Reflow is a modular flow-based programming runtime that executes actor-model DAGs for data pipelines, real-time media, visual tooling, and optional ML/CV workloads. This package is the official Python SDK.
Project description
offbit-reflow — Python SDK for Reflow
Reflow is a modular flow-based programming runtime built on the actor model. Graphs are declarative DAGs: each node is an actor with named in/out ports, edges route messages, and a network executor runs the whole thing with bounded backpressure and a tracing stream. It ships a standard library of ~300 actors covering data, media, GPU rendering, animation, I/O, and optional ML / CV — plus the hooks to register your own.
This package is the official Python SDK. It wraps the runtime via pyo3 and exposes idiomatic Python classes that mirror the Node / Go SDKs one-for-one.
pip install offbit-reflow
from offbit_reflow import Actor, Network, Message
Quick start
from offbit_reflow import Actor, Network, Message
class Doubler(Actor):
component = "doubler"
inports = ["in"]
outports = ["out"]
def run(self, ctx):
n = ctx.inputs["in"]["data"]
ctx.done({"out": Message.integer(n * 2)})
class Log(Actor):
component = "log"
inports = ["in"]
outports = []
def run(self, ctx):
print("got:", ctx.inputs["in"])
ctx.done()
net = Network()
net.register_actor("tpl_doubler", Doubler())
net.register_actor("tpl_log", Log())
net.add_node("a", "tpl_doubler")
net.add_node("b", "tpl_log")
net.add_connection("a", "out", "b", "in")
net.add_initial("a", "in", {"type": "Integer", "data": 21})
net.start()
# ... later:
net.shutdown()
Authoring actors
Subclass Actor. Class-level attributes declare ports and await semantics; the instance run(ctx) method is the per-tick body:
class Sum(Actor):
component = "sum"
inports = ["a", "b"]
outports = ["sum"]
await_all_inports = True
def run(self, ctx):
a = ctx.inputs["a"]["data"]
b = ctx.inputs["b"]["data"]
ctx.done({"sum": Message.integer(a + b)})
Inside run(ctx):
| Member | Purpose |
|---|---|
ctx.inputs |
dict keyed by port — each entry is a JSON-shaped Message. |
ctx.config |
Per-node config passed at graph time. |
ctx.done(outputs=None) |
Emit outputs keyed by output port. Values are Message instances or JSON-shaped Messages. |
ctx.fail(message) |
Abort this tick with an error. |
Exactly one of done / fail must be called per tick. If run raises, the SDK calls fail with the exception's message.
Multi-graph composition
Merge N GraphExport dicts into a single runnable graph:
from offbit_reflow import compose_graphs, Graph, Network
composed = compose_graphs({
"graphs": [left_export, right_export], # dicts
"connections": [
{"from": {"process": "gsrc/src", "port": "out"},
"to": {"process": "gsink/sink", "port": "in"}},
],
"shared_resources": [],
"properties": {"name": "pipeline"},
"case_sensitive": False,
})
g = Graph.from_json(composed)
net = Network.from_graph(g)
Standard component catalog
from offbit_reflow import template_actor, template_list
net.register_actor("tpl_http_request", template_actor("tpl_http_request"))
print([tid for tid in template_list() if tid.startswith("tpl_math_")])
The catalog is documented at docs/components/standard-library.md (~300 templates).
Subgraphs
from offbit_reflow import SubgraphBuilder
sub = SubgraphBuilder(graph_export_json) # dict or parsed object
sub.register_actor("my_custom", MyCustom())
sub.fill_from_catalog() # resolve bundled components
sg = sub.build()
net.register_actor("tpl_sub", sg)
Streams
Producer side:
from offbit_reflow import Stream
s = Stream.create(buffer_size=64, content_type="image/jpeg")
s.send_bytes(frame1)
s.send_bytes(frame2)
s.end()
ctx.done({"out": s.into_message()})
Consumer side:
rdr = ctx.inputs["frames"].take_stream()
while True:
f = rdr.recv(500)
if f["kind"] == "data":
handle(f["data"])
elif f["kind"] == "end":
break
elif f["kind"] in ("closed", "timeout"):
break
elif f["kind"] == "error":
raise RuntimeError(f["error"])
Events
events = net.events()
while True:
evt = events.recv(timeout_ms=200)
if evt is None:
continue
print(evt.get("_type"), evt)
Subscribe before net.start() so no events are missed.
Building locally
cd sdk/python
python -m venv .venv && source .venv/bin/activate
pip install maturin pytest
maturin develop
pytest -q
Releasing
Releases are built and published by CI — see
.github/workflows/publish-python.yml. Tag a commit with
python-v<version> (e.g. python-v0.2.0) and the workflow builds
wheels for every supported triple (linux x86_64/aarch64, macOS
x86_64/aarch64, windows x64), plus an sdist, verifies metadata,
smoke-tests the wheel on each host, and uploads everything to PyPI.
Publishing currently uses an API token stored as the PYPI_API_TOKEN
repository secret. Migration to PyPI trusted publishing (OIDC) is a
one-line swap once the first release is live.
License
MIT OR Apache-2.0.
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 Distributions
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 offbit_reflow-0.2.0.tar.gz.
File metadata
- Download URL: offbit_reflow-0.2.0.tar.gz
- Upload date:
- Size: 699.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a3a870d0ce2a463173ef03a8d0e7b75f8b51e3cee8d3f11886c683c8800f9f31
|
|
| MD5 |
edb9ba281c1d58eebd4e7599265a366b
|
|
| BLAKE2b-256 |
c6c8ea52f2c4a59147df4e50edaa727ebb0abd7b2617212fd33b943144698154
|
File details
Details for the file offbit_reflow-0.2.0-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: offbit_reflow-0.2.0-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 5.5 MB
- Tags: CPython 3.9+, Windows x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
169b40f23ccddcc6fb8af520b505255abfd95ad77611280c3b5ff7ed0a73ea3c
|
|
| MD5 |
6ee224147b89da1f187ed02101884543
|
|
| BLAKE2b-256 |
22e6fe88a242d3398fa173363678c98b781590db602b18ee7f4410c5e0786909
|
File details
Details for the file offbit_reflow-0.2.0-cp39-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: offbit_reflow-0.2.0-cp39-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 6.2 MB
- Tags: CPython 3.9+, manylinux: glibc 2.28+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0c559c87e6a24253078ae227037737380d279fd70304b4654f30f32254dcbbe6
|
|
| MD5 |
eb47231fb88d3bade1011d90c49edee5
|
|
| BLAKE2b-256 |
458cf1188f8dc72622e6d1e69a200de283211f36adf7b4657e70ae2b7037b74f
|
File details
Details for the file offbit_reflow-0.2.0-cp39-abi3-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: offbit_reflow-0.2.0-cp39-abi3-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 5.4 MB
- Tags: CPython 3.9+, manylinux: glibc 2.28+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
93d83fffb6aba76166de29bcf9aad0b429853408286b5d43935e28df078c8fc0
|
|
| MD5 |
de1b1cdd86086b9614c96c6676e41c16
|
|
| BLAKE2b-256 |
4272387dcd8aa2506e6a6bf7d57aab8b95d6327006cb533bd2bcd9ffc43010a9
|
File details
Details for the file offbit_reflow-0.2.0-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: offbit_reflow-0.2.0-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 4.9 MB
- Tags: CPython 3.9+, macOS 11.0+ ARM64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
5027e4eaf7fc4bf1c0eb8e7b401757828c195dcd097f8d0cdf0a8f9467cab202
|
|
| MD5 |
e478930ac80e18aeb71789f326819bff
|
|
| BLAKE2b-256 |
48df063dffa561fcf30dcd83d63f66a4fbfa19beb409c1a5b439da1d2731b359
|
File details
Details for the file offbit_reflow-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: offbit_reflow-0.2.0-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 5.7 MB
- Tags: CPython 3.9+, macOS 10.12+ x86-64
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
66492cb59ed25d90290c825c0f6ff3b19202e1e4736eeca5cbe24b7f9c490886
|
|
| MD5 |
af829b8908cf7ca6765dadd3a0f8a52e
|
|
| BLAKE2b-256 |
1c8b07ae7ddd4a6bf235d36b9258ac10b28835fad67c750124660a747671c7f9
|