Step API π£
Steps are the building blocks of flowyml pipelines.
Usage
Decorator @step
Decorator to define a pipeline step with automatic context injection.
Can be used as @step or @step(inputs=...)
Every decorated function is automatically registered in a global
StepRegistry, enabling Pipeline(auto_discover=True) to build
the DAG without any manual add_step() calls.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
_func
|
Callable | None
|
Function being decorated (when used as @step) |
None
|
inputs
|
list[str] | None
|
List of input asset names |
None
|
outputs
|
list[str] | None
|
List of output asset names |
None
|
cache
|
bool | str | Callable
|
Caching strategy ("code_hash", "input_hash", callable, or False) |
'code_hash'
|
retry
|
int
|
Number of retry attempts on failure |
0
|
timeout
|
int | None
|
Maximum execution time in seconds |
None
|
resources
|
Union[dict[str, Any], ResourceRequirements, None]
|
Resource requirements (ResourceRequirements object or dict for backward compat) |
None
|
tags
|
dict[str, str] | None
|
Metadata tags for the step |
None
|
name
|
str | None
|
Optional custom name for the step |
None
|
condition
|
Callable | None
|
Optional callable that returns True if step should run |
None
|
execution_group
|
str | None
|
Optional group name for executing multiple steps together |
None
|
pipeline
|
str | None
|
Optional pipeline name for scoped auto-discovery.
When set, the step is only auto-discovered by pipelines
that match this name (or by |
None
|
register
|
bool
|
If False, the step is NOT added to the global registry.
Defaults to True. Set to False for helper/utility steps that
should only be used via explicit |
True
|
Example
@step ... def simple_step(): ... ... @step(inputs=["data/train"], outputs=["model/trained"]) ... def train_model(train_data): ... ...
Scoped to a specific pipeline
@step(pipeline="training", outputs=["model"]) ... def train(data): ... ...
With resource requirements
from flowyml.core.resources import ResourceRequirements, GPUConfig @step(resources=ResourceRequirements(cpu="4", memory="16Gi", gpu=GPUConfig(gpu_type="nvidia-v100", count=2))) ... def gpu_train(data): ... ...
Source code in flowyml/core/step.py
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 337 338 339 340 341 342 343 344 345 346 347 348 | |
Class Step
A pipeline step that can be executed with automatic context injection.
Source code in flowyml/core/step.py
Functions
__call__(*args: Any, **kwargs: Any) -> Any
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.