From a4e1f9036d8eaefde25a08018be7ec360d97de77 Mon Sep 17 00:00:00 2001 From: Nuno Campos Date: Tue, 29 Aug 2023 14:40:21 +0100 Subject: [PATCH] Add readme --- README.md | 33 +++++++++++++++++++++++++++++++++ permchain/__init__.py | 9 +++++++++ 2 files changed, 42 insertions(+) diff --git a/README.md b/README.md index e69de29bb..58e5e7ff4 100644 --- a/README.md +++ b/README.md @@ -0,0 +1,33 @@ +# `permchain` + +## Get started + +`pip install permchain` + +## Usage + +```python +from permchain import InMemoryPubSubConnection, PubSub, Topic + +topic_one = Topic("one") +chain_one = Topic.IN.subscribe() | (lambda x: x + 'b') | topic_one.publish() +chain_two = topic_one.subscribe() | (lambda x: x + 'c') | Topic.OUT.publish() + +conn = InMemoryPubSubConnection() +pubsub = PubSub(processes=(chain_one, chain_two), connection=conn) + +assert pubsub.invoke('a') == ['abc'] +``` + +Check `tests` and `examples` for more examples. + +## Roadmap + +- [ ] Add initial retry support (pending changes in `langchain`) +- [ ] Detect cycles (aka. infinite loops) and throw an error + - [ ] Allow user to catch that error (by subcribing to an error topic?) +- [ ] Replace Queue data structure with a Log data structure (this will enable checking the status of the readers, etc.) + - [ ] eg. https://anyio.readthedocs.io/en/3.x/streams.html + - [ ] Implement IN and OUT topics as regular topics +- [ ] Enable resuming PubSub from the "middle" of the computation +- [ ] Add Redis-backed Connection implementation diff --git a/permchain/__init__.py b/permchain/__init__.py index e69de29bb..845641df9 100644 --- a/permchain/__init__.py +++ b/permchain/__init__.py @@ -0,0 +1,9 @@ +from permchain.pubsub import PubSub +from permchain.topic import Topic +from permchain.connection_inmemory import InMemoryPubSubConnection + +__all__ = [ + "PubSub", + "Topic", + "InMemoryPubSubConnection", +]