Decorators API π
Decorators are the primary API surface of FlowyML. By annotating a plain Python function with @step, @trace_llm, or similar decorators, you opt the function into the framework's execution, caching, lineage-tracking, and monitoring capabilities β all without modifying the function body. This section documents every decorator, its parameters, and its runtime behaviour.
@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
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 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | |
@trace_llm
Decorator to trace LLM calls.
Source code in flowyml/monitoring/llm.py
See Also
- Step API β full reference for the
Stepclass produced by the@stepdecorator - Steps Guide β conceptual guide on writing and composing steps