Duraton Python SDK: durable-workflow runner over the duraton.connect.v0 WebSocket protocol
Project description
duraton (Python SDK)
The Python runner SDK for Duraton. It speaks the frozen
duraton.connect.v0 WebSocket protocol: a runner dials the engine, registers its workflows, and
the engine drives each run one replay pass at a time. Durable steps memoize across passes, so a
handler resumes exactly where it left off after a crash, deploy, sleep, or human approval.
This is the core transport + runtime. See DECISIONS.md for the design, the evidence behind
every library/tooling choice, and the spec-conformance notes.
Requires Python >= 3.11.
Quickstart
import asyncio
from duraton import Runner, define_workflow
from duraton.context import StepContext
async def fulfill(ctx: StepContext) -> object:
charge = await ctx.step.run("charge", lambda: {"charge_id": "ch_1"})
await ctx.step.sleep("cooldown", "30s")
await ctx.step.emit("notify", name="order.fulfilled", data=charge)
return {"ok": True}
workflows = [define_workflow("fulfill", fulfill, triggers=[{"event": "order.created"}])]
async def main() -> None:
# url / app / api_key fall back to DURATON_URL / DURATON_APP / DURATON_API_KEY.
await Runner(workflows).run() # blocks, reconnecting with backoff, until cancelled
asyncio.run(main())
Runner(...).run() is the blocking entrypoint. Inside an existing loop, async with Runner(...)
runs it in the background, or connect(workflows, ...) returns a handle you can aclose().
The ctx surface (10 structural ops)
ctx.step.run / sleep / sleep_until / wait_for_event / run_workflow / emit,
ctx.webhook.send, ctx.step.approval, ctx.step.ai.infer, ctx.score. Plus ctx.log
(structured, per-run), ctx.asserts (eval checks), and run metadata (ctx.run_id, ctx.attempt,
ctx.app, ctx.event).
Configuration
| Knob | Option | Env | Default |
|---|---|---|---|
| Engine URL | url |
DURATON_URL |
http://localhost:6770 |
| App | app |
DURATON_APP |
default |
| API key (Bearer) | api_key |
DURATON_API_KEY |
(dev: none) |
| App-ping interval | ping_interval_ms |
DURATON_CONNECT_PING_MS |
25000 |
| Pong watchdog | pong_timeout_ms |
DURATON_CONNECT_PONG_TIMEOUT_MS |
10000 |
| Reconnect initial | reconnect_initial_ms |
DURATON_CONNECT_RECONNECT_INITIAL_MS |
500 |
| Reconnect max | reconnect_max_ms |
DURATON_CONNECT_RECONNECT_MAX_MS |
30000 |
Development
uv sync # install
uv run pytest -q # offline conformance + unit tests
uv run mypy . # strict type gate
uv run pyright # second type checker (src)
uv run ruff check . && uv run ruff format --check .
uv build # wheel + sdist
The offline conformance tests reproduce the shared golden vectors
(tests/fixtures/golden-vectors.json) byte-for-byte: step-id hashing (incl. Unicode /
no-normalization), :n dedup, version parsing, and envelope round-trips.
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 duraton-0.1.1.tar.gz.
File metadata
- Download URL: duraton-0.1.1.tar.gz
- Upload date:
- Size: 56.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
ed89ec9d2fb1ae0561f54a7e7c3469205090a08bf7ff68fa89cfa7bed8391c88
|
|
| MD5 |
7b653dbdb5d522082c8d50617b398909
|
|
| BLAKE2b-256 |
be035b48106fd8861ae589f35f6d56d303885b4723e701bd8c8822cd781ab1d5
|
File details
Details for the file duraton-0.1.1-py3-none-any.whl.
File metadata
- Download URL: duraton-0.1.1-py3-none-any.whl
- Upload date:
- Size: 75.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.9.18 {"installer":{"name":"uv","version":"0.9.18","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"macOS","version":null,"id":null,"libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
1a2114740d228dcc04e543240b13858c880eae34f37c8c089ad438a8bf88deeb
|
|
| MD5 |
0538b0fa039919abecfea000c0afd8c4
|
|
| BLAKE2b-256 |
98cc51cd81f1c5b659f74e3fa17454dfdfdcf43253d856bc251bcb4797962cb6
|