Pipeline Recipes API¶
The wandas.pipeline module provides portable Recipe extraction, validation,
serialization, replay, and extension declarations. For a guided executable
lesson, use the Reusable Pipeline Recipes Learning Path.
For task-oriented procedures, use the RecipePlan How-to.
段階的に学ぶ実行可能な教材は Reusable Pipeline Recipes Learning Pathへ、 具体的な作業手順はRecipePlan How-toへ進んでください。
wandas.pipeline
¶
Portable semantic Recipe plans.
Attributes¶
__all__ = ['OperationCapture', 'RecipeExecutionError', 'RecipeExtractionError', 'RecipeOperation', 'RecipeOperationDescription', 'RecipeParameterDescription', 'RecipePlan', 'RecipeRegistry', 'RecipeSerializationError', 'RecipeValidationError', 'default_recipe_registry', 'recipe_definition', 'recipe_operation']
module-attribute
¶
Classes¶
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 | |
RecipeExecutionError
¶
Bases: RuntimeError
Raised when a validated Recipe cannot be applied to runtime inputs.
Attributes:
| Name | Type | Description |
|---|---|---|
node_id |
Id of the Recipe node that failed, or |
|
operation |
Registered operation id of that node ( |
|
cause |
The exception raised by the operation, the same object as
|
Source code in wandas/pipeline/errors.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
Attributes¶
node_id = node_id
instance-attribute
¶
operation = operation
instance-attribute
¶
cause = cause
instance-attribute
¶
Functions¶
__init__(message, *, node_id=None, operation=None, cause=None)
¶
Source code in wandas/pipeline/errors.py
33 34 35 36 37 38 39 40 41 42 43 44 | |
__reduce__()
¶
Source code in wandas/pipeline/errors.py
46 47 48 49 50 51 52 | |
RecipeExtractionError
¶
Bases: ValueError
Raised when a frame lineage cannot be represented by a recipe.
Source code in wandas/pipeline/errors.py
6 7 | |
RecipeSerializationError
¶
Bases: ValueError
Raised when a Recipe payload violates the canonical schema.
Source code in wandas/pipeline/errors.py
10 11 | |
RecipeValidationError
¶
Bases: ValueError
Raised when a Recipe graph or registered operation contract is invalid.
Source code in wandas/pipeline/errors.py
14 15 | |
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.
A plan returns one Frame per :meth:apply. Besides its output, it can name
other steps, such as a shared preprocessing result or a second analysis of it;
apply(..., step=name) returns that step instead and builds only the
operations it needs.
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 |
steps
|
Iterable[tuple[str, str]]
|
|
()
|
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 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 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 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 | |
Attributes¶
inputs
instance-attribute
¶
nodes
instance-attribute
¶
output
instance-attribute
¶
steps
instance-attribute
¶
step_names
property
¶
Names accepted by apply(..., step=...), in order.
Functions¶
__init__(inputs, nodes, output, *, steps=(), registry=None)
¶
Snapshot and validate a complete Recipe graph.
Source code in wandas/pipeline/model.py
89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 | |
for_step(step, *, registry=None)
¶
Return a plan whose output is the named step, without other steps.
The new plan keeps only the operations and inputs that step needs, so it can
be saved or shared on its own. Applied to those inputs, it returns the same
Frame as plan.apply(..., step=name), which still takes every input of
this plan.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step
|
str
|
Name from :attr: |
required |
registry
|
RecipeRegistry | None
|
Registry used to validate the new plan, as in :meth: |
None
|
Returns:
| Type | Description |
|---|---|
RecipePlan
|
A validated plan with the inputs that step uses and no steps. |
Raises:
| Type | Description |
|---|---|
RecipeExecutionError
|
If |
Source code in wandas/pipeline/model.py
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 | |
from_frame(frame, *, input_names=None, steps=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
|
steps
|
Mapping[str, Any] | None
|
Other Frames to name in the plan, by name, so that
|
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, |
Examples:
>>> import wandas as wd
>>> from wandas.pipeline import RecipePlan
>>> signal = wd.generate_sin(freqs=[1000.0], duration=0.1)
>>> weighted = signal.high_pass_filter(cutoff=50).a_weighting()
>>> plan = RecipePlan.from_frame(
... weighted.welch(), steps={"weighted": weighted, "noct": weighted.noct_spectrum()}
... )
>>> plan.step_names
('weighted', 'noct')
>>> type(plan.apply(signal, step="noct")).__name__
'NOctFrame'
Source code in wandas/pipeline/model.py
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 | |
from_dict(payload, *, registry=None)
classmethod
¶
Load and validate a Recipe schema-2 or schema-3 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
185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 | |
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
210 211 212 213 214 215 216 217 218 | |
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
220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
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
237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 | |
apply(inputs, *, step=None, registry=None)
¶
Build the Recipe output, or one named step, lazily from named runtime inputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
Mapping[str, Any] | Any
|
Exact mapping from each :class: |
required |
step
|
str | None
|
Name from :attr: |
None
|
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 (or the named step) with semantic lineage, metadata, and Dask laziness preserved by its public operations. An identity plan with no nodes returns its input Frame unchanged. |
Raises:
| Type | Description |
|---|---|
RecipeExecutionError
|
If names or runtime value kinds do not match, a
plan with several inputs receives one value instead of a mapping,
|
RecipeValidationError
|
If the plan is invalid for |
Source code in wandas/pipeline/model.py
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 | |
apply_files(paths, out_dir, *, root=None, jobs=1, on_error='continue', overwrite=False, step=None, registry=None)
¶
Apply this one-input plan to many recordings and save each result as WDF.
Each recording is read with :func:wandas.read, passed to :meth:apply, and
saved with save to out_dir/<name>.wdf. Reading uses the dtype of
:func:wandas.get_default_dtype at this call, in worker processes too. The name keeps the recording's
extension (a.wav becomes a.wav.wdf), so a.wav and a.flac do not
share an output. With root, the path below root is kept, so
root/L1/a.wav becomes out_dir/L1/a.wav.wdf. Saving needs the io
extra (pip install "wandas[io]").
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
paths
|
Iterable[str | Path]
|
Local recording paths, in the order of the returned rows. |
required |
out_dir
|
str | Path
|
Folder for the outputs; created as needed. |
required |
root
|
str | Path | None
|
Folder the paths are below; keeps their relative folders in
|
None
|
jobs
|
int
|
Recordings processed at the same time, in separate processes.
Workers are started with |
1
|
on_error
|
Literal['continue', 'raise']
|
|
'continue'
|
overwrite
|
bool
|
Replace existing outputs. Without it, an existing output is that recording's failure. |
False
|
step
|
str | None
|
Name from :attr: |
None
|
registry
|
RecipeRegistry | None
|
Registry for validation and execution, as in :meth: |
None
|
Returns:
| Type | Description |
|---|---|
Any
|
A pandas |
Raises:
| Type | Description |
|---|---|
RecipeExecutionError
|
If the plan does not have exactly one input. |
RecipeExecutionError
|
If |
ValueError
|
If |
Exception
|
With |
Source code in wandas/pipeline/model.py
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 363 364 365 366 367 368 369 370 371 372 373 374 375 | |
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
|
method
|
Callable[..., Any] | None
|
Decorated method whose calls record this operation. It is used only by
:meth: |
None
|
extras
|
tuple[str, ...]
|
Optional |
()
|
Source code in wandas/pipeline/registry.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 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 349 350 351 352 353 354 | |
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
¶
method = field(default=None, repr=False)
class-attribute
instance-attribute
¶
extras = ()
class-attribute
instance-attribute
¶
Functions¶
__post_init__()
¶
Snapshot and validate the complete operation contract.
Source code in wandas/pipeline/registry.py
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 | |
accepts(bindings)
¶
Return whether bindings exactly match a declared pattern.
Source code in wandas/pipeline/registry.py
303 304 305 | |
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
307 308 309 310 311 312 313 314 315 316 317 318 | |
describe()
¶
Describe this operation's inputs, method parameters, and Frame types.
Parameters come from the decorated method signature after its Frame receiver,
so they describe the call that Recipe extraction captures. Literal
annotations also report their accepted values as choices. The receiver
comes from the imported Frame classes that expose the method, and the result
type from the method's return annotation.
Returns:
| Type | Description |
|---|---|
RecipeOperationDescription
|
An immutable description; |
Source code in wandas/pipeline/registry.py
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 | |
__init__(operation_id, version, binding_patterns, handler, validate_params=_no_param_validation, method=None, extras=())
¶
RecipeOperationDescription
dataclass
¶
Machine-readable description of one registered Recipe operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
operation_id
|
str
|
Stable identifier persisted in Recipe nodes. |
required |
version
|
int
|
Operation contract version. |
required |
method
|
str | None
|
Name of the decorated method, if known. Public calls record
operations whose method name is public; contracts kept only to replay
older Recipes use private names such as |
required |
binding_patterns
|
tuple[tuple[InputBinding, ...], ...]
|
Accepted ordered input-role and input-kind patterns. |
required |
parameters
|
tuple[RecipeParameterDescription, ...] | None
|
Parameters of that method after its Frame receiver, or |
required |
receiver
|
tuple[type[Any], ...]
|
Most general Frame classes the method is called on. Subclasses
inherit it unless they override the method with another Recipe
declaration, so use :meth: |
()
|
returns
|
type[Any] | Literal['receiver'] | None
|
Frame class of the result; |
None
|
extras
|
tuple[str, ...]
|
Optional |
()
|
Source code in wandas/pipeline/registry.py
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 | |
Attributes¶
operation_id
instance-attribute
¶
version
instance-attribute
¶
method
instance-attribute
¶
binding_patterns
instance-attribute
¶
parameters
instance-attribute
¶
receiver = ()
class-attribute
instance-attribute
¶
returns = None
class-attribute
instance-attribute
¶
extras = ()
class-attribute
instance-attribute
¶
Functions¶
applies_to(frame)
¶
Return whether calling method on frame records this operation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
frame
|
Any
|
A Frame or a Frame class. |
required |
Returns:
| Type | Description |
|---|---|
bool
|
|
bool
|
with another Recipe declaration. |
Source code in wandas/pipeline/registry.py
116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
__init__(operation_id, version, method, binding_patterns, parameters, receiver=(), returns=None, extras=())
¶
RecipeParameterDescription
dataclass
¶
Machine-readable description of one operation method parameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Parameter name accepted by the public method. |
required |
kind
|
str
|
:class: |
required |
required
|
bool
|
Whether the call must supply a value. |
required |
default
|
Any
|
Deep copy of the default Python value, or |
required |
annotation
|
str | None
|
Annotation text as written for postponed annotations, or the
:func: |
required |
choices
|
tuple[Any, ...] | None
|
Accepted values when the annotation is a |
required |
Source code in wandas/pipeline/registry.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
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
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 | |
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
373 374 375 376 377 378 379 380 381 382 383 384 385 | |
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
387 388 389 390 391 392 393 394 395 396 397 398 399 400 | |
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
402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 | |
describe()
¶
Describe every registered operation in registration order.
Use this catalog to build parameter forms, documentation, or tool schemas
from the same declarations that Recipe validation and replay use. Released
contracts kept only to replay older Recipes are included; their method
is private (one leading underscore, such as _fft_recipe_v2). Public
calls record the operations whose method is public, including operator
methods such as __add__.
Returns:
| Name | Type | Description |
|---|---|---|
One |
tuple[RecipeOperationDescription, ...]
|
class: |
Source code in wandas/pipeline/registry.py
420 421 422 423 424 425 426 427 428 429 430 431 432 433 | |
Functions¶
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
217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
recipe_operation(operation_id, *, version=1, bindings=None, binding_patterns=None, capture=None, handler=None, validate_params=None, extras=())
¶
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
|
extras
|
tuple[str, ...]
|
Optional |
()
|
Returns:
| Type | Description |
|---|---|
Callable[[Callable[P, R]], Callable[P, R]]
|
A method decorator that preserves the wrapped signature and exposes its
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 210 211 212 213 214 | |
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: |
Source code in wandas/pipeline/registry.py
436 437 438 439 440 441 442 443 444 445 446 | |
wandas.pipeline.sklearn
¶
Scikit-learn-compatible adapters for declared Wandas Frame operations.
Attributes¶
__all__ = ['BandPassFilter', 'HighPassFilter', 'LowPassFilter', 'Normalize', 'RemoveDC', 'WandasOperationTransformer']
module-attribute
¶
Classes¶
BaseEstimator
¶
Import-time placeholder used only to define unavailable adapters.
Source code in wandas/pipeline/sklearn.py
29 30 31 32 | |
TransformerMixin
¶
Import-time placeholder used only to define unavailable adapters.
Source code in wandas/pipeline/sklearn.py
34 35 36 37 | |
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 156 157 158 159 160 161 162 | |
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.
Only the given parameters change. Passing a different operation to the
generic adapter replaces its parameters with the given ones.
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 156 157 158 159 160 161 162 | |
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
165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 | |
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
175 176 177 178 179 | |
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
182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 | |
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
192 193 194 195 196 | |
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
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 | |
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
210 211 212 213 214 215 | |
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
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 | |
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
230 231 232 233 234 235 236 237 238 239 240 241 242 | |
RemoveDC
¶
Bases: WandasOperationTransformer
Stateless sklearn adapter for Frame.remove_dc.
Source code in wandas/pipeline/sklearn.py
245 246 247 248 249 250 251 252 | |