-
Notifications
You must be signed in to change notification settings - Fork 6
Contexts and Results
The built-in context and result types. Contexts parameterize workflow steps; results carry their output. Both are BaseModel subclasses, so they validate and serialize like any config. See Defining Workflows for usage.
All contexts derive from ContextBase and are frozen and hashable so they can serve as cache keys.
| Type | Fields | Notes |
|---|---|---|
NullContext |
none | For steps with no runtime parameters. |
GenericContext[T] |
value: T |
Holds an arbitrary (optionally typed) value. |
DateContext |
date |
Single date. |
DatetimeContext |
dt |
Single datetime. |
DateRangeContext |
start_date, end_date
|
A date range. |
VersionedDateContext |
date, entry_time_cutoff
|
Date with an as-of cutoff. |
UniverseContext |
universe |
A named universe. |
UniverseDateContext |
universe, date
|
Universe plus date. |
ModelDateContext |
mode, date
|
Model name plus date. |
NullContext validates from None or an empty container:
NullContext.model_validate(None) # NullContext()
NullContext.model_validate([]) # NullContext()GenericContext[T] coerces its value to T:
GenericContext[str].model_validate(100) # GenericContext[str](value='100')Date-based contexts accept strings and tuples, including relative offsets (handy from the command line):
DateContext.model_validate("2025-01-01") # explicit date
DateContext.model_validate("0d") # today
DateRangeContext.model_validate(("-7d", "0d")) # last 7 days through todayAll results derive from ResultBase.
| Type | Holds |
|---|---|
GenericResult[T] |
An arbitrary (optionally typed) value. |
PandasResult |
A pandas DataFrame. |
NDArrayResult |
A NumPy array. |
ArrowResult |
A PyArrow table. |
XArrayResult |
An xarray structure. |
NarwhalsFrameResult |
A dataframe via Narwhals, for cross-library compatibility. |
Holds anything, with optional generic typing and boilerplate-reducing validation:
GenericResult(value={"x": "foo", "y": 5.0}) # any value
GenericResult[str](value="Any string") # typed
GenericResult.model_validate("Any string") # bare value validated into the wrapperDefine a schema by subclassing ResultBase:
from ccflow import ResultBase
class MyResult(ResultBase):
x: str
y: float-
Core Types —
ContextBase,ResultBase, and the surrounding machinery. - Defining Workflows — contexts and results in a running workflow.
This wiki is autogenerated. To made updates, open a PR against the original source file in docs/wiki.
Tutorials
- Overview
- First Steps
- Configuring Models
- Defining Workflows
- Building an ETL Pipeline
- Composing an ETL Application
- Building a Configurable Calculator
How-to Guides
- Overview
- Install ccflow
- Configure Complex Values
- Bind Logic to Configs
- Run Workflows from the CLI
- Cache Results
- Retry on Failure
Reference
Explanation
Developer Guide