Skip to main content
Loss of provenance

A previous release had provenance metadata, but this release does not. View details.

Rivlet

English | 简体中文

Rivlet is a Python library for composing and running task graphs, with a Rust execution core. Write your tasks as Python functions, connect them explicitly, and reuse whole workflows as subgraphs.

Use it for build pipelines, automation, data processing, or validation workflows that need clear dependencies and controlled concurrency. It runs inside your application; it is not a distributed workflow service.

What you can do

  • Compose steps and subgraphs: use >> for ordering and | for independent branches, without flattening reusable subgraphs.
  • Connect readiness ports: let a consumer prepare early and wait only where it actually needs a provider's output, not for the provider's entire workflow.
  • Make data flow explicit: bind step results to action and condition arguments through result edges; order-only dependencies need no result passing.
  • Apply conditions where they belong: prune optional work before execution, skip a step based on runtime results, or condition only a dependency.
  • Control execution: run synchronous or asynchronous Python tasks with explicit concurrency limits. Runtime-created subgraphs share the same action budget.
  • Inspect what happened: render graphs, query results, and subscribe to typed execution events. A failed step blocks dependent work while independent branches continue; the overall run still reports failure.

Install

Requires Python 3.13 or later:

pip install rivlet

Prebuilt wheels are available for CPython 3.13–3.15 on Linux x86_64 (glibc 2.28+) and macOS arm64 (macOS 11+). These installations need no Rust toolchain. Other platforms require a source build; see distribution support.

Compose steps and reusable subgraphs

from rivlet import Graph, GraphExecution, Step, ThreadGraphRunOptions


def checks() -> Graph:
    validate = Step(lambda: print("validate"), label="validate")
    test = Step(lambda: print("test"), label="test")
    return (validate | test).graph(label="checks")


prepare = Step(lambda: print("prepare"), label="prepare")
finish = Step(lambda: print("finish"), label="finish")

graph = (prepare >> checks() >> finish).graph(label="example")
GraphExecution(graph=graph).run(ThreadGraphRunOptions(workers=2))

After prepare, the checks subgraph can run validate and test concurrently. finish waits for both to succeed; their print order is not guaranteed.

checks() returns an ordinary Graph, ready to place in other workflows. Nesting it preserves its boundary and internal dependencies. >> waits for the whole left-hand step or subgraph; | adds no dependency between its branches. Actual concurrency comes from the run options, not from | alone.

Declarations and runs are separate: Graph describes the workflow; GraphExecution(graph) owns one run. Create a new execution to run the declaration again. You can also declare the same wiring without the DSL; see the core model.

Connect subgraphs through input and output ports

Sometimes a downstream workflow needs only one intermediate result, not the completion of an entire upstream subgraph. A capability names that readiness contract. Its output identifies the step that makes it ready; its input identifies where the consumer starts needing it.

This complete example connects two otherwise independent subgraphs:

from rivlet import (
    Capability,
    CapabilityBinding,
    CapabilityInterface,
    Graph,
    GraphExecution,
    Step,
    ThreadGraphRunOptions,
)

data_ready = Capability("validated-data")

fetch = Step(lambda: print("fetch data"), label="fetch")
validate = Step(lambda: print("validate data"), label="validate")
archive = Step(lambda: print("archive data"), label="archive")
producer_graph = (fetch >> validate >> archive).graph(
    label="producer",
    capabilities=CapabilityInterface(outputs={data_ready: validate}),
)

prepare = Step(lambda: print("prepare consumer"), label="prepare")
process = Step(lambda: print("process data"), label="process")
report = Step(lambda: print("report results"), label="report")
consumer_graph = (prepare >> process >> report).graph(
    label="consumer",
    capabilities=CapabilityInterface(inputs={data_ready: process}),
)

producer = producer_graph.step()
consumer = consumer_graph.step()
graph = Graph(
    label="pipeline",
    steps=(producer, consumer),
    edges=(
        CapabilityBinding(source=producer, target=consumer, capability=data_ready),
    ),
)
GraphExecution(graph).run(ThreadGraphRunOptions(workers=3))
producer: fetch → validate [output] → archive
                     │ validated-data
                     ▼
consumer: prepare → process [input] → report

The consumer can prepare immediately. Once validation succeeds, process can run without waiting for archive, provided its own preparation has also completed. The overall execution still waits for both subgraphs to finish.

Matching port names do not create dependencies: CapabilityBinding explicitly connects this producer and consumer. Ports synchronize readiness; they do not transfer Python return values or inspect external data. Use result edges for argument passing, and publish an output only when later steps will no longer invalidate what the consumer reads.

This is different from producer_graph >> consumer_graph, which waits for the entire producer before starting any consumer step. For selecting among providers, multiple inputs, and failure behavior, see capability ports.

Forward an interface when wrapping a subgraph

Using producer_graph from the previous example:

setup = Step(lambda: print("set up producer"), label="setup")
wrapped = (setup >> producer_graph).graph(
    label="wrapped producer",
    capabilities=producer_graph,
)

capabilities=producer_graph explicitly exposes the child's input and output ports on the wrapper. Omit it and the wrapper exposes no ports. You can forward only one direction or declare a new interface with CapabilityInterface.

Use conditions

What you want API When the condition is false
Exclude optional work before execution StaticConditions.when(...) Remove the node and its incident edges during compilation
Decide whether a task runs Step(condition=runtime_condition(...)) Skip its action; a subgraph is not entered
Decide whether a task waits for another ConditionalPrerequisite(...) Remove only that waiting requirement, not either task

Static conditions: choose work before execution

from rivlet import (
    GraphExecution,
    StaticCondition,
    StaticConditions,
    Step,
    ThreadGraphRunOptions,
)

extra_checks = StaticCondition(payload=False, description="extra checks enabled")
static = StaticConditions(evaluator=lambda condition: condition.payload is True)

prepare = Step(lambda: print("prepare static workflow"), label="prepare")
verify = Step(lambda: print("verify"), label="verify")
extra = Step(lambda: print("extra checks"), label="extra")
finish = Step(lambda: print("finish static workflow"), label="finish")

graph = (
    prepare >> (verify | static.when(extra_checks, extra)) >> finish
).graph(label="static conditions")
GraphExecution(graph).run(ThreadGraphRunOptions(workers=2))

With payload=False, compilation removes extra; change it to True to include it alongside verify. The application defines the payload and its evaluator; Rivlet does not embed its own feature or platform rules.

Static pruning does not reconnect a removed node's predecessors and successors. Here the always-present prepare → verify → finish path preserves the required ordering. Static conditions also do not defer Python construction of a child graph.

Static selection: retain candidates, select exactly one

from rivlet import Case, GraphExecution, Step, static

platform = "android"
version = 3
prepare = Step(lambda: print("prepare"), label="prepare")
modern = Step(lambda: print("modern Android"), label="modern")
legacy = Step(lambda: print("legacy Android"), label="legacy")
linux = Step(lambda: print("Linux"), label="linux")
finish = Step(lambda: print("finish"), label="finish")

graph = (
    prepare
    >> static.select(
        cases=(
            Case(platform == "android" and version >= 3, modern),
            Case(platform == "android" and version < 3, legacy),
            Case(platform == "linux", linux),
        ),
    )
    >> finish
).graph(label="static selection")
GraphExecution(graph).run()

Each Case(condition, component) contains one complete boolean condition and a Step or Graph. Declaration rendering retains every case; compilation requires exactly one true condition and produces prepare → modern → finish. Zero or multiple active cases are errors, not first-match precedence. static is the module namespace and requires no evaluator. Python computes the booleans at construction; compilation checks the selection. See static selection for subgraphs, boundaries, and direct declarations.

Runtime conditions: decide from a step result

from rivlet import Graph, GraphExecution, Option, Step, runtime_condition


def should_process(result: Option[object]) -> bool:
    return result.unwrap() is True


probe = Step(lambda: False, label="has work")
has_work = runtime_condition(when=should_process)
process = Step(
    lambda: print("process work"), label="process", condition=has_work
)
done = Step(lambda: print("workflow finished"), label="done")

graph = Graph.from_wiring(
    (
        probe.wire(),
        process.wire(inputs={has_work: (probe,)}),
        done.wire(after=(process,)),
    ),
    label="runtime conditions",
)
GraphExecution(graph).run()

inputs declares the result dependency and passes the result to the predicate as an Option; there is no second after=(probe,) to maintain. Because the probe returns False, process is skipped and done still runs. Return True to run process. A skipped action produces no result; an action returning None produces Some(None). If a source may be skipped, inspect is_some() or is_none() before unwrapping. A predicate error blocks the affected task; it is not treated as false.

For a subgraph, use the same runtime condition on child_graph.step(condition=...).

Conditional edges: decide whether to wait

from rivlet import (
    ConditionalPrerequisite,
    Graph,
    GraphExecution,
    Step,
    ThreadGraphRunOptions,
    runtime_condition,
)

decision = Step(lambda: False, label="wait for checks")
checks = Step(lambda: print("run checks"), label="checks")
publish = Step(lambda: print("publish"), label="publish")
wait_for_checks = runtime_condition(when=lambda result: result.unwrap() is True)

graph = Graph.from_wiring(
    (
        decision.wire(),
        checks.wire(),
        publish.wire(
            after=(ConditionalPrerequisite(checks, condition=wait_for_checks),),
            inputs={wait_for_checks: (decision,)},
        ),
    ),
    label="conditional dependency",
)
GraphExecution(graph).run(ThreadGraphRunOptions(workers=2))

publish waits for decision. If it returns True, publish also waits for checks; if it returns False, checks still runs, but publishing need not wait for it. Both tasks remain part of the overall run. To skip publishing itself, declare it with Step(..., condition=...) instead. Static edge conditions are available through static.edge(source, target, condition=...).

Export structure without running tasks

import json
from rivlet import Graph, GraphExecution, Step, export_graph

graph = (Step(lambda: None, label="prepare") >> Step(lambda: None, label="finish")).graph()
execution = GraphExecution(graph)
declaration = export_graph(graph)
compilation = execution.compile()
compiled = export_graph(compilation)
json.dumps({"declaration": declaration, "compiled": compiled})
execution.run()  # reuses the same compilation

The versioned JSON document preserves mounted IDs, subgraph boundaries, typed edges, conditions, and capability ports. Declaration inspection evaluates no host code; compiled export reads existing decisions without recompiling. Runtime events and results stay separate. See structural export for the schema, historical snapshots, and static/dynamic scope limits.

Explore more

For contributors: local development and checks, architecture, and releasing.

License

This project is licensed under the MIT License.

Metadata

Release files for rivlet 0.3.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Loss of provenance

These files do not have provenance metadata, despite files in a prior release including this data.

We recommend further investigation before installing these files. View details.

Source distribution (sdist)

Source distribution for rivlet 0.3.0
File Size Uploaded Provenance Actions
rivlet-0.3.0.tar.gz 505.1 kB Without provenance Details for rivlet-0.3.0.tar.gz

Built distributions (wheels)

Table of built distributions (wheels) for rivlet 0.3.0
File Actions
rivlet-0.3.0-cp315-cp315-win_amd64.whl CPython 3.15 CPython 3.15 Windows x86-64 Details for rivlet-0.3.0-cp315-cp315-win_amd64.whl
rivlet-0.3.0-cp315-cp315-macosx_11_0_arm64.whl CPython 3.15 CPython 3.15 macOS 11.0+ ARM64 Details for rivlet-0.3.0-cp315-cp315-macosx_11_0_arm64.whl
rivlet-0.3.0-cp314-cp314-win_amd64.whl CPython 3.14 CPython 3.14 Windows x86-64 Details for rivlet-0.3.0-cp314-cp314-win_amd64.whl
rivlet-0.3.0-cp314-cp314-macosx_11_0_arm64.whl CPython 3.14 CPython 3.14 macOS 11.0+ ARM64 Details for rivlet-0.3.0-cp314-cp314-macosx_11_0_arm64.whl
rivlet-0.3.0-cp313-cp313-win_amd64.whl CPython 3.13 CPython 3.13 Windows x86-64 Details for rivlet-0.3.0-cp313-cp313-win_amd64.whl
rivlet-0.3.0-cp313-cp313-macosx_11_0_arm64.whl CPython 3.13 CPython 3.13 macOS 11.0+ ARM64 Details for rivlet-0.3.0-cp313-cp313-macosx_11_0_arm64.whl

Total release size: 4.0 MB

Release files / rivlet-0.3.0.tar.gz

Loss of provenance

This file belongs to a release without provenance metadata, despite a prior release including this data.

We recommend further investigation before installing this file. View details.

Download URL rivlet-0.3.0.tar.gz
Size 505.1 kB
Tags Source
SHA-256 checksum
How to use checksums
18b9afcf85cd5b3a3ab24ddc429267bd2f62f847d05da3611e649785c4fa07e6
BLAKE2b-256 checksum
How to use checksums
0f1a076da48f806c2e27bf73538065e8186de93907627e0cc1a3df10c19457a5
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / rivlet-0.3.0-cp315-cp315-win_amd64.whl

Loss of provenance

This file belongs to a release without provenance metadata, despite a prior release including this data.

We recommend further investigation before installing this file. View details.

Download URL rivlet-0.3.0-cp315-cp315-win_amd64.whl
Size 532.7 kB
Tags CPython 3.15 Windows x86-64
SHA-256 checksum
How to use checksums
c8d31c414482be4e8619474070d031286fb3094591643970ec73e66747905f1b
BLAKE2b-256 checksum
How to use checksums
8f3bcb180c461f4264ce98fc6f63523a6eab46dee4118d1fba0def9e75896061
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / rivlet-0.3.0-cp315-cp315-macosx_11_0_arm64.whl

Loss of provenance

This file belongs to a release without provenance metadata, despite a prior release including this data.

We recommend further investigation before installing this file. View details.

Download URL rivlet-0.3.0-cp315-cp315-macosx_11_0_arm64.whl
Size 647.8 kB
Tags CPython 3.15 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
6e344b07435bb524184dd5acdd5ce8052c9036062536b9c4b9e94313c0f2cdfc
BLAKE2b-256 checksum
How to use checksums
d8c973708c7fc826ad6800d2769f5393f94a6da1213259a5785a0c9efbdd2671
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / rivlet-0.3.0-cp314-cp314-win_amd64.whl

Loss of provenance

This file belongs to a release without provenance metadata, despite a prior release including this data.

We recommend further investigation before installing this file. View details.

Download URL rivlet-0.3.0-cp314-cp314-win_amd64.whl
Size 532.3 kB
Tags CPython 3.14 Windows x86-64
SHA-256 checksum
How to use checksums
7d27c26ceb8655dc50731d6b698b329f97e5432592f18153e340862bb3b0a2b4
BLAKE2b-256 checksum
How to use checksums
cf88a9403f74a45a75452d2290ae268c13cb39c8bb2a8da2d77201e59d82cd17
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / rivlet-0.3.0-cp314-cp314-macosx_11_0_arm64.whl

Loss of provenance

This file belongs to a release without provenance metadata, despite a prior release including this data.

We recommend further investigation before installing this file. View details.

Download URL rivlet-0.3.0-cp314-cp314-macosx_11_0_arm64.whl
Size 647.6 kB
Tags CPython 3.14 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
47e2f588beb5442fed229b888e1ba67166742d656c5c1ee65b526ca1975e39c5
BLAKE2b-256 checksum
How to use checksums
dce0e8ce7ddd93e46f05650382f0c1686e7029ca2e97b61bb3e9404b2d250be3
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / rivlet-0.3.0-cp313-cp313-win_amd64.whl

Loss of provenance

This file belongs to a release without provenance metadata, despite a prior release including this data.

We recommend further investigation before installing this file. View details.

Download URL rivlet-0.3.0-cp313-cp313-win_amd64.whl
Size 532.9 kB
Tags CPython 3.13 Windows x86-64
SHA-256 checksum
How to use checksums
b4db7309259bb81cab26dbf70c1cd3051aa11d4bf6341d5fe368a3518ff45ec5
BLAKE2b-256 checksum
How to use checksums
d2b626e27aaceb99b1a8a7c353208bdde2aee31bf0d2bf66a46ac92418b95c20
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Release files / rivlet-0.3.0-cp313-cp313-macosx_11_0_arm64.whl

Loss of provenance

This file belongs to a release without provenance metadata, despite a prior release including this data.

We recommend further investigation before installing this file. View details.

Download URL rivlet-0.3.0-cp313-cp313-macosx_11_0_arm64.whl
Size 646.9 kB
Tags CPython 3.13 macOS 11.0+ ARM64
SHA-256 checksum
How to use checksums
d775eccbf8bc7962ec1acb1e1109fbc11894aed878b88a144240135f3b7e2ccc
BLAKE2b-256 checksum
How to use checksums
8a9e6bdc2b77f012a1832036c7ec7e510c22df9851ad57b7d4b25fd4286d1f82
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.13.5

Security for rivlet 0.3.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

Loss of provenance

A previous release of these files had provenance metadata, but this release does not.

While this could reflect a routine change by the project maintainers, it may also indicate that the release files have been compromised.

Release comparison

  • Removed 0.2.0.post1 7 files With provenance
  • Added 0.3.0 7 files Without provenance

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page