Skip to main content

"Pipeline orchestration and operator CLI for Money Ex Machina — Prefect-backed flows, text-first ergonomics, and optional asset metadata."

Project description

mxm-pipeline

Version License Python Checked with pyright CI

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-pipeline owns 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:

  • FlowSpec
  • TaskSpec

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:

  • ruff
  • black
  • isort
  • pyright (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


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

mxm_pipeline-0.1.1.tar.gz (19.1 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

mxm_pipeline-0.1.1-py3-none-any.whl (24.5 kB view details)

Uploaded Python 3

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

Hashes for mxm_pipeline-0.1.1.tar.gz
Algorithm Hash digest
SHA256 90effc26de1e05d7fe320d30c53efd74d75e9a84024f3309c490169010dc8536
MD5 0fa12208acd9d43f564a310793efaa73
BLAKE2b-256 521d44eba26358875b37f0b56db660ff1f5ddf5ce032a02b90e7226c27ae00c3

See more details on using hashes here.

Provenance

The following attestation bundles were made for mxm_pipeline-0.1.1.tar.gz:

Publisher: release.yml on moneyexmachina/mxm-pipeline

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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

Hashes for mxm_pipeline-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 d5c7955338ea288035c15fb739241ab5ed6dbb9a54ed929f05eb6dfc493a62e2
MD5 2f5228569cf471c011a8ad8843d0e94f
BLAKE2b-256 a37116be1ca78ac22c67080da26c8785d863996d59beb6f0574404bd149b9ec3

See more details on using hashes here.

Provenance

The following attestation bundles were made for mxm_pipeline-0.1.1-py3-none-any.whl:

Publisher: release.yml on moneyexmachina/mxm-pipeline

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page