Pipeline API ποΈ
The Pipeline class is the main entry point for defining and running workflows in flowyml.
Usage
Class Pipeline
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
|
Optional stack instance to run on |
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 | |
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
473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 | |
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
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:
Source code in flowyml/core/pipeline.py
run(inputs: dict[str, Any] | None = None, debug: bool = False, stack: Any | None = None, 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 override (uses self.stack or active stack if not provided) |
None
|
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
553 554 555 556 557 558 559 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 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 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 | |
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.