Pipeline
data_joinery.Pipeline
Connect transforms and invoke them in dependency order.
| PARAMETER | DESCRIPTION |
|---|---|
context_type
|
Optional context dataclass. Pass its class when
transforms use the
TYPE:
|
Source code in src/data_joinery/pipeline.py
add_step
Add a transform as a named step.
| PARAMETER | DESCRIPTION |
|---|---|
transform
|
Function decorated with
TYPE:
|
name
|
Step name. Defaults to the transform's function name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Step[OutputT]
|
The new step. |
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If the name is already used or cannot be inferred. |
TypeError
|
If the transform has unsupported parameters or context dependencies that the pipeline cannot supply. |
Source code in src/data_joinery/pipeline.py
connect
Connect an output to a compatible input on another step.
| PARAMETER | DESCRIPTION |
|---|---|
upstream
|
Step that produces the value.
TYPE:
|
downstream
|
Step that receives the value.
TYPE:
|
param
|
Downstream parameter name. Required when more than one input can accept the output.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
PipelineConnectionError
|
If the steps or their contracts cannot be connected. |
PipelineCycleError
|
If the connection would create a cycle. |
Source code in src/data_joinery/pipeline.py
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 | |
connect_many
Connect several upstream steps to one downstream step.
Each output must match one unambiguous downstream input.
| PARAMETER | DESCRIPTION |
|---|---|
upstream_steps
|
Nonempty sequence of steps that provide inputs.
TYPE:
|
downstream
|
Step that receives the inputs.
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ValueError
|
If |
PipelineConnectionError
|
If an output cannot be connected. |
PipelineCycleError
|
If a connection would create a cycle. |
Source code in src/data_joinery/pipeline.py
get_upstream_steps
get_steps_in_execution_order
Return all steps in an order that respects their connections.
run
run(
context: None = None,
*,
transform_overrides: Mapping[str, Transform]
| None = None,
include_side_effects: bool = True,
) -> PipelineResult
run(
context: ContextT,
*,
transform_overrides: Mapping[str, Transform]
| None = None,
include_side_effects: bool = True,
) -> PipelineResult
Invoke each step and return its recorded inputs and outputs.
| PARAMETER | DESCRIPTION |
|---|---|
context
|
Instance of the context dataclass, when the pipeline was created with one.
TYPE:
|
transform_overrides
|
Replacement transforms keyed by step name. Each replacement must have compatible input contracts and the same output contract.
TYPE:
|
include_side_effects
|
Whether to run transforms marked with
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
PipelineResult
|
A result containing an invocation record for every executed step. |
| RAISES | DESCRIPTION |
|---|---|
TypeError
|
If the context is missing or has the wrong type. |
PipelineOverrideError
|
If a replacement is invalid. |
PipelineExecutionError
|
If a required input is unconnected or a step fails. |
Source code in src/data_joinery/pipeline.py
499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 | |
visualize
Draw the pipeline and return its Matplotlib figure.
| PARAMETER | DESCRIPTION |
|---|---|
show
|
Whether to display the figure. Set to
TYPE:
|
| RAISES | DESCRIPTION |
|---|---|
ImportError
|
If the |
Source code in src/data_joinery/pipeline.py
Steps
data_joinery.Step
dataclass
Context
data_joinery.Context
Mark a transform parameter as supplied by the pipeline context.
Use with Annotated. By default, the parameter's type selects a field
of the same type on the context dataclass.
| PARAMETER | DESCRIPTION |
|---|---|
type_
|
Context field type to use instead of the parameter's type.
TYPE:
|
Source code in src/data_joinery/context.py
Pipeline results
Pipeline.run() returns a PipelineResult. Use a Step or a step name to
select the output you want. The result also acts as a mapping from step names
to non-None outputs. When include_side_effects=False, marked side-effect
steps are skipped and do not appear in the result's run records.
| Method | Use |
|---|---|
get_output |
Read a step's output. Pass the expected runtime type when using a name. |
get_input |
Read a value bound to a step's input parameter, including writers. |
get_one_input |
Read the only input of a runtime type without naming its parameter. |
get_step_invocation |
Inspect an invocation's inputs, output, and input sources. |
data_joinery.PipelineResult
Bases: Mapping[str, Any]
Record a pipeline invocation and provide access to step outputs.
Mapping access by step name includes only outputs other than None.
step_invocations includes every invoked step in dependency order.
| PARAMETER | DESCRIPTION |
|---|---|
step_invocations
|
Invocation records in dependency order.
TYPE:
|
| ATTRIBUTE | DESCRIPTION |
|---|---|
step_invocations |
Records for every invoked step, including writers.
|
Source code in src/data_joinery/pipeline_result.py
get_step_invocation
get_step_invocation(step: Step[T]) -> StepInvocation[T]
get_step_invocation(step: str) -> StepInvocation[Any]
Get a step's invocation record, including steps that return None.
| PARAMETER | DESCRIPTION |
|---|---|
step
|
A step from this pipeline or its name. A step object must be the same object that was invoked, not just have the same name.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
StepInvocation[Any]
|
The step invocation's recorded inputs and output. |
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If the step name is absent or the step was not invoked. |
Source code in src/data_joinery/pipeline_result.py
get_output
get_output(step: Step[T]) -> T
Get a step's output.
A Step keeps its declared output type. When using a step name, pass
the expected runtime type.
| PARAMETER | DESCRIPTION |
|---|---|
step
|
A step from this pipeline or its name.
TYPE:
|
value_type
|
Required runtime type when
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
Any
|
The step's output, including |
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If the step is absent. |
TypeError
|
If the type is missing for a name, supplied for a |
Source code in src/data_joinery/pipeline_result.py
get_input
Get a value bound to a step's input parameter before input coercion.
| PARAMETER | DESCRIPTION |
|---|---|
step
|
A step from this pipeline or its name.
TYPE:
|
parameter_name
|
Name of the transform parameter.
TYPE:
|
value_type
|
Required runtime type of the bound value.
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
T
|
The recorded input value. |
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If the step or parameter is absent. |
TypeError
|
If the value is not an instance of |
Source code in src/data_joinery/pipeline_result.py
get_one_input
Get the only recorded input of a runtime type before input coercion.
All bound inputs are considered, including context values and defaults.
Use get_input with a parameter name if more than one value matches.
| PARAMETER | DESCRIPTION |
|---|---|
step
|
A step from this pipeline or its name.
TYPE:
|
value_type
|
Runtime type to match with
TYPE:
|
| RETURNS | DESCRIPTION |
|---|---|
T
|
The single matching input value. |
| RAISES | DESCRIPTION |
|---|---|
KeyError
|
If the step is absent. |
LookupError
|
If zero or multiple inputs match |
Source code in src/data_joinery/pipeline_result.py
StepInvocation records the transform called for a step, its bound inputs,
and its returned output. A lazy DataFrame can defer data processing until a
later operation.
data_joinery.StepInvocation
dataclass
Record one step invocation's transform, inputs, and output.
| ATTRIBUTE | DESCRIPTION |
|---|---|
step |
Step that was invoked.
TYPE:
|
transform |
Transform used, including any replacement supplied to the run.
TYPE:
|
inputs |
Values bound to parameter names before input coercion.
TYPE:
|
output |
Validated output, including
TYPE:
|
data_joinery.BoundInput
dataclass
Record an input value and where it came from.
| ATTRIBUTE | DESCRIPTION |
|---|---|
value |
Value passed to the transform before input coercion.
TYPE:
|
source |
Upstream step, context field, or parameter default.
TYPE:
|
BoundInput.source identifies the upstream Step, a context field, or a
parameter default.
data_joinery.ContextSource
dataclass
Identify the context field that supplied an input.
| ATTRIBUTE | DESCRIPTION |
|---|---|
field |
Name of the context field.
TYPE:
|
data_joinery.DefaultSource
dataclass
Identify an input supplied by a transform parameter default.
Logging
Pipeline.run() logs invocation summaries at INFO and step details at DEBUG
through the data_joinery logger. Configure this logger in your application
to choose the level, format, and destination. A step's logged duration measures
the transform call, which may return a lazy DataFrame before its data is
processed. Logs include step names, transform names, context field names, call
durations, and return types, but not input, context, or output values.
Errors
data_joinery.PipelineExecutionError
Bases: RuntimeError
A pipeline could not run or one of its steps failed.
data_joinery.PipelineOverrideError
Bases: ValueError
A replacement transform is unknown or incompatible with its step.