Overview
Metaflow provides two mechanisms for making flows configurable:- Parameters: Runtime values passed via command line or API
- Configs: Deploy-time configuration files for structured settings
Parameters
Parameters are runtime inputs to your flow, specified when running the flow.Basic Parameters
Parameter Types
From the source code:Separator for Lists
Split string parameters into lists:Deploy-Time Parameters
Parameters can be functions evaluated at deploy time:Real-World Example
From the playlist tutorial:Config: Structured Configuration
Configs are special parameters for complex, structured configuration:config.json:
Config Properties
Configs are immutable ConfigValue objects:Config vs Parameter
| Feature | Parameter | Config |
|---|---|---|
| When set | Runtime | Deploy time |
| Mutability | Immutable | Immutable |
| Structure | Single value | Nested dictionary |
| Use in decorators | Limited | Yes |
| CLI syntax | --param value | --config file.json |
Using Configs in Decorators
Configs can be used in decorator arguments:config.json:
Config Expressions
For complex expressions, useconfig_expr():
Custom Parsers
Configs default to JSON but support custom parsers:Default Values
Configs support both default files and default values:Parameter Validation
Reserved Names
Some parameter names are reserved:Required Parameters
Parameter Name Normalization
Parameters are case-insensitive:Accessing Parameters in Code
As Artifacts
Parameters become artifacts accessible throughout the flow:Parameter Immutability
Parameters cannot be modified:Environment Variables
Parameters can be set via environment variables:Best Practices
1. Meaningful Defaults
Provide sensible defaults for optional parameters:2. Clear Help Text
3. Use Configs for Complex Settings
4. Validate Parameters Early
5. Document Parameter Choices
Common Patterns
Debug Mode
Environment Selection
Feature Flags
Data Source Selection
Next Steps
FlowSpec
Learn more about the FlowSpec base class
Data Management
Best practices for managing data artifacts
Error Handling
Handle errors and failures gracefully
Branching
Create parallel execution paths
