Metaflow

2.19.21.1 · active · verified Thu Apr 16

Metaflow is a human-centric framework for building and managing real-life data science projects, from prototyping to production. It enables data scientists and ML engineers to rapidly develop, deploy, and operate ML workflows. The `ob-metaflow` distribution is a specific PyPI package that provides the core Metaflow library. Its current version is 2.19.21.1, and it follows the frequent release cadence of the main Metaflow project.

Common errors

Warnings

Install

Imports

Quickstart

This quickstart defines a simple Metaflow `FlowSpec` with three steps: `start`, `process_data`, and `end`. It prints messages and passes data between steps. Note that Metaflow flows are typically executed via the Metaflow CLI (e.g., `python your_flow_file.py run`) to leverage its full capabilities like artifact tracking, resumption, and distributed execution, rather than just running the Python script directly.

from metaflow import FlowSpec, step, card
import os

class MyFirstMetaflowFlow(FlowSpec):
    """
    A simple Metaflow flow demonstrating basic steps.
    """
    @step
    def start(self):
        self.message = "Hello Metaflow!"
        print(f"Starting flow with message: {self.message}")
        self.next(self.process_data)

    @step
    def process_data(self):
        self.data = [len(self.message), 42]
        print(f"Processing data: {self.data}")
        self.next(self.end)

    @step
    def end(self):
        print(f"Flow finished. Final data: {self.data}")

if __name__ == '__main__':
    # To run: python your_flow_file.py run
    # For this quickstart, we just instantiate it.
    # Metaflow typically expects execution via its CLI for full features.
    flow = MyFirstMetaflowFlow()
    # Running via the CLI: python this_file.py run

view raw JSON →