Python SDK for the Threadify Engine — workflow orchestration via WebSocket and GraphQL
Project description
Threadify Python SDK
Python SDK for connecting to the Threadify Engine over WebSocket and querying archived data over GraphQL.
Installation
pip install threadify-sdk
For local development:
pip install -e ".[dev]"
Quick Start
import asyncio
import logging
from threadify import Threadify
async def main():
try:
conn = await Threadify.connect(
"your-api-key",
service_name="orders-service",
ws_url="wss://eng.threadify.dev/threads",
)
except Exception as e:
logging.error(f"Failed to connect: {e}")
return
try:
thread = await conn.start(contract_name="order_flow")
# Easy chaining!
await (
thread.step("order_received")
.add_context({"orderId": "ORD-123"})
.success("Order accepted")
)
except Exception as e:
logging.error(f"Error in thread: {e}")
finally:
await conn.close()
if __name__ == "__main__":
asyncio.run(main())
ws_url is required. The SDK no longer uses a hardcoded default URL.
Configuration
Connect options
Use keyword arguments with Threadify.connect(...):
service_namews_url(required)graphql_urldebugmax_in_flightconnect_timeout
Example:
from threadify import Threadify
conn = await Threadify.connect(
"your-api-key",
service_name="inventory-service",
ws_url="wss://eng.threadify.dev/threads",
debug=True,
)
Join options
Use Connection.join(...) with keyword arguments:
token=...thread_id=...androle=...
Example:
thread = await conn.join(token="jwt-token")
Or:
thread = await conn.join(
thread_id="thread-123",
role="supplier",
)
Subscriptions
Preferred API:
subscribe(event, step_name, handler)unsubscribe(event, step_name)
Supported event patterns:
step.successstep.failedstep.*rule.passedrule.violatedrule.**
Example:
def handle_notification(notification):
if notification.is_violated:
print(notification.message)
conn.subscribe("rule.violated", "payment_step", handle_notification)
Versioning & Releases
This SDK follows Semantic Versioning and Conventional Commits. Releases are automated via GitHub Actions.
fix: ...-> Patch bumpfeat: ...-> Minor bumpfeat!: ...orBREAKING CHANGE: ...-> Major bump
Testing
To run the SDK tests, execute:
make test
Alternatively, use pytest:
python3 -m pytest
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file threadify_sdk-0.2.0.tar.gz.
File metadata
- Download URL: threadify_sdk-0.2.0.tar.gz
- Upload date:
- Size: 32.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
7e94f6b294dd4714f7bcb9205f74861af63d3139e81380e207142a1ab1ecfd19
|
|
| MD5 |
156531387328955a6cced648f1b29eba
|
|
| BLAKE2b-256 |
9bf2e64ada5b6d6a9cb79d72e3842a29fb73abb9c7944d50c4e9eb7bac6bd716
|
File details
Details for the file threadify_sdk-0.2.0-py3-none-any.whl.
File metadata
- Download URL: threadify_sdk-0.2.0-py3-none-any.whl
- Upload date:
- Size: 26.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.9.6
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
49a47327307bc2f41ab7f44ba8b00eb56634bc7a4f0ca90ee127059d57067daa
|
|
| MD5 |
ade24ca17cd4cdd0ba4153e52388f3cf
|
|
| BLAKE2b-256 |
1853f7ab61c7e194849bcd224979225800bb025f02cac597e247ffe2665fed16
|