Context API 🧠
Access runtime information, parameters, and configuration within a step.
Usage
from flowyml import step, get_context
@step
def my_step():
ctx = get_context()
print(f"Running in pipeline: {ctx.pipeline_name}")
Class Context
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 |