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. Each release ships two flavours of every pack:

Flavour Filename When to use
Full multi-triple <name>-<version>.rflpack (~22 MiB) Distributing to mixed-platform consumers
Per-triple slim <name>-<version>-<triple>.rflpack (~3 MiB) Shipping to a known platform — much smaller download
VER=0.2.0
# Slim variant for the host you're running on (Apple Silicon shown).
curl -LO https://github.com/offbit-ai/reflow/releases/download/pack-v$VER/reflow.pack.ml-$VER-aarch64-apple-darwin.rflpack

# Or the full bundle if you don't know the deployment target ahead of time.
curl -LO https://github.com/offbit-ai/reflow/releases/download/pack-v$VER/reflow.pack.ml-$VER.rflpack

Triples published per pack are listed in sdk/packs/README.md.

load_pack() accepts either flavour identically — it picks the binary that matches the runtime triple at load time.

To slim a downloaded full bundle yourself, install the reflow_pack_cli crate and run:

reflow-pack strip reflow.pack.ml-0.2.0.rflpack
# → reflow.pack.ml-0.2.0-<host-triple>.rflpack

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 SDK release 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.6.tar.gz (735.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.6-cp39-abi3-win_amd64.whl (5.8 MB view details)

Uploaded CPython 3.9+Windows x86-64

offbit_reflow-0.2.6-cp39-abi3-manylinux_2_28_x86_64.whl (6.6 MB view details)

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

offbit_reflow-0.2.6-cp39-abi3-manylinux_2_28_aarch64.whl (5.7 MB view details)

Uploaded CPython 3.9+manylinux: glibc 2.28+ ARM64

offbit_reflow-0.2.6-cp39-abi3-macosx_11_0_arm64.whl (5.2 MB view details)

Uploaded CPython 3.9+macOS 11.0+ ARM64

offbit_reflow-0.2.6-cp39-abi3-macosx_10_12_x86_64.whl (6.1 MB view details)

Uploaded CPython 3.9+macOS 10.12+ x86-64

File details

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

File metadata

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

File hashes

Hashes for offbit_reflow-0.2.6.tar.gz
Algorithm Hash digest
SHA256 5959111702c225b1512b5406a3dce113c8c24e91967903fa2cab6732e745ebc9
MD5 914bda57c4b722553b8c29c914197c49
BLAKE2b-256 aee97b142248a22b5da8c13080c65b8d4c1ae9eafef38e98f8b1e370d8bb0eea

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for offbit_reflow-0.2.6-cp39-abi3-win_amd64.whl
Algorithm Hash digest
SHA256 352f52ec9312f5ca196169a4411b3c6f25bd82efe0fbf8ef15dd07053515f7f6
MD5 b62f500e52e0429c78c8b90d911688f1
BLAKE2b-256 37be2488e9496cfa8501852a7c48b49d2743e443df047947eda3bf9b2f39ff03

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for offbit_reflow-0.2.6-cp39-abi3-manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 eff69ecee8d523829f6495e32bb01eff7d97840b35089b0e905552c77b3a1120
MD5 9914bbccee618490161367914f3924e5
BLAKE2b-256 6857c692fd30fbf3d4f6e249934a57cf0bef3bdb87cf2ff94611cbcc01526cb7

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for offbit_reflow-0.2.6-cp39-abi3-manylinux_2_28_aarch64.whl
Algorithm Hash digest
SHA256 d3f75da079ab6932c0ee517e5b4ba1f5a74b772bdf46ef80f7cf9122773f3761
MD5 a94e9b7b01a035eb1fd1c3d4631f705a
BLAKE2b-256 58365903fb1f4641968e3949f8e1a3d26280d5a092c08e75d087983c6d36f109

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for offbit_reflow-0.2.6-cp39-abi3-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ab18407e6b0d81105403f5dc13fa6dfa4f1b4ace6c9565f1c779c9b1540ff814
MD5 4d74b52294b52e218592024564f46c43
BLAKE2b-256 98abe1a6656d3f78a9817523f0877f0ac4e01f28ff9aa4d3cfc9d1890c199623

See more details on using hashes here.

File details

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

File metadata

File hashes

Hashes for offbit_reflow-0.2.6-cp39-abi3-macosx_10_12_x86_64.whl
Algorithm Hash digest
SHA256 183cce737237beba94384d57455c0088d956944c708ae8e10c407399ca0f9595
MD5 ac2b0b63dfb8891b8ef2d2fdd2680265
BLAKE2b-256 591c7bbfbf795c78c9b66317db7d65aab365491769de24bdb9afe2c0ebe65636

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