Skip to main content

Metaflow extension: deploy and run flows as Prefect deployments

Project description

metaflow-prefect

CI PyPI License: Apache-2.0 Python 3.10+

Deploy and run Metaflow flows as Prefect deployments.

metaflow-prefect generates a self-contained Prefect flow file from any Metaflow flow, letting you schedule, deploy, and monitor your pipelines through Prefect while keeping all your existing Metaflow code unchanged.

Install

pip install metaflow-prefect

Or from source:

git clone https://github.com/npow/metaflow-prefect.git
cd metaflow-prefect
pip install -e ".[dev]"

Quick start

python my_flow.py prefect create my_flow_prefect.py
python my_flow_prefect.py

Usage

Generate and run a Prefect flow

python my_flow.py prefect create my_flow_prefect.py
python my_flow_prefect.py

All graph shapes are supported

# Linear
class SimpleFlow(FlowSpec):
    @step
    def start(self):
        self.value = 42
        self.next(self.end)
    @step
    def end(self): pass

# Split/join (branch)
class BranchFlow(FlowSpec):
    @step
    def start(self):
        self.next(self.branch_a, self.branch_b)
    ...

# Foreach fan-out
class ForeachFlow(FlowSpec):
    @step
    def start(self):
        self.items = [1, 2, 3]
        self.next(self.process, foreach="items")
    ...

Parametrised flows

Parameters defined with metaflow.Parameter are forwarded automatically:

python param_flow.py prefect create param_flow_prefect.py
python param_flow_prefect.py --message "hello" --count 5

How it works

metaflow-prefect generates a self-contained Prefect flow file from your Metaflow flow's DAG. Each Metaflow step becomes a @task. The generated file:

  • runs each step as a subprocess via the standard metaflow step CLI
  • passes --input-paths correctly for joins and foreach splits
  • writes Metaflow artifacts to the Prefect UI as markdown artifacts with a ready-to-use retrieval snippet

Prefect UI: flow run timeline

The generated flow preserves the Metaflow DAG structure — foreach fan-outs appear as parallel task runs in the Prefect timeline:

Flow run timeline showing foreach fan-out

Prefect UI: artifact retrieval snippets

After each step completes, a Prefect artifact is posted showing the Metaflow self.* artifact names and a one-liner to fetch each value:

Artifact tab showing retrieval snippet

Development

git clone https://github.com/npow/metaflow-prefect.git
cd metaflow-prefect
pip install -e ".[dev]"
pytest -v

License

Apache 2.0

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

metaflow_prefect-0.1.0.tar.gz (212.1 kB view details)

Uploaded Source

Built Distribution

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

metaflow_prefect-0.1.0-py3-none-any.whl (22.0 kB view details)

Uploaded Python 3

File details

Details for the file metaflow_prefect-0.1.0.tar.gz.

File metadata

  • Download URL: metaflow_prefect-0.1.0.tar.gz
  • Upload date:
  • Size: 212.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for metaflow_prefect-0.1.0.tar.gz
Algorithm Hash digest
SHA256 544a60beed3dc83f8f37277d4885063d5afcc9c33aecc46c536253c060b0be14
MD5 c242248d45c064d9bf8c662d3aaacf7a
BLAKE2b-256 549e33232bf9ef94bd3f89945f31b507e885f94c02559e31f92ee2701a83516e

See more details on using hashes here.

Provenance

The following attestation bundles were made for metaflow_prefect-0.1.0.tar.gz:

Publisher: publish.yml on npow/metaflow-prefect

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

File details

Details for the file metaflow_prefect-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for metaflow_prefect-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 c92130aad3bab8a411db430e544d1df2f3b35e85203427155ca9d0acec304289
MD5 f2d2d8d00be2029b2b94f7d42b81fbf0
BLAKE2b-256 f2dcf74d7601be25c2ca423a03326958d3d750f9135aa632a33a46881b435ec7

See more details on using hashes here.

Provenance

The following attestation bundles were made for metaflow_prefect-0.1.0-py3-none-any.whl:

Publisher: publish.yml on npow/metaflow-prefect

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