π’ Pipeline
π’ Pipeline API
The central orchestrator that wires steps into a directed acyclic graph and manages execution.
π§ Build βΆοΈ Execute π Schedule
Constructor
from flowyml import Pipeline
pipeline = Pipeline(
name="my_pipeline",
context=ctx, # optional
description="...", # optional
)
| Parameter | Type | Default | Description |
|---|---|---|---|
name |
str |
required | Unique identifier for the pipeline. Used in UI, logs, and artifact paths. |
context |
Context | None |
None |
A context() object for parameter injection into steps. |
description |
str | None |
None |
Human-readable description shown in the UI dashboard. |
tags |
list[str] |
[] |
Arbitrary tags for filtering and grouping pipeline runs. |
version |
str | None |
None |
Explicit version string. Auto-incremented if omitted. |
Key Methods
| Method | Signature | Description |
|---|---|---|
add_step |
add_step(fn, **overrides) |
Register a decorated @step function. Overrides let you change cache, retries, etc. at add-time. |
run |
run(**runtime_ctx) β PipelineResult |
Execute all steps in topological order. Returns a result object with .success, .outputs, .duration. |
build |
build() β DAG |
Compile the pipeline into a DAG without executing. Useful for validation and visualization. |
schedule |
schedule(cron: str, **kwargs) |
Register a cron-style schedule for recurring execution. |
dry_run |
dry_run(**runtime_ctx) β PipelineResult |
Simulate execution β resolves the DAG and validates inputs/outputs without running step bodies. |
visualize |
visualize(format="mermaid") |
Render the pipeline DAG as Mermaid, DOT, or ASCII art. |
Usage Examples
1οΈβ£ Basic Pipeline
2οΈβ£ Pipeline with Context
Runtime Overrides
You can also pass overrides directly to run():
3οΈβ£ Sub-Pipeline Composition
4οΈβ£ Scheduled Execution
5οΈβ£ Dry Run & Validation
Dry Run Limitations
Dry runs validate the DAG topology and type compatibility but cannot catch runtime errors inside step functions.
PipelineResult
The object returned by run() and dry_run():
| Attribute | Type | Description |
|---|---|---|
success |
bool |
Whether all steps completed without error. |
outputs |
dict |
Final outputs keyed by artifact name. |
duration |
float |
Total wall-clock time in seconds. |
steps |
list[StepResult] |
Per-step results with timing and status. |
dag |
DAG |
The compiled directed acyclic graph. |
Autodoc
Main pipeline class for orchestrating ML workflows.
Example
from flowyml import Pipeline, step, context ctx = context(learning_rate=0.001, epochs=10) @step(outputs=["model/trained"]) ... def train(learning_rate: float, epochs: int): ... return train_model(learning_rate, epochs)
Option 1: Auto-discover all @step-decorated functions
pipeline = Pipeline("my_pipeline", context=ctx, auto_discover=True) result = pipeline.run()
Option 2: Concise explicit selection
pipeline = Pipeline.from_steps(train, name="my_pipeline", context=ctx)
Option 3: Batch add
pipeline = Pipeline("my_pipeline", context=ctx) pipeline.add_steps([train])
Option 4: Manual add_step (existing, still works)
pipeline = Pipeline("my_pipeline", context=ctx) pipeline.add_step(train) result = pipeline.run()
With project_name, automatically creates/attaches to project
pipeline = Pipeline("my_pipeline", context=ctx, project_name="ml_project")
With version parameter, automatically creates VersionedPipeline
pipeline = Pipeline("my_pipeline", context=ctx, version="v1.0.1", project_name="ml_project")
Initialize pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the pipeline |
required |
context
|
Context | None
|
Optional context for parameter injection |
None
|
executor
|
Executor | None
|
Optional executor (defaults to LocalExecutor) |
None
|
enable_cache
|
bool
|
Whether to enable caching |
True
|
enable_checkpointing
|
bool | None
|
Whether to enable checkpointing (defaults to config setting, True by default) |
None
|
enable_experiment_tracking
|
bool | None
|
Whether to enable automatic experiment tracking (defaults to config.auto_log_metrics, True by default) |
None
|
cache_dir
|
str | None
|
Optional directory for cache |
None
|
stack
|
Any | None
|
Stack to run on. Accepts:
- |
None
|
env
|
str | None
|
Environment name from |
None
|
project
|
str | None
|
Optional project name to attach this pipeline to (deprecated, use project_name) |
None
|
project_name
|
str | None
|
Optional project name to attach this pipeline to. If the project doesn't exist, it will be created automatically. |
None
|
version
|
str | None
|
Optional version string. If provided, a VersionedPipeline instance will be created instead of a regular Pipeline. |
None
|
auto_discover
|
bool
|
If True, automatically discover all |
False
|
**kwargs
|
Any
|
Additional keyword arguments passed to the pipeline. |
{}
|
Source code in flowyml/core/pipeline.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 | |
Functions
__new__(name: str, version: str | None = None, project_name: str | None = None, project: str | None = None, **kwargs: Any)
Create a Pipeline or VersionedPipeline instance.
If version is provided, automatically returns a VersionedPipeline instance. Otherwise, returns a regular Pipeline instance.
Source code in flowyml/core/pipeline.py
add_control_flow(control_flow: Any) -> Pipeline
Add conditional control flow to the pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
control_flow
|
Any
|
Control flow object (If, Switch, etc.) |
required |
Returns:
| Type | Description |
|---|---|
Pipeline
|
Self for chaining |
Example
Source code in flowyml/core/pipeline.py
add_step(step: Step) -> Pipeline
add_steps(steps: list[Step]) -> Pipeline
Add multiple steps to the pipeline at once.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
steps
|
list[Step]
|
List of Step instances to add |
required |
Returns:
| Type | Description |
|---|---|
Pipeline
|
Self for chaining |
Example
pipeline.add_steps([load_data, train_model, evaluate])
Source code in flowyml/core/pipeline.py
add_sub_pipeline(pipeline: Any, name: str | None = None, inputs: list[str] | None = None, outputs: list[str] | None = None, input_mapping: dict[str, str] | None = None, output_mapping: dict[str, str] | None = None, **kwargs: Any) -> Pipeline
Add a sub-pipeline as a step in this pipeline.
The sub-pipeline's steps will execute as a single unit within this pipeline's execution flow.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pipeline
|
Any
|
Pipeline to nest as a step |
required |
name
|
str | None
|
Optional step name (defaults to sub_pipeline.name) |
None
|
inputs
|
list[str] | None
|
Input asset names from this pipeline |
None
|
outputs
|
list[str] | None
|
Output asset names exposed to this pipeline |
None
|
input_mapping
|
dict[str, str] | None
|
Maps this pipeline's output names to child input names |
None
|
output_mapping
|
dict[str, str] | None
|
Maps child output names to this pipeline's input names |
None
|
**kwargs
|
Any
|
Additional SubPipelineStep configuration |
{}
|
Returns:
| Type | Description |
|---|---|
Pipeline
|
Self for chaining |
Example
preprocess = Pipeline("preprocessing") preprocess.add_step(clean).add_step(normalize)
parent = Pipeline("training") parent.add_sub_pipeline(preprocess, inputs=["raw"], outputs=["clean"]) parent.add_step(train_model)
Source code in flowyml/core/pipeline.py
build() -> None
Build the execution DAG with type validation.
Source code in flowyml/core/pipeline.py
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 | |
cache_stats() -> dict[str, Any]
check_cache() -> dict[str, Any] | None
Check if a successful run of this pipeline already exists.
Returns:
| Type | Description |
|---|---|
dict[str, Any] | None
|
Metadata of the last successful run, or None if not found. |
Source code in flowyml/core/pipeline.py
dry_run(inputs: dict[str, Any] | None = None, stack: Any | None = None, env: str | None = None, **kwargs: Any) -> PipelineResult
Validate the pipeline without executing it.
Resolves the stack, validates policies, and displays the execution plan without running any steps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
dict[str, Any] | None
|
Optional input data for the pipeline. |
None
|
stack
|
Any | None
|
Stack override (name, URI, instance, or StackDefinition). |
None
|
env
|
str | None
|
Environment name from project config. |
None
|
**kwargs
|
Any
|
Additional arguments. |
{}
|
Returns:
| Type | Description |
|---|---|
PipelineResult
|
PipelineResult with validation info but no execution. |
Source code in flowyml/core/pipeline.py
from_definition(definition: dict, context: Context | None = None) -> Pipeline
classmethod
Reconstruct pipeline from stored definition.
This creates a "ghost" pipeline that can be executed but uses the stored step structure. Actual step logic must still be available in the codebase.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
definition
|
dict
|
Pipeline definition from to_definition() |
required |
context
|
Context | None
|
Optional context for execution |
None
|
Returns:
| Type | Description |
|---|---|
Pipeline
|
Reconstructed Pipeline instance |
Source code in flowyml/core/pipeline.py
from_steps(*steps: Step, name: str, **kwargs: Any) -> Pipeline
classmethod
Create a pipeline from an explicit list of steps.
Convenience constructor that avoids repetitive add_step() calls
while still giving you full control over which steps are included.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
*steps
|
Step
|
Step instances to include |
()
|
name
|
str
|
Pipeline name (keyword-only) |
required |
**kwargs
|
Any
|
Additional arguments passed to Pipeline() |
{}
|
Returns:
| Type | Description |
|---|---|
Pipeline
|
Configured Pipeline instance |
Example
pipeline = Pipeline.from_steps( ... load_data, ... train_model, ... evaluate, ... name="training", ... enable_cache=False, ... )
Source code in flowyml/core/pipeline.py
invalidate_cache(step: str | None = None, before: str | None = None) -> None
Invalidate cache entries.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step
|
str | None
|
Invalidate cache for specific step |
None
|
before
|
str | None
|
Invalidate cache entries before date |
None
|
Source code in flowyml/core/pipeline.py
rerun(run_id: str, from_step: str | None = None, **kwargs: Any) -> PipelineResult
Re-run a pipeline from a checkpoint, resuming from where it left off.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_id
|
str
|
The run ID of the previous execution to resume from. |
required |
from_step
|
str | None
|
Optional step name to start re-execution from. If provided, all steps before this one are skipped. If not provided, resumes from the first non-completed step. |
None
|
**kwargs
|
Any
|
Additional arguments passed to Pipeline.run(). |
{}
|
Returns:
| Type | Description |
|---|---|
PipelineResult
|
PipelineResult with outputs from the resumed run. |
Examples:
>>> # Resume from last checkpoint
>>> result = pipeline.rerun(run_id="previous-run-id")
>>> # Resume from a specific step
>>> result = pipeline.rerun(run_id="previous-run-id", from_step="train_model")
Source code in flowyml/core/pipeline.py
1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 | |
run(inputs: dict[str, Any] | None = None, debug: bool = False, stack: Any | None = None, env: str | None = None, dry_run: bool = False, orchestrator: Any | None = None, resources: Any | None = None, docker_config: Any | None = None, context: dict[str, Any] | None = None, auto_start_ui: bool = True, **kwargs: Any) -> PipelineResult
Execute the pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
dict[str, Any] | None
|
Optional input data for the pipeline |
None
|
debug
|
bool
|
Enable debug mode with detailed logging |
False
|
stack
|
Any | None
|
Stack to use for this run. Accepts:
- |
None
|
env
|
str | None
|
Environment name from |
None
|
dry_run
|
bool
|
If True, resolve the stack, validate policies, and display the execution plan without actually running any steps. |
False
|
orchestrator
|
Any | None
|
Orchestrator override (takes precedence over stack orchestrator) |
None
|
resources
|
Any | None
|
Resource configuration for execution |
None
|
docker_config
|
Any | None
|
Docker configuration for containerized execution |
None
|
context
|
dict[str, Any] | None
|
Context variables override |
None
|
auto_start_ui
|
bool
|
Automatically start UI server if not running and display URL |
True
|
**kwargs
|
Any
|
Additional arguments passed to the orchestrator |
{}
|
Note
The orchestrator is determined in this priority order:
1. Explicit orchestrator parameter (if provided)
2. Stack's orchestrator (if stack is set/active)
3. Default LocalOrchestrator
When using a stack (e.g., GCPStack), the stack's orchestrator is automatically used unless explicitly overridden. This is the recommended approach for production deployments.
Returns:
| Type | Description |
|---|---|
PipelineResult
|
PipelineResult with outputs and execution info |
Source code in flowyml/core/pipeline.py
670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 | |
schedule(schedule_type: str, value: str | int, **kwargs) -> Any
Schedule this pipeline to run automatically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
schedule_type
|
str
|
Type of schedule ('cron', 'interval', 'daily', 'hourly') |
required |
value
|
str | int
|
Schedule value (cron expression, seconds, 'HH:MM', or minute) |
required |
**kwargs
|
Additional arguments for scheduler |
{}
|
Returns:
| Type | Description |
|---|---|
Any
|
Schedule object |
Source code in flowyml/core/pipeline.py
to_definition() -> dict
Serialize pipeline to definition for storage and reconstruction.
Source code in flowyml/core/pipeline.py
π What's Next?
π£ Step API
Decorator options, caching, retries, resource requirements, and input/output contracts.
π Context API
Parameter injection, environment-specific configs, and runtime overrides.
π¦ Assets API
Model, Dataset, and Metrics β first-class artifacts with lineage tracking.