Skip to main content

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


Download files

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

Source Distribution

offbit_reflow-0.2.3.tar.gz (726.8 kB view details)

Uploaded Source

Built Distributions

If you're not sure about the file name format, learn more about wheel file names.

offbit_reflow-0.2.3-cp39-abi3-win_amd64.whl (5.7 MB view details)

Uploaded CPython 3.9+Windows x86-64

offbit_reflow-0.2.3-cp39-abi3-manylinux_2_28_x86_64.whl (6.4 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.28+ x86-64

offbit_reflow-0.2.3-cp39-abi3-manylinux_2_28_aarch64.whl (5.5 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.28+ ARM64

offbit_reflow-0.2.3-cp39-abi3-macosx_11_0_arm64.whl (5.1 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

offbit_reflow-0.2.3-cp39-abi3-macosx_10_12_x86_64.whl (5.9 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

Details for the file offbit_reflow-0.2.3.tar.gz.

File metadata

  • Download URL: offbit_reflow-0.2.3.tar.gz
  • Upload date:
  • Size: 726.8 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: maturin/1.13.1

File hashes

Hashes for offbit_reflow-0.2.3.tar.gz
Algorithm Hash digest
SHA256 db96461b0a3c6991a620e18ade90055408b54fc13f1cba4e961e51278240aa1e
MD5 3b29a48c8240fe99f629ec826ca94e2c
BLAKE2b-256 8d2c6c2e654b639cad651064a009d23c65e9d83c660e4a701dd198aa12104840

See more details on using hashes here.

File details

Details for the file offbit_reflow-0.2.3-cp39-abi3-win_amd64.whl.

File metadata

File hashes

Hashes for offbit_reflow-0.2.3-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 9ea4f9579deedcc15eec679b9ff8644140479ca75fb88c24348c21e599702562
MD5 c539776c3e1b256d34514344451335e2
BLAKE2b-256 830a4add2a92c1b634eef2788211f0733a9c3c8e139e620c87e2e68d20aa7993

See more details on using hashes here.

File details

Details for the file offbit_reflow-0.2.3-cp39-abi3-manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for offbit_reflow-0.2.3-cp39-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 d46d4c9ab62029e12e10b2da2877a03af51160dad8c08f55318f30f5be8889f0
MD5 6eda38b9ba7cc66da55094cdb1763ed7
BLAKE2b-256 2cca7d6e93787fb60068f5f4c113b7ef6dcfe53647ffdcac15a9f6766efa7b37

See more details on using hashes here.

File details

Details for the file offbit_reflow-0.2.3-cp39-abi3-manylinux_2_28_aarch64.whl.

File metadata

File hashes

Hashes for offbit_reflow-0.2.3-cp39-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 9a5ec65179b112a0daf83293521a8c90ce61d573873cc2ffc71023705781e6ad
MD5 cf19bed5614f52d722e5cfb21ef2ea6e
BLAKE2b-256 b2d941c6a120d5b0366eead1944d60b8d3afca2a5eef924c7a702e61decf1d2a

See more details on using hashes here.

File details

Details for the file offbit_reflow-0.2.3-cp39-abi3-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for offbit_reflow-0.2.3-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 32a55ed2cee67274dbba9592a00326818f3e941ba18c9bef217bc3ef02cc03d3
MD5 9b1ce885d7f15b5e21141364951b1caf
BLAKE2b-256 f22d06e3f617740f50fd467efa7769ea343e862fbf8b2ee858a1d746a07430da

See more details on using hashes here.

File details

Details for the file offbit_reflow-0.2.3-cp39-abi3-macosx_10_12_x86_64.whl.

File metadata

File hashes

Hashes for offbit_reflow-0.2.3-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 42c49e9aba17b4da3a98dac69f44c6b60d3dfac81e34bff31d6a42d8a7743cee
MD5 92f60dc8341530f992024d9a67ee8648
BLAKE2b-256 76496e20f9e71a7b5bd46244a1454db4d99dda9705fa6b5b7d8f9d0132827658

See more details on using hashes here.

Supported by

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