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
The wheel ships the pure-Rust + av-core slice of reflow_components
— roughly 270 templates covering animation, flow control, math, vector,
2D graphics, asset DB, scene graph, HTTP integration, stream ops, DSP,
and procedural generation. Heavy optional palettes (GPU, ML, browser
automation, video encoding, window events, ~6,700 API-service wrappers)
are not bundled and install as actor packs.
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_")])
Full catalog reference: docs/components/standard-library.md.
Actor packs
Packs are .rflpack bundles that publish additional templates into
this SDK at runtime. template_actor(id) and template_list()
transparently include pack-supplied templates after load.
import offbit_reflow as reflow
# Peek before committing.
print(reflow.inspect_pack("./reflow.pack.ml-0.2.0.rflpack"))
# Load (idempotent).
reflow.load_pack("./reflow.pack.ml-0.2.0.rflpack")
# Pack-owned templates now resolve normally.
net.register_actor("tpl_ml_run_inference",
reflow.template_actor("tpl_ml_run_inference"))
print(reflow.list_packs())
print(reflow.pack_abi_version())
First-party packs live under sdk/packs/:
| Pack | Templates | Pulls in |
|---|---|---|
reflow.pack.browser |
1 | chromiumoxide |
reflow.pack.video_encode |
1 | openh264 |
reflow.pack.ml |
12 | CV ops, LiteRT inference |
reflow.pack.gpu |
6 | wgpu SDF / scene / 2D renderers |
reflow.pack.window_events |
5 | Keyboard / mouse / gamepad / touch / window |
reflow.pack.api_services |
~6700 | Generated Slack / Stripe / Jira / Notion / … |
Where to get .rflpack files
First-party bundles ship as assets on every GitHub Release
whose tag starts with pack-v. Grab the one you want and hand its
path to load_pack():
VER=0.2.0
curl -LO https://github.com/offbit-ai/reflow/releases/download/pack-v$VER/reflow.pack.ml-$VER.rflpack
Each .rflpack bundles every supported triple in one file — the
loader picks the right dylib at runtime. Catalog + per-pack contents:
sdk/packs/README.md.
Third-party packs are distributed however their author chooses (PyPI
data files, GitHub Releases, internal registry) — any local file path
works with load_pack().
ABI lockstep. A pack is pinned to the rustc version of the SDK it
was built against. Pick the pack-v* release whose version matches
your offbit-reflow; rebuild from source
(sdk/packs/README.md)
if you need a pack for a different SDK version.
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.1.tar.gz.
File metadata
- Download URL: offbit_reflow-0.2.1.tar.gz
- Upload date:
- Size: 712.2 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: maturin/1.13.1
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
440aab05abfef7817ec9245764e5ca87fd416f3e9a6ff92dbb27bd302b8772ed
|
|
| MD5 |
6874a98813cc423ac79f9488d04c026e
|
|
| BLAKE2b-256 |
0df3a6f4b1d1d570609c107a35274cb2d291ac0f31d9e0cb9655cbbabeaae1c5
|
File details
Details for the file offbit_reflow-0.2.1-cp39-abi3-win_amd64.whl.
File metadata
- Download URL: offbit_reflow-0.2.1-cp39-abi3-win_amd64.whl
- Upload date:
- Size: 5.6 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 |
2cc408224c49a037fb49afa22a25203e6f8e29fee7ea6728ebd8df44c34eaae7
|
|
| MD5 |
6dc5da2e5483ecc2bfe4dc5b20eeb1c6
|
|
| BLAKE2b-256 |
22f1e27144970fbde34a537e98710f22a5a35bfaae03d80225b9bffab387b3cc
|
File details
Details for the file offbit_reflow-0.2.1-cp39-abi3-manylinux_2_28_x86_64.whl.
File metadata
- Download URL: offbit_reflow-0.2.1-cp39-abi3-manylinux_2_28_x86_64.whl
- Upload date:
- Size: 6.3 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 |
9c92615d50197a923455da7477afdf90a0749f16a72cde2eea22cfa6aaabfc22
|
|
| MD5 |
6db8c96e7f72f7eb0d3273d4da72fbdc
|
|
| BLAKE2b-256 |
b85620c9e987cd3a62dd2f86e0d2c621d2d7c9ba2e267a7c7ac9ea44bf37ba5b
|
File details
Details for the file offbit_reflow-0.2.1-cp39-abi3-manylinux_2_28_aarch64.whl.
File metadata
- Download URL: offbit_reflow-0.2.1-cp39-abi3-manylinux_2_28_aarch64.whl
- Upload date:
- Size: 5.5 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 |
74c938e38b387f2808d943d73701b838aa3358783d6e03a2444216ec83a6f784
|
|
| MD5 |
63891051b77e7a7aefb1c4f9cb88b6ba
|
|
| BLAKE2b-256 |
a2438a9d1138bb85f5c272f1794a616dff62161cc5113d27466b5d276752b5cd
|
File details
Details for the file offbit_reflow-0.2.1-cp39-abi3-macosx_11_0_arm64.whl.
File metadata
- Download URL: offbit_reflow-0.2.1-cp39-abi3-macosx_11_0_arm64.whl
- Upload date:
- Size: 5.0 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 |
7c9f25c45e0e95320cf5a02c0a67de2126300dab94e457559bfe6e1273f520dd
|
|
| MD5 |
06bc0e360d463da91e1a2953bdc37164
|
|
| BLAKE2b-256 |
a1b27335eff9e7a30c84500cf25e5ce797b2a0ac6ef9bbda104a45a5c0b40689
|
File details
Details for the file offbit_reflow-0.2.1-cp39-abi3-macosx_10_12_x86_64.whl.
File metadata
- Download URL: offbit_reflow-0.2.1-cp39-abi3-macosx_10_12_x86_64.whl
- Upload date:
- Size: 5.8 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 |
9a76420cf9546c1b7dd31001ddf179d1cdca3496c5634f4ec1011332d100d6a2
|
|
| MD5 |
51805c1bbfb55f4c383d702dcf039aec
|
|
| BLAKE2b-256 |
afe2a0c28d457ba5ad6dd9b117fa0e86eead0f92a07aef55443f14bde1fda805
|