"Pipeline orchestration and operator CLI for Money Ex Machina — Prefect-backed flows, text-first ergonomics, and optional asset metadata."
Project description
mxm-pipeline
Declarative Prefect orchestration substrate with semantic execution events for Money Ex Machina.
mxm-pipeline provides a small orchestration layer for defining workflows as declarative task graphs and compiling them into executable Prefect flows.
The package intentionally does not implement its own orchestration engine.
Instead:
- Prefect owns operational execution truth
mxm-pipelineowns semantic execution meaning
The package provides:
- declarative flow specifications (
FlowSpec,TaskSpec) - deterministic Prefect flow compilation
- runtime execution-context injection
- semantic event emission and persistence
- CLI utilities for local execution and inspection
The current implementation targets local Prefect execution.
Purpose
mxm-pipeline exists to provide a stable orchestration substrate for MXM systems while keeping orchestration semantics intentionally small and explicit.
The package separates:
- operational execution state
- semantic/domain meaning
- logs and execution traces
Operational orchestration concerns are delegated to Prefect:
- flow runs
- task runs
- retries
- scheduling
- orchestration lifecycle
mxm-pipeline augments execution with:
- semantic event emission
- execution context injection
- deterministic flow compilation
- lightweight runtime helpers
The design goal is compositional, inspectable workflows without building a parallel orchestration framework.
Installation
pip install mxm-pipeline
To enable orchestration support:
pip install "mxm-pipeline[orchestration]"
Requires Python 3.13+.
Usage
Define tasks
from mxm.pipeline.spec import FlowSpec, TaskSpec
def produce_number(x: int) -> int:
return x * 2
def consume_number(
value: int,
*,
execution_context,
) -> int:
execution_context.emit_semantic_event(
event_type="value_consumed",
domain_key="demo.value",
payload={"value": value},
)
return value + 1
Define a flow
flow = FlowSpec(
name="demo",
tasks=[
TaskSpec(
name="produce",
fn=produce_number,
params={"x": 4},
),
TaskSpec(
name="consume",
fn=consume_number,
upstream=["produce"],
),
],
)
Compile and execute
from mxm.pipeline.api import compile_flow, execute_flow
from mxm.pipeline.reporting.layout import ReportingLayout
layout = ReportingLayout.from_root("./runtime")
compiled = compile_flow(
flow,
reporting_layout=layout,
)
result = execute_flow(compiled)
print(result)
CLI usage
List flows:
mxm-pipeline list
Show dependency graph:
mxm-pipeline graph demo
Run a flow:
mxm-pipeline run demo --param x=4
Runtime Model
The runtime model is intentionally small:
FlowSpec
↓
Prefect FlowRun
↓
Prefect TaskRun
↓
MXM ExecutionContext
↓
SemanticEvent(s)
ExecutionContext is injected into tasks that accept an execution_context argument.
The context provides:
- Prefect runtime identifiers
- logging access
- semantic event emission
- lightweight execution metadata
The context does not own orchestration state.
Semantic Events
Semantic events are append-only domain records emitted during execution.
Examples:
- dataset materialized
- partial coverage obtained
- degraded upstream state
- stale reference data detected
- validation failure
- no-op execution
Principle:
operational records say what happened
semantic events say what it meant
logs say how it unfolded
Semantic events are persisted independently from Prefect operational state.
Architecture
mxm-pipeline is structured into four primary layers.
1. Specification Layer
Declarative workflow definitions:
FlowSpecTaskSpec
Tasks define executable units and dependencies without embedding orchestration logic.
2. API Layer
Public orchestration interface:
compile_flow()execute_flow()
This layer hides backend implementation details from callers.
3. Adapter Layer
Backend-specific compilation and execution.
Current implementation:
adapters/prefect_adapter.py
The adapter:
- validates task graphs
- compiles Prefect flows/tasks
- injects execution contexts
- manages semantic event sinks
- executes flows under MXM runtime defaults
4. Reporting Layer
Semantic event persistence and reporting utilities.
Current implementation includes:
- semantic event models
- append-only semantic event storage
- SQLite-backed persistence
- reporting layouts and sinks
The reporting layer intentionally does not duplicate Prefect orchestration state.
Design Principles
-
Prefect owns operational truth
MXM does not reimplement orchestration state management. -
Semantic meaning is explicit
Domain outcomes are emitted as structured semantic events. -
Declarative flow construction
Workflows are defined as task graphs rather than imperative orchestration code. -
Minimal runtime abstraction
The package avoids building a general-purpose orchestration framework. -
Strict typing
Fully Pyright-clean and PEP 561 compliant. -
Deterministic execution structure
Task ordering and graph validation are stable and explicit.
Development
poetry install
make check
All code is required to pass:
ruffblackisortpyright(strict)pytest
ADRs
Architecture decisions are documented under:
docs/adr/
Current ADR sequence:
- ADR 0001 — Optional asset layer from day 1
- ADR 0002 — Task-centric execution model with semantic events
- ADR 0003 — Prefect owns operational truth
License
MIT License. See LICENSE.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file mxm_pipeline-0.1.1.tar.gz.
File metadata
- Download URL: mxm_pipeline-0.1.1.tar.gz
- Upload date:
- Size: 19.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
90effc26de1e05d7fe320d30c53efd74d75e9a84024f3309c490169010dc8536
|
|
| MD5 |
0fa12208acd9d43f564a310793efaa73
|
|
| BLAKE2b-256 |
521d44eba26358875b37f0b56db660ff1f5ddf5ce032a02b90e7226c27ae00c3
|
Provenance
The following attestation bundles were made for mxm_pipeline-0.1.1.tar.gz:
Publisher:
release.yml on moneyexmachina/mxm-pipeline
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mxm_pipeline-0.1.1.tar.gz -
Subject digest:
90effc26de1e05d7fe320d30c53efd74d75e9a84024f3309c490169010dc8536 - Sigstore transparency entry: 1629923032
- Sigstore integration time:
-
Permalink:
moneyexmachina/mxm-pipeline@a1bfdac190d91a7d9fc427f6c8a75faaabc53c2c -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/moneyexmachina
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a1bfdac190d91a7d9fc427f6c8a75faaabc53c2c -
Trigger Event:
push
-
Statement type:
File details
Details for the file mxm_pipeline-0.1.1-py3-none-any.whl.
File metadata
- Download URL: mxm_pipeline-0.1.1-py3-none-any.whl
- Upload date:
- Size: 24.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d5c7955338ea288035c15fb739241ab5ed6dbb9a54ed929f05eb6dfc493a62e2
|
|
| MD5 |
2f5228569cf471c011a8ad8843d0e94f
|
|
| BLAKE2b-256 |
a37116be1ca78ac22c67080da26c8785d863996d59beb6f0574404bd149b9ec3
|
Provenance
The following attestation bundles were made for mxm_pipeline-0.1.1-py3-none-any.whl:
Publisher:
release.yml on moneyexmachina/mxm-pipeline
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
mxm_pipeline-0.1.1-py3-none-any.whl -
Subject digest:
d5c7955338ea288035c15fb739241ab5ed6dbb9a54ed929f05eb6dfc493a62e2 - Sigstore transparency entry: 1629923057
- Sigstore integration time:
-
Permalink:
moneyexmachina/mxm-pipeline@a1bfdac190d91a7d9fc427f6c8a75faaabc53c2c -
Branch / Tag:
refs/tags/v0.1.1 - Owner: https://github.com/moneyexmachina
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
release.yml@a1bfdac190d91a7d9fc427f6c8a75faaabc53c2c -
Trigger Event:
push
-
Statement type: