Run Metaflow flows as Mage pipelines
Project description
metaflow-mage
Run any Metaflow flow as a Mage pipeline without rewriting your steps.
The problem
Mage is a modern data pipeline tool with a rich UI and flexible block model, but it has no native support for Metaflow's step graph, artifact store, or retry semantics. Teams that want Mage's notebook-style visibility must either re-implement their Metaflow flows as Mage blocks from scratch or give up Metaflow's lineage, versioning, and @retry behavior. There is no ready-made compiler that maps a Metaflow DAG to Mage blocks while keeping the full Metaflow runtime intact.
Quick start
pip install metaflow-mage
python flow.py mage create --mage-host http://localhost:6789
python flow.py mage trigger --mage-host http://localhost:6789
# Compiling HelloFlow to Mage pipeline...
# Pipeline hello_flow deployed successfully.
# Pipeline run started: http://localhost:6789/pipelines/hello_flow/runs/1
Install
pip install metaflow-mage
From source:
git clone https://github.com/npow/metaflow-mage
cd metaflow-mage
pip install -e .
Usage
Deploy and run in one step:
python flow.py mage run \
--mage-host http://localhost:6789 \
--mage-project metaflow_project
# Compiling HelloFlow to Mage pipeline...
# Pipeline hello_flow deployed successfully.
# Triggering pipeline run...
# Pipeline run started: http://localhost:6789/pipelines/hello_flow/runs/1
# Pipeline run is running...
# Pipeline run 1 completed successfully.
Deploy once, trigger many times with parameters:
python flow.py mage create --mage-host http://localhost:6789
python flow.py mage trigger --mage-host http://localhost:6789 \
--run-param message=hello --run-param n=10
Programmatic API:
from metaflow import Deployer
with Deployer("flow.py") as d:
df = d.mage().create(
mage_host="http://localhost:6789",
mage_project="metaflow_project",
)
run = df.trigger(message="hello")
print(run.status) # RUNNING / SUCCEEDED / FAILED
print(run.mage_ui) # http://localhost:6789/pipelines/hello_flow/runs/1
print(run.run.successful) # True
Delete a deployed pipeline:
python flow.py mage delete --mage-host http://localhost:6789
# Pipeline hello_flow deleted from Mage.
How it works
Each Metaflow step becomes a Mage Python block. An init block runs first to allocate the Metaflow run ID; subsequent blocks call python flow.py step <step_name> with --run-id, --task-id, and --retry-count threaded through as block outputs. Foreach steps emit a foreach_init block that enumerates items and fans out to per-item body blocks. A Mage API trigger (pipeline schedule) is created or reused on every create, so trigger works immediately without manual Mage UI setup.
Supported graph patterns: linear, branch/join, foreach. @parallel is not supported.
Configuration
| CLI option | Environment variable | Default | Description |
|---|---|---|---|
--mage-host |
MAGE_HOST |
http://localhost:6789 |
Mage server base URL |
--mage-project |
MAGE_PROJECT |
metaflow_project |
Mage project name |
--max-workers |
— | 10 |
Max concurrent block runs |
--branch |
— | — | @project branch name |
--production |
— | false |
Deploy to the production project branch |
--name |
— | derived from class name | Override the Mage pipeline UUID |
Development
git clone https://github.com/npow/metaflow-mage
cd metaflow-mage
pip install -e ".[dev]"
pytest tests/
Integration tests require a running Mage instance:
docker run -it -p 6789:6789 mageai/mageai mage start metaflow_project
pytest tests/ -m integration
License
Apache 2.0. 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 metaflow_mage-0.2.1.tar.gz.
File metadata
- Download URL: metaflow_mage-0.2.1.tar.gz
- Upload date:
- Size: 24.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
c64dc9c598ba68510a19cd93a2752ea0d7338e4c7136f082c70801b326204452
|
|
| MD5 |
eee3068b75bc492ef5cb2d4e80560d7e
|
|
| BLAKE2b-256 |
d090cfef25b66f495b11d940552150254e5c30f34c5d3ebc1b2593d01cc874c8
|
Provenance
The following attestation bundles were made for metaflow_mage-0.2.1.tar.gz:
Publisher:
publish.yml on npow/metaflow-mage
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
metaflow_mage-0.2.1.tar.gz -
Subject digest:
c64dc9c598ba68510a19cd93a2752ea0d7338e4c7136f082c70801b326204452 - Sigstore transparency entry: 1092383569
- Sigstore integration time:
-
Permalink:
npow/metaflow-mage@4db90897f814563b1521002b9963550e88cd7e1c -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/npow
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4db90897f814563b1521002b9963550e88cd7e1c -
Trigger Event:
push
-
Statement type:
File details
Details for the file metaflow_mage-0.2.1-py3-none-any.whl.
File metadata
- Download URL: metaflow_mage-0.2.1-py3-none-any.whl
- Upload date:
- Size: 24.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? Yes
- Uploaded via: twine/6.1.0 CPython/3.13.7
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
eb95cf499d02e1a35d030c50c9777cb880a6b8e2b1a955bbd44f5ff7b9dfa86d
|
|
| MD5 |
fc54088b99dbdff7322dd24d0e3081c8
|
|
| BLAKE2b-256 |
afa8a126845b54788f781f9c9d13ca83632d779e22a66712b042966200072cca
|
Provenance
The following attestation bundles were made for metaflow_mage-0.2.1-py3-none-any.whl:
Publisher:
publish.yml on npow/metaflow-mage
-
Statement:
-
Statement type:
https://in-toto.io/Statement/v1 -
Predicate type:
https://docs.pypi.org/attestations/publish/v1 -
Subject name:
metaflow_mage-0.2.1-py3-none-any.whl -
Subject digest:
eb95cf499d02e1a35d030c50c9777cb880a6b8e2b1a955bbd44f5ff7b9dfa86d - Sigstore transparency entry: 1092383570
- Sigstore integration time:
-
Permalink:
npow/metaflow-mage@4db90897f814563b1521002b9963550e88cd7e1c -
Branch / Tag:
refs/tags/v0.2.1 - Owner: https://github.com/npow
-
Access:
public
-
Token Issuer:
https://token.actions.githubusercontent.com -
Runner Environment:
github-hosted -
Publication workflow:
publish.yml@4db90897f814563b1521002b9963550e88cd7e1c -
Trigger Event:
push
-
Statement type: