Minimal example showing how to chain flows using @trigger_on_finish.
flow-chaining-example/
obproject.toml
flows/
preprocess/flow.py # Runs first, processes datasets in parallel
train/flow.py # Triggered when preprocess finishes
- PreprocessFlow runs with a
datasetsparameter (comma-separated paths) - Uses
foreachto process each dataset in parallel - Stores results in
self.processed_pathsartifact - TrainFlow has
@trigger_on_finish(flow="PreprocessFlow") - When PreprocessFlow completes, TrainFlow starts automatically
- TrainFlow accesses data via
current.trigger.run.data.processed_paths
# Test PreprocessFlow standalone
cd flows/preprocess
python flow.py run --datasets "path1,path2,path3"
# Test TrainFlow standalone (without trigger)
cd flows/train
python flow.py run --learning_rate 0.05 --n_estimators 200obproject-deployAfter deploy:
- Run PreprocessFlow from UI or CLI
- TrainFlow will trigger automatically when it finishes
- TrainFlow parameters (learning_rate, n_estimators) use deploy-time defaults
TrainFlow parameters are set at deploy time via the flow definition defaults. To change them per-run, either:
- Redeploy with different defaults
- Use artifacts instead of Parameters for runtime values:
- PreprocessFlow stores config in an artifact
- TrainFlow reads it via
current.trigger.run.data.config
# In TrainFlow
@trigger_on_finish(flow="PreprocessFlow")
class TrainFlow(ProjectFlow):
@step
def start(self):
if current.trigger:
# Access parent flow's artifacts
data = current.trigger.run.data.processed_paths