Flow Fundamentals (Notebook)
The notebook companion to Flow: build a Flow, run it as
plain Python, then drop it into a graph and step it in-process. Every output
block below is captured from a real run — nothing here needs a backend, camera,
or robot.
⬇ Download .ipynb▶ Open in Colab
The smallest shape
Section titled “The smallest shape”Inputs and outputs are @io dataclasses; their fields are the graph ports.
Flow[NumberInput, NumberOutput] is the type boundary Retriever checks.
Output
Takeaway: a Flow is callable directly — no pipeline, clock, or event loop. That is what makes it unit-testable and breakpoint-friendly on its own.
_signals says what arrived
Section titled “_signals says what arrived”@io makes every field Optional, so a Flow can receive a partial input.
_signals lists the fields actually set, so step() can branch on what it got.
Output
Local state with reset()
Section titled “Local state with reset()”Runtime-local state — counters, buffers, model handles — belongs in reset(),
which the runtime calls once when a run starts. Keep __init__ lightweight.
Output
Put timing in the Pipeline, not the Flow
Section titled “Put timing in the Pipeline, not the Flow”A Flow never decides when it runs — the graph does, via a clock (@) and a
sync policy on each edge. pipe.step(dt=...) advances the whole graph one tick
at a time, in your process, where you can set a breakpoint inside any step().
Output
Takeaway: the Flow owns local computation; the graph owns when it wakes and which upstream record it consumes. Next: Time and Sync shows how clocks and sync policies build the input passed to step().
This page is generated from notebooks/src/flow_fundamentals.py (jupytext py:percent source). Grab the runnable notebook and run every cell yourself.
