Pipeline Recipes API¶
wandas.pipeline provides the portable Recipe surface. Most users need only
RecipePlan; registry and decorator APIs are for extensions with stable public Frame
methods.
Start with the Recipe tutorial for a complete workflow or the Recipe how-to for concise task recipes.
RecipePlan¶
Create plans with RecipePlan.from_frame(), RecipePlan.from_dict(), or
RecipePlan.load(). Persist a standalone strict JSON artifact with
RecipePlan.save(). The direct
graph constructor is internal and is not a supported compatibility surface.
wandas.pipeline.RecipePlan
dataclass
¶
Portable, validated graph of public Wandas Frame operations.
A plan stores operation intent and named input slots, never Frame samples or a Dask task graph. Constructing, serializing, loading, and applying a plan therefore remain lazy; computation occurs only when the returned Frame is computed.
User workflows create plans with :meth:from_frame or :meth:from_dict, then use
:meth:apply and :meth:to_dict. The direct inputs/nodes/output
constructor is an internal graph-assembly interface, not a public compatibility
surface.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
Iterable[RecipeInput]
|
Named Frame or NumPy/Dask array inputs used by the graph. |
required |
nodes
|
Iterable[RecipeNode]
|
Topologically ordered Recipe operations. |
required |
output
|
str
|
Identifier of the Frame input or node returned by the plan. |
required |
registry
|
RecipeRegistry | None
|
Immutable operation registry used to validate the graph. Uses the built-in registry when omitted. |
None
|
Raises:
| Type | Description |
|---|---|
RecipeValidationError
|
If the graph or an operation contract is invalid. |
Source code in wandas/pipeline/model.py
53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 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 | |
Attributes¶
inputs
instance-attribute
¶
nodes
instance-attribute
¶
output
instance-attribute
¶
Functions¶
__init__(inputs, nodes, output, *, registry=None)
¶
Snapshot and validate a complete Recipe graph.
Source code in wandas/pipeline/model.py
81 82 83 84 85 86 87 88 89 90 91 92 93 | |
from_frame(frame, *, input_names=None, registry=None)
classmethod
¶
Extract a Recipe from a Frame's semantic lineage.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame
|
Any
|
Result Frame produced through public Recipe-capable operations. |
required |
input_names
|
tuple[str, ...] | None
|
Optional names assigned to discovered runtime inputs in
deterministic traversal order. When omitted, names are generated as
|
None
|
registry
|
RecipeRegistry | None
|
Registry used to resolve every captured operation. Uses the built-in registry when omitted. |
None
|
Returns:
| Type | Description |
|---|---|
RecipePlan
|
A validated plan whose output reproduces |
Raises:
| Type | Description |
|---|---|
RecipeExtractionError
|
If the value is not a Frame, an operation is not
portable or registered, or |
Source code in wandas/pipeline/model.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | |
from_dict(payload, *, registry=None)
classmethod
¶
Load and validate a Recipe schema-2 mapping.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
payload
|
Mapping[str, Any]
|
Mapping produced by :meth: |
required |
registry
|
RecipeRegistry | None
|
Registry used to validate operation identifiers and versions. |
None
|
Returns:
| Type | Description |
|---|---|
RecipePlan
|
A new immutable Recipe plan. |
Raises:
| Type | Description |
|---|---|
RecipeSerializationError
|
If the payload violates the schema or graph contract. |
Source code in wandas/pipeline/model.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 | |
to_dict()
¶
Return the deterministic JSON-compatible Recipe schema.
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A fresh mapping using schema |
Source code in wandas/pipeline/model.py
149 150 151 152 153 154 155 156 157 | |
save(path, *, overwrite=False)
¶
Save this plan as a standalone .recipe.json artifact.
The artifact contains operation intent and named inputs only. Frame samples, WDF data, and Dask graphs remain outside the Recipe persistence boundary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Target path. |
required |
overwrite
|
bool
|
Replace an existing artifact when true. |
False
|
Returns:
| Type | Description |
|---|---|
Path
|
The normalized artifact path written to disk. |
Source code in wandas/pipeline/model.py
159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 | |
load(path, *, registry=None)
classmethod
¶
Load and validate a standalone .recipe.json artifact.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
path
|
str | Path
|
Artifact path. |
required |
registry
|
RecipeRegistry | None
|
Registry used to validate operation identifiers and versions. |
None
|
Returns:
| Type | Description |
|---|---|
RecipePlan
|
A validated immutable Recipe plan. |
Raises:
| Type | Description |
|---|---|
FileNotFoundError
|
If the normalized artifact path does not exist. |
RecipeSerializationError
|
If decoding, schema validation, or graph validation fails. |
Source code in wandas/pipeline/model.py
176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 | |
apply(inputs, *, registry=None)
¶
Build the Recipe output lazily from named runtime inputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
Mapping[str, Any]
|
Exact mapping from each :class: |
required |
registry
|
RecipeRegistry | None
|
Registry used for validation and operation execution. Supply the same extension registry used during extraction and loading. |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
The output Frame with semantic lineage, metadata, and Dask laziness |
Any
|
preserved by its public operations. An identity plan with no nodes returns |
Any
|
its input Frame unchanged. |
Raises:
| Type | Description |
|---|---|
RecipeExecutionError
|
If names or runtime value kinds do not match, an operation fails, or an operation violates the Frame lineage contract. |
RecipeValidationError
|
If the plan is invalid for |
Source code in wandas/pipeline/model.py
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 | |
Errors¶
wandas.pipeline.RecipeExtractionError
¶
Bases: ValueError
Raised when a frame lineage cannot be represented by a recipe.
Source code in wandas/pipeline/errors.py
4 5 | |
wandas.pipeline.RecipeSerializationError
¶
Bases: ValueError
Raised when a Recipe payload violates the canonical schema.
Source code in wandas/pipeline/errors.py
8 9 | |
wandas.pipeline.RecipeValidationError
¶
Bases: ValueError
Raised when a Recipe graph or registered operation contract is invalid.
Source code in wandas/pipeline/errors.py
12 13 | |
wandas.pipeline.RecipeExecutionError
¶
Bases: RuntimeError
Raised when a validated Recipe cannot be applied to runtime inputs.
Source code in wandas/pipeline/errors.py
16 17 | |
Extension declarations¶
wandas.pipeline.recipe_operation(operation_id, *, version=1, bindings=None, binding_patterns=None, capture=None, handler=None, validate_params=None)
¶
Declare and capture one portable public Frame operation.
The returned decorator attaches a :class:RecipeOperation declaration to the
wrapped method and records one authoritative semantic lineage node per public call.
The default unary replay handler delegates to the wrapped public method. An
extension that supplies an explicit handler is responsible for keeping that handler
behaviorally equivalent to its public method.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation_id
|
str
|
Stable serialized identifier for the public operation. |
required |
version
|
int
|
Positive contract version for |
1
|
bindings
|
tuple[InputBinding, ...] | None
|
Ordered input contract for one invocation shape. Defaults to one
Frame binding named |
None
|
binding_patterns
|
tuple[tuple[InputBinding, ...], ...] | None
|
Alternative accepted input contracts for operations that
support more than one shape, such as Frame-or-array operands. Mutually
exclusive with |
None
|
capture
|
CaptureResolver | None
|
Callback that derives actual bindings, lineage parents, and portable parameters from a public call. Required for non-unary contracts. |
None
|
handler
|
RecipeHandler | None
|
Replay callback receiving ordered runtime inputs and an immutable parameter mapping. Required for non-unary contracts; unary operations use the wrapped method by default. |
None
|
validate_params
|
ParamValidator | None
|
Optional validator called on immutable decoded parameters during complete-plan validation. |
None
|
Returns:
| Type | Description |
|---|---|
Callable[[Callable[P, R]], Callable[P, R]]
|
A method decorator that preserves the wrapped signature and exposes its |
Callable[[Callable[P, R]], Callable[P, R]]
|
Recipe declaration through :func: |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
ValueError
|
If declarations conflict, binding patterns are empty, a required capture or handler is missing, or the method signature is unsupported. |
Source code in wandas/pipeline/decorators.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 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 | |
wandas.pipeline.recipe_definition(value)
¶
Return the operation declaration attached by :func:recipe_operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
object
|
Decorated public method or an equivalent statically inspected member. |
required |
Returns:
| Type | Description |
|---|---|
RecipeOperation
|
The immutable operation contract ready to add to a :class: |
Raises:
| Type | Description |
|---|---|
TypeError
|
If |
Source code in wandas/pipeline/decorators.py
212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 | |
wandas.pipeline.OperationCapture
dataclass
¶
Semantic inputs and parameters captured at a public method boundary.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
bindings
|
tuple[InputBinding, ...]
|
Ordered input roles and runtime kinds for this invocation. |
required |
parents
|
tuple[LineageNode | None, ...]
|
Lineage parent for each binding; array bindings use |
required |
params
|
Mapping[str, Any]
|
Call intent to snapshot into semantic lineage. Nonportable top-level values become display-only markers and make Recipe extraction fail. |
required |
recipe_error
|
str | None
|
Optional explanation that makes later Recipe extraction fail atomically while retaining display history for the public call. |
None
|
Source code in wandas/pipeline/decorators.py
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 | |
wandas.pipeline.RecipeOperation
dataclass
¶
Complete versioned contract for one portable public operation.
Operation values use identity-based equality so independently declared handlers are never treated as interchangeable merely because their metadata matches.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation_id
|
str
|
Stable identifier persisted in Recipe nodes. |
required |
version
|
int
|
Positive version of this operation contract. |
required |
binding_patterns
|
tuple[tuple[InputBinding, ...], ...]
|
Accepted ordered input-role and input-kind patterns. Runtime kind signatures must be unique. |
required |
handler
|
RecipeHandler
|
Replay callback receiving ordered runtime inputs and immutable params. |
required |
validate_params
|
ParamValidator
|
Callback that rejects invalid decoded parameters. |
_no_param_validation
|
Source code in wandas/pipeline/registry.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
Attributes¶
operation_id
instance-attribute
¶
version
instance-attribute
¶
binding_patterns
instance-attribute
¶
handler = field(repr=False)
class-attribute
instance-attribute
¶
validate_params = field(default=_no_param_validation, repr=False)
class-attribute
instance-attribute
¶
Functions¶
__post_init__()
¶
Snapshot and validate the complete operation contract.
Source code in wandas/pipeline/registry.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
accepts(bindings)
¶
Return whether bindings exactly match a declared pattern.
Source code in wandas/pipeline/registry.py
103 104 105 | |
invoke(inputs, params)
¶
Invoke the replay handler after complete-plan validation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
tuple[Any, ...]
|
Ordered runtime values matching one declared binding pattern. |
required |
params
|
FrozenMap
|
Canonical parameters already accepted by |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The handler's Frame result. |
Source code in wandas/pipeline/registry.py
107 108 109 110 111 112 113 114 115 116 117 118 | |
__init__(operation_id, version, binding_patterns, handler, validate_params=_no_param_validation)
¶
wandas.pipeline.RecipeRegistry
dataclass
¶
Immutable collection of versioned Recipe operation contracts.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operations
|
Iterable[RecipeOperation]
|
Initial operation definitions. Each |
()
|
Raises:
| Type | Description |
|---|---|
TypeError
|
If an entry is not a :class: |
ValueError
|
If two entries use the same identifier and version. |
Source code in wandas/pipeline/registry.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
Attributes¶
operations = ()
class-attribute
instance-attribute
¶
Functions¶
__init__(operations=())
¶
Snapshot definitions and build a read-only lookup index.
Source code in wandas/pipeline/registry.py
137 138 139 140 141 142 143 144 145 146 147 148 149 | |
with_operation(operation)
¶
Return a new registry containing one additional operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
RecipeOperation
|
Definition to append without changing this registry. |
required |
Returns:
| Type | Description |
|---|---|
RecipeRegistry
|
A new immutable registry. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the operation identifier and version already exist. |
TypeError
|
If |
Source code in wandas/pipeline/registry.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 | |
require(operation_id, version)
¶
Return an exact registered operation definition.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation_id
|
str
|
Stable operation identifier. |
required |
version
|
int
|
Required contract version. |
required |
Returns:
| Type | Description |
|---|---|
RecipeOperation
|
The matching operation definition. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If no exact identifier-version pair is registered. |
Source code in wandas/pipeline/registry.py
166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 | |
wandas.pipeline.default_recipe_registry()
cached
¶
Return the cached immutable registry of built-in Frame operations.
Returns:
| Type | Description |
|---|---|
RecipeRegistry
|
A process-wide immutable registry. Use :meth: |
RecipeRegistry
|
to derive an extension registry without mutating the built-in value. |
Source code in wandas/pipeline/registry.py
185 186 187 188 189 190 191 192 193 194 195 | |
Scikit-learn adapters¶
These stateless estimators call declared public Frame methods and preserve sklearn's clone and pipeline conventions.
wandas.pipeline.sklearn.WandasOperationTransformer
¶
Bases: TransformerMixin, BaseEstimator
Stateless sklearn transformer for a declared Wandas Frame operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation
|
str
|
Public Frame method name decorated with |
required |
**params
|
Any
|
Keyword arguments forwarded to that method by :meth: |
{}
|
Raises:
| Type | Description |
|---|---|
ImportError
|
If scikit-learn is not installed. |
Source code in wandas/pipeline/sklearn.py
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
Attributes¶
operation = operation
instance-attribute
¶
Functions¶
__init__(operation, **params)
¶
Store operation identity and estimator parameters without fitting state.
Source code in wandas/pipeline/sklearn.py
59 60 61 62 63 64 | |
fit(X, y=None)
¶
Return this stateless transformer without inspecting training data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
Any
|
Accepted for sklearn estimator compatibility and left untouched. |
required |
y
|
Any
|
Optional target accepted for sklearn estimator compatibility. |
None
|
Returns:
| Type | Description |
|---|---|
WandasOperationTransformer
|
This already-fitted stateless transformer. |
Source code in wandas/pipeline/sklearn.py
72 73 74 75 76 77 78 79 80 81 82 | |
__sklearn_is_fitted__()
¶
Report that this stateless transformer requires no fitted attributes.
Source code in wandas/pipeline/sklearn.py
84 85 86 | |
transform(X)
¶
Apply the declared public operation to a Wandas Frame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
X
|
Any
|
Frame exposing the configured declared public operation. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The Frame result returned by that operation. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in wandas/pipeline/sklearn.py
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 | |
get_params(deep=True)
¶
Return estimator parameters using sklearn's cloning contract.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deep
|
bool
|
Accepted for sklearn compatibility; this adapter has no nested estimators. |
True
|
Returns:
| Type | Description |
|---|---|
dict[str, Any]
|
A fresh parameter dictionary. |
Source code in wandas/pipeline/sklearn.py
111 112 113 114 115 116 117 118 119 120 121 122 123 124 | |
set_params(**params)
¶
Update estimator parameters in place using sklearn conventions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**params
|
Any
|
Parameter values to update. |
{}
|
Returns:
| Type | Description |
|---|---|
WandasOperationTransformer
|
This transformer. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If a generic |
ValueError
|
If a parameter is invalid for the current adapter configuration. |
Source code in wandas/pipeline/sklearn.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 | |
wandas.pipeline.sklearn.HighPassFilter
¶
Bases: WandasOperationTransformer
Stateless sklearn adapter for Frame.high_pass_filter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cutoff
|
float
|
High-pass cutoff frequency in hertz. |
required |
order
|
int
|
Filter order. |
4
|
Source code in wandas/pipeline/sklearn.py
158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 | |
Attributes¶
cutoff = cutoff
instance-attribute
¶
order = order
instance-attribute
¶
Functions¶
__init__(cutoff, order=4)
¶
Initialize high-pass filter parameters.
Source code in wandas/pipeline/sklearn.py
168 169 170 171 172 | |
wandas.pipeline.sklearn.LowPassFilter
¶
Bases: WandasOperationTransformer
Stateless sklearn adapter for Frame.low_pass_filter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
cutoff
|
float
|
Low-pass cutoff frequency in hertz. |
required |
order
|
int
|
Filter order. |
4
|
Source code in wandas/pipeline/sklearn.py
175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | |
Attributes¶
cutoff = cutoff
instance-attribute
¶
order = order
instance-attribute
¶
Functions¶
__init__(cutoff, order=4)
¶
Initialize low-pass filter parameters.
Source code in wandas/pipeline/sklearn.py
185 186 187 188 189 | |
wandas.pipeline.sklearn.BandPassFilter
¶
Bases: WandasOperationTransformer
Stateless sklearn adapter for Frame.band_pass_filter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
low_cutoff
|
float
|
Lower cutoff frequency in hertz. |
required |
high_cutoff
|
float
|
Upper cutoff frequency in hertz. |
required |
order
|
int
|
Filter order. |
4
|
Source code in wandas/pipeline/sklearn.py
192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |
Attributes¶
low_cutoff = low_cutoff
instance-attribute
¶
high_cutoff = high_cutoff
instance-attribute
¶
order = order
instance-attribute
¶
Functions¶
__init__(low_cutoff, high_cutoff, order=4)
¶
Initialize band-pass filter parameters.
Source code in wandas/pipeline/sklearn.py
203 204 205 206 207 208 | |
wandas.pipeline.sklearn.Normalize
¶
Bases: WandasOperationTransformer
Stateless sklearn adapter for Frame.normalize.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
norm
|
float | None
|
Norm used for amplitude normalization. |
inf
|
axis
|
int | None
|
Axis normalized independently, or |
-1
|
threshold
|
float | None
|
Optional magnitude threshold treated as zero. |
None
|
fill
|
bool | None
|
Optional zero-norm fill behavior forwarded to the Frame operation. |
None
|
Source code in wandas/pipeline/sklearn.py
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 | |
Attributes¶
norm = norm
instance-attribute
¶
axis = axis
instance-attribute
¶
threshold = threshold
instance-attribute
¶
fill = fill
instance-attribute
¶
Functions¶
__init__(norm=np.inf, axis=-1, threshold=None, fill=None)
¶
Initialize normalization parameters.
Source code in wandas/pipeline/sklearn.py
223 224 225 226 227 228 229 230 231 232 233 234 235 | |
wandas.pipeline.sklearn.RemoveDC
¶
Bases: WandasOperationTransformer
Stateless sklearn adapter for Frame.remove_dc.
Source code in wandas/pipeline/sklearn.py
238 239 240 241 242 243 244 245 | |