Core API Reference
Pipeline
flowyml.core.pipeline.Pipeline(name: str, context: Context | None = None, executor: Executor | None = None, enable_cache: bool = True, enable_checkpointing: bool | None = None, enable_experiment_tracking: bool | None = None, cache_dir: str | None = None, stack: Any | None = None, project: str | None = None, project_name: str | None = None, version: str | None = None, **kwargs)
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) 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
|
**kwargs
|
Additional keyword arguments passed to the pipeline. instance is automatically created instead of a regular Pipeline. |
{}
|
Source code in flowyml/core/pipeline.py
170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 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 | |
Functions
__new__(name: str, version: str | None = None, project_name: str | None = None, project: str | None = None, **kwargs)
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
build() -> None
Build the execution DAG.
Source code in flowyml/core/pipeline.py
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
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
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) -> 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
|
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
370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 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 | |
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
Step
flowyml.core.step.Step(func: Callable, name: str | None = None, inputs: list[str] | None = None, outputs: list[str] | None = None, cache: bool | str | Callable = 'code_hash', retry: int = 0, timeout: int | None = None, resources: Union[dict[str, Any], ResourceRequirements, None] = None, tags: dict[str, str] | None = None, condition: Callable | None = None, execution_group: str | None = None)
A pipeline step that can be executed with automatic context injection.
Source code in flowyml/core/step.py
Functions
__call__(*args, **kwargs)
Execute the step function.
Source code in flowyml/core/step.py
get_cache_key(inputs: dict[str, Any] | None = None) -> str
Generate cache key based on caching strategy.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
dict[str, Any] | None
|
Input data for the step |
None
|
Returns:
| Type | Description |
|---|---|
str
|
Cache key string |
Source code in flowyml/core/step.py
get_code_hash() -> str
Compute hash of the step's source code.
Source code in flowyml/core/step.py
get_input_hash(inputs: dict[str, Any]) -> str
Generate hash of inputs for caching.
Context
flowyml.core.context.Context(**kwargs)
Pipeline context with automatic parameter injection.
Example
ctx = Context(learning_rate=0.001, epochs=10, batch_size=32, device="cuda")
Source code in flowyml/core/context.py
Functions
__getattr__(name: str) -> Any
Allow dot notation access to parameters.
Source code in flowyml/core/context.py
__getitem__(key: str) -> Any
Allow dict-style access to parameters.
Source code in flowyml/core/context.py
get(key: str, default: Any = None) -> Any
inherit(**overrides) -> Context
inject_params(func: callable) -> dict[str, Any]
Automatically inject parameters based on function signature.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
callable
|
Function to analyze and inject parameters for |
required |
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
Dictionary of parameters to inject |
Source code in flowyml/core/context.py
items() -> list[tuple]
keys() -> set[str]
to_dict() -> dict[str, Any]
update(data: dict[str, Any]) -> None
Update context with new data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
dict[str, Any]
|
Dictionary of key-value pairs to add to context |
required |
validate_for_step(step_func: callable, exclude: list[str] = None) -> list[str]
Validate that all required parameters are available.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step_func
|
callable
|
Step function to validate |
required |
exclude
|
list[str]
|
List of parameter names to exclude from validation (e.g. inputs) |
None
|
Returns:
| Type | Description |
|---|---|
list[str]
|
List of missing required parameters |