FlowSpec Base Class
All Metaflow flows inherit from theFlowSpec base class:
Flow Properties
TheFlowSpec class provides several key properties:
name
The name of your flow, derived from the class name:script_name
The filename containing your flow:The
script_name property is a legacy function. Use the current singleton for modern workflows.Flow Graph
Metaflow automatically constructs a flow graph from your step definitions. The graph is accessible via:- Maps all steps and their transitions
- Validates the DAG structure
- Identifies step types (linear, split, join, foreach)
- Powers the Metaflow CLI and UI
Flow Lifecycle
Flow Graph Structure
Metaflow supports several graph patterns:Linear Flow
Fan-out (Static Split)
Fan-in (Join)
Foreach (Dynamic Split)
Flow Context
Within a flow, you have access to:- self: The current flow instance
- self.index: Current foreach index (if in a foreach)
- self.input: Current foreach value (if in a foreach)
- inputs: Parent step outputs (in join steps)
Best Practices
Flows cannot be serialized. If you try to assign
self or inputs to an artifact, you’ll get an error. Instead, extract specific attributes you need.Related
- Steps - Learn about step functions
- Decorators - Enhance steps with decorators
- Parameters - Pass arguments to flows
