Skip to main content

permchain

Project description

permchain

Get started

pip install permchain

Usage

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.

Near-term Roadmap

  • Add initial retry support (pending changes in langchain)
  • Implement OUT as regular topic
  • Implement IN as regular topic
  • Add Connection.peek() to monitor past messages from all topics
  • Enable resuming PubSub from the "middle" of the computation
  • Add test for .peek()
  • Add "wait until topic X is done" pattern, aka. Topic.join()
  • Move tracking of inflight processes/messages to Connection
    • Use this to build retry mechanism, where any inflight messages are moved back to the respective topics when restarting
    • But this would require being able to replay a message for a single listener only, which maybe requires a larger redesign of PubSub<>Connection contract than what I wanted to do here
  • Detect cycles (aka. infinite loops) and throw an error
    • Allow user to catch that error (by subcribing to an error topic?)
  • Add example for "human in the loop" pattern, one of the two below
    • Example with one permchain, which runs until it produces either 1. request for input or 2. output. The consumer code then gets the needed info, and restarts the permchain with answer, and same state id
    • Allow interrupting execution by breaking out of the iterator returned by .stream()
      • Build example showing a simple "human in the loop" pattern using this, ie. if a certain message asking for input is published the consumer of the iterator breaks out, does something and then restarts it
  • Add Redis-backed Connection implementation

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

permchain-0.0.3.tar.gz (9.1 kB view details)

Uploaded Source

Built Distribution

permchain-0.0.3-py3-none-any.whl (9.4 kB view details)

Uploaded Python 3

File details

Details for the file permchain-0.0.3.tar.gz.

File metadata

  • Download URL: permchain-0.0.3.tar.gz
  • Upload date:
  • Size: 9.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.5 Darwin/22.6.0

File hashes

Hashes for permchain-0.0.3.tar.gz
Algorithm Hash digest
SHA256 3bf886903d92654bf4ab927c81f173052509fc9d6457ce45f6ca39e684376be5
MD5 074d29c0f5b91c5f25ee7bb89b38f6b6
BLAKE2b-256 53de42085bc846f520fa8a13bb643e9555ab4eae40dfa53482bbfc78d07f78e5

See more details on using hashes here.

File details

Details for the file permchain-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: permchain-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 9.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: poetry/1.6.1 CPython/3.11.5 Darwin/22.6.0

File hashes

Hashes for permchain-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 e2729d4a102d0bb1296dc578e411f52487f1d689a0ecccc8f5a14eb60cf17d6e
MD5 207eb238e3410192fe71c8e33127265a
BLAKE2b-256 d9d3b8b5fae46e180f7bcca4c2559e6a7533748c8655c0750199d33ef56b08aa

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page