Skip to content

FlowyML Light

Connect ordinary Python functions into a local pipeline with named artifacts, retries, and optional disk caching. The Python runner uses the standard library. An optional terminal inspector adds a live, keyboard-driven view.

Install

Install From this checkout From a release
Standalone local Python and CLI python -m pip install ./runtime ./light python -m pip install flowyml-light
Light with the interactive TUI python -m pip install ./runtime "./light[tui]" python -m pip install "flowyml-light[tui]"

Plain pip install flowyml installs Basic, including tracking, Studio and stack orchestration. Light installs only the shared standard-library runtime. Both provide the same Python API for local jobs, the flowyml command, and python -m flowyml.

Run a Python job

Save this example as job.py and run python job.py.

from flowyml.light import Artifact, Dataset, Pipeline, step

orders = Dataset("orders", list, "Orders for the current batch")
amounts = Dataset("orders/amounts", list)
total = Artifact("orders/total", int)


def extract_amounts(rows):
    return [row["amount"] for row in rows]


def add_amounts(values):
    return sum(values)


extract = step(inputs={"rows": orders}, outputs=amounts)(extract_amounts)
add = step(inputs={"values": amounts}, outputs=total)(add_amounts)
job = Pipeline.from_steps(extract, add, name="daily_orders", inputs=orders)

if __name__ == "__main__":
    result = job.run({orders: [{"amount": 12}, {"amount": 8}]})
    print(result[total])  # 20
    print(result.summary())

extract_amounts and add_amounts can be called, unit tested, and debugged directly. An artifact names a value in memory. Its optional Python class is checked at the boundary. The mapping {"values": amounts} tells the runner which artifact supplies the function's values argument.

For shorter jobs, decorate a function with @step. Its required parameter names connect to artifacts or pipeline context, and the function name becomes its output name. For multiple outputs, declare a sequence of names and return a matching tuple, list, or dictionary. Pass outputs=[] for a step that just performs an action.

Build the DAG automatically

Define the steps in any order and construct the pipeline after their declarations. Leaving out the step list enables discovery. FlowyML wires matching artifact names, checks the connections and determines the execution order. Save this example as scores.py.

from flowyml.light import Context, Pipeline, current_context, step


@step(cache=True)
def score(samples, scale):
    return {"score": sum(samples) * scale, "dataset": current_context().dataset}


@step
def samples():
    return [2, 3]


job = Pipeline("scores", context=Context(scale=2, dataset="train"))

if __name__ == "__main__":
    assert job.build().get_dependencies("score") == {"samples"}
    assert job.run(context={"scale": 3})["score"]["score"] == 15

Pipeline.discover("scores", context=...) and auto_discover=True make discovery explicit. In a module or factory, discovery finds visible decorated steps, including directly imported steps. To select a family across modules, decorate its members with @step(pipeline="scores") and import those modules before discovery. Use register=False for helpers that should only run in explicit pipelines.

Parameters such as scale come from context when there is no matching artifact. Declared pipeline inputs and step outputs take precedence over a context key of the same name. Nested helpers, conditions and event callbacks can read the active configuration via current_context(). Each invocation starts with its own parameter mapping and restores the enclosing run's context on return. Cache keys include run configuration, so a change used inside a helper also invalidates cached results.

Run flowyml inspect scores.py:job to see the connections and context parameter names. Use flowyml run scores.py:job --tui -c dataset=validation to override a setting in the terminal inspector. CLI overrides are strings. Pass Python values directly to job.run(context=...) for typed overrides.

Inspect and debug

Call print(job.describe()) to see the execution order and the named connections. Constructing the graph checks for missing producers, duplicate outputs, incompatible declared types, and cycles before any function runs. A failed function raises its original exception with its Python traceback. On Python 3.11 and later, the exception also includes the pipeline and step names. On Python 3.10 the runner logs that context.

For a step that can recover from a temporary error, set retry=2 to allow two additional attempts with exponential backoff. The run summary reports elapsed time, retries, and cache hits for each completed step.

Run in the terminal inspector

flowyml inspect job.py:job
flowyml run job.py:job --tui --inputs '{"orders":[{"amount":12},{"amount":8}]}'

Select a step with the arrow keys to inspect its ports, artifact kinds, Python types, retries, duration, and source location. The inspector shows live user output and tracebacks. After the run, it shows artifact previews, including numeric metrics. Press R to rerun or Q to close. In Python, use job.run(inputs, tui=True). The standard-library display and redirected terminals use a streaming text view. Pass --inputs-file inputs.json for larger inputs and --no-cache to debug every step.

The checkout also includes a working training example with dataset, model, and metrics artifacts. Run flowyml run examples/light_training.py:job --tui from the repository root.

Define artifacts and step behavior

Use Dataset("training/rows", list), Metrics("training/metrics", dict), Model("training/model", MyModel), or a general Artifact("name"). Model objects and data frames stay in memory and use the libraries already installed by your application.

Step option Local behavior
name, inputs, outputs Wire functions by named artifacts. A mapping binds artifact names to function parameters.
cache Opt into reuse with True, "input_hash", or "code_hash". These choices include both code and inputs. A callable accepting the bound arguments and a context dictionary can supply a custom input fingerprint.
retry, timeout Retry exceptions with backoff and apply a time limit in seconds to each attempt. A timeout interrupts blocking calls on the POSIX main thread when the process timer is free. Other threads and platforms check Python execution and report an overrun when a native call returns.
condition A predicate can read the step arguments. A false result skips the step and consumers that require its outputs. Independent branches continue.
tags, resources, execution_group Inspect step labels and resource hints in the TUI. Resource provisioning and execution groups take effect through the SDK and its execution stack.
pipeline, register Opt into in-memory discovery with @step(pipeline="training") and Pipeline.discover("training"). Use register=False to keep that step out of discovery. Explicit pipelines can always use from_steps.

Cache a pure step

Set cache=True on a step to reuse its results across Python invocations. Entries go in .flowyml-light/cache by default. Choose a directory with job.run(inputs, cache_dir="my-cache"), or pass cache_dir=None to execute every step when debugging.

Cache keys include the function code, arguments, run context, defaults, and supported closure values. Pass changing configuration or external data as inputs. For file reads and other operations that depend on outside state, leave caching disabled. The disk cache supports JSON values including nested lists and dictionaries with string keys. For a custom model or dataset, pass encode= and decode= functions to its artifact declaration to convert between the Python object and a JSON value. Other objects pass through in memory. Jobs with caching disabled create no FlowyML files, databases, or background services.

Use the same job with the SDK

Install flowyml to add tracking, artifact storage, and the dashboard. The SDK includes the matching light runtime, so the existing python job.py entry point keeps its local behavior. To run the same graph with SDK services, use its declarations directly.

from flowyml import Pipeline
from job import job, orders

tracked_job = Pipeline.from_light(job)
result = tracked_job.run(inputs={orders: [{"amount": 12}, {"amount": 8}]}, auto_start_ui=False)
print(result.outputs["orders/total"])

From a source checkout, poetry install --only main installs the matching SDK. With pip, use python -m pip install ./runtime .. For released versions, choose framework or provider extras such as python -m pip install "flowyml[pytorch]" or python -m pip install "flowyml[tensorflow,azure]". The broad install is python -m pip install "flowyml[all]".