Package a Python Computation Graph
A Python-authored computation graph packages and deploys exactly like a Python
workflow: a package.toml plus a module tree under workflow/. The server loads
it through the same path as a Rust-authored graph. This how-to packages the
market_maker graph end to end. (For the workflow analog, see
Packaging Python Workflows.)
Prerequisites
Section titled “Prerequisites”- A Python computation graph (see Python CG Decorator Surface).
cloacinactlinstalled, and a running server to upload to.
Step 1: Lay out the package
Section titled “Step 1: Lay out the package”market-maker/├── package.toml└── workflow/ └── market_maker/ ├── __init__.py └── graph.py # @cloaca.reactor + ComputationGraphBuilder + @cloaca.nodeThe module tree must live under workflow/. graph.py holds the reactor,
the accumulators, the ComputationGraphBuilder, and the @cloaca.node functions
(see the Topology Dict Schema).
Step 2: Write package.toml
Section titled “Step 2: Write package.toml”A computation-graph package sets graph_name (this is what marks it a CG rather
than a workflow) and entry_module (the dotted path, relative to workflow/,
the loader imports):
[package]name = "market-maker"version = "0.1.0"interface = "cloacina-workflow-plugin"interface_version = 1extension = "cloacina"
[metadata]language = "python"graph_name = "market_maker"entry_module = "market_maker.graph"reaction_mode = "when_any" # or "when_all"input_strategy = "latest" # or "sequential"requires_python = ">=3.10"Both are optional (defaults: reaction_mode = "when_any", input_strategy = "latest"):
reaction_modeshould match themode=on your@cloaca.reactor(when_any= fire when any accumulator has new data;when_all= wait for all).input_strategycontrols how queued boundaries are consumed:latestcollapses to the newest boundary (one execution on the most recent data);sequentialruns the graph once per boundary in order.
Importing entry_module runs your decorators, which register the graph.
Step 3: Validate and pack
Section titled “Step 3: Validate and pack”cloacinactl package validate market-makercloacinactl package pack market-maker --out market-maker-0.1.0.cloacinavalidate checks the layout and the closed [metadata] schema; pack writes
the .cloacina archive. (No maturin/compile step — a Python package ships
source.)
Step 4: Upload and verify
Section titled “Step 4: Upload and verify”cloacinactl --tenant my_tenant package upload market-maker-0.1.0.cloacinacloacinactl --tenant my_tenant graph listOnce the server loads it, the graph appears in graph list and its health is
queryable via cloacinactl graph status market_maker.
See also
Section titled “See also”- Topology Dict Schema
- Packaging Python Workflows — the same packaging model for workflows.
- Package Format — the
.cloacinaarchive structure.