Execution
zenml.execution
Step and pipeline execution.
Modules
pipeline
Pipeline execution.
Modules
dynamic
Dynamic pipeline execution.
outputs
Dynamic pipeline execution outputs.
ArtifactFuture(wrapped: Future[StepRunOutputs], invocation_id: str, index: int)
Bases: _BaseStepRunFuture
Future for a step run output artifact.
Initialize the future.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wrapped
|
Future[StepRunOutputs]
|
The wrapped future object. |
required |
invocation_id
|
str
|
The invocation ID of the step run. |
required |
index
|
int
|
The index of the output artifact. |
required |
Source code in src/zenml/execution/pipeline/dynamic/outputs.py
73 74 75 76 77 78 79 80 81 82 83 84 | |
load(disable_cache: bool = False) -> Any
Load the step run output artifact data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
disable_cache
|
bool
|
Whether to disable the artifact cache. |
False
|
Returns:
| Type | Description |
|---|---|
Any
|
The step run output artifact data. |
Source code in src/zenml/execution/pipeline/dynamic/outputs.py
106 107 108 109 110 111 112 113 114 115 | |
result() -> OutputArtifact
Get the output artifact this future represents.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the future returned an invalid output. |
Returns:
| Type | Description |
|---|---|
OutputArtifact
|
The output artifact. |
Source code in src/zenml/execution/pipeline/dynamic/outputs.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 | |
MapResultsFuture(futures: List[StepRunOutputsFuture])
Future that represents the results of a step.map/product(...) call.
Initialize the map results future.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
futures
|
List[StepRunOutputsFuture]
|
The step run futures. |
required |
Source code in src/zenml/execution/pipeline/dynamic/outputs.py
276 277 278 279 280 281 282 | |
result() -> List[StepRunOutputs]
Get the step run outputs this future represents.
Returns:
| Type | Description |
|---|---|
List[StepRunOutputs]
|
The step run outputs. |
Source code in src/zenml/execution/pipeline/dynamic/outputs.py
284 285 286 287 288 289 290 | |
unpack() -> Tuple[List[ArtifactFuture], ...]
Unpack the map results future.
This method can be used to get lists of artifact futures that represent the outputs of all the step runs that are part of this map result.
Example:
from zenml import pipeline, step
@step
def create_int_list() -> list[int]:
return [1, 2]
@step
def do_something(a: int) -> Tuple[int, int]:
return a * 2, a * 3
@pipeline
def map_pipeline():
int_list = create_int_list()
results = do_something.map(a=int_list)
double, triple = results.unpack()
# [future.load() for future in double] will return [2, 4]
# [future.load() for future in triple] will return [3, 6]
Returns:
| Type | Description |
|---|---|
Tuple[List[ArtifactFuture], ...]
|
The unpacked map results. |
Source code in src/zenml/execution/pipeline/dynamic/outputs.py
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 | |
OutputArtifact
StepRunOutputsFuture(wrapped: Future[StepRunOutputs], invocation_id: str, output_keys: List[str])
Bases: _BaseStepRunFuture
Future for a step run output.
Initialize the future.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
wrapped
|
Future[StepRunOutputs]
|
The wrapped future object. |
required |
invocation_id
|
str
|
The invocation ID of the step run. |
required |
output_keys
|
List[str]
|
The output keys of the step run. |
required |
Source code in src/zenml/execution/pipeline/dynamic/outputs.py
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
artifacts() -> StepRunOutputs
Get the step run output artifacts.
Returns:
| Type | Description |
|---|---|
StepRunOutputs
|
The step run output artifacts. |
Source code in src/zenml/execution/pipeline/dynamic/outputs.py
161 162 163 164 165 166 167 | |
get_artifact(key: str) -> ArtifactFuture
Get an artifact future by key.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key
|
str
|
The key of the artifact future. |
required |
Raises:
| Type | Description |
|---|---|
KeyError
|
If no artifact for the given name exists. |
Returns:
| Type | Description |
|---|---|
ArtifactFuture
|
The artifact future. |
Source code in src/zenml/execution/pipeline/dynamic/outputs.py
137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 | |
load(disable_cache: bool = False) -> Any
Get the step run output artifact data.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
disable_cache
|
bool
|
Whether to disable the artifact cache. |
False
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the step run output is invalid. |
Returns:
| Type | Description |
|---|---|
Any
|
The step run output artifact data. |
Source code in src/zenml/execution/pipeline/dynamic/outputs.py
177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 | |
result() -> StepRunOutputs
Get the step run outputs this future represents.
Returns:
| Type | Description |
|---|---|
StepRunOutputs
|
The step run outputs. |
Source code in src/zenml/execution/pipeline/dynamic/outputs.py
169 170 171 172 173 174 175 | |
run_context
Dynamic pipeline run context.
DynamicPipelineRunContext(pipeline: DynamicPipeline, snapshot: PipelineSnapshotResponse, run: PipelineRunResponse, runner: DynamicPipelineRunner)
Bases: BaseContext
Dynamic pipeline run context.
Initialize the dynamic pipeline run context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pipeline
|
DynamicPipeline
|
The dynamic pipeline that is being executed. |
required |
snapshot
|
PipelineSnapshotResponse
|
The snapshot of the pipeline. |
required |
run
|
PipelineRunResponse
|
The pipeline run. |
required |
runner
|
DynamicPipelineRunner
|
The dynamic pipeline runner. |
required |
Source code in src/zenml/execution/pipeline/dynamic/run_context.py
34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
pipeline: DynamicPipeline
property
The pipeline that is being executed.
Returns:
| Type | Description |
|---|---|
DynamicPipeline
|
The pipeline that is being executed. |
run: PipelineRunResponse
property
runner: DynamicPipelineRunner
property
The runner executing the pipeline.
Returns:
| Type | Description |
|---|---|
DynamicPipelineRunner
|
The runner executing the pipeline. |
snapshot: PipelineSnapshotResponse
property
The snapshot of the pipeline.
Returns:
| Type | Description |
|---|---|
PipelineSnapshotResponse
|
The snapshot of the pipeline. |
runner
Dynamic pipeline runner.
DynamicPipelineRunner(snapshot: PipelineSnapshotResponse, run: Optional[PipelineRunResponse])
Dynamic pipeline runner.
Initialize the dynamic pipeline runner.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
PipelineSnapshotResponse
|
The snapshot of the pipeline. |
required |
run
|
Optional[PipelineRunResponse]
|
The pipeline run. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the snapshot has no associated stack. |
Source code in src/zenml/execution/pipeline/dynamic/runner.py
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 | |
pipeline: DynamicPipeline
property
The pipeline that the runner is executing.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the pipeline can't be loaded. |
Returns:
| Type | Description |
|---|---|
DynamicPipeline
|
The pipeline that the runner is executing. |
await_all_step_run_futures() -> None
Await all step run output futures.
Source code in src/zenml/execution/pipeline/dynamic/runner.py
328 329 330 331 332 | |
launch_step(step: BaseStep, id: Optional[str], args: Tuple[Any, ...], kwargs: Dict[str, Any], after: Union[StepRunFuture, Sequence[StepRunFuture], None] = None, concurrent: bool = False) -> Union[StepRunOutputs, StepRunOutputsFuture]
launch_step(
step: BaseStep,
id: Optional[str],
args: Tuple[Any, ...],
kwargs: Dict[str, Any],
after: Union[
StepRunFuture, Sequence[StepRunFuture], None
] = None,
concurrent: Literal[False] = False,
) -> StepRunOutputs
launch_step(
step: BaseStep,
id: Optional[str],
args: Tuple[Any, ...],
kwargs: Dict[str, Any],
after: Union[
StepRunFuture, Sequence[StepRunFuture], None
] = None,
concurrent: Literal[True] = True,
) -> StepRunOutputsFuture
Launch a step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step
|
BaseStep
|
The step to launch. |
required |
id
|
Optional[str]
|
The invocation ID of the step. |
required |
args
|
Tuple[Any, ...]
|
The arguments for the step function. |
required |
kwargs
|
Dict[str, Any]
|
The keyword arguments for the step function. |
required |
after
|
Union[StepRunFuture, Sequence[StepRunFuture], None]
|
The step run output futures to wait for. |
None
|
concurrent
|
bool
|
Whether to launch the step concurrently. |
False
|
Returns:
| Type | Description |
|---|---|
Union[StepRunOutputs, StepRunOutputsFuture]
|
The step run outputs or a future for the step run outputs. |
Source code in src/zenml/execution/pipeline/dynamic/runner.py
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 | |
map(step: BaseStep, args: Tuple[Any, ...], kwargs: Dict[str, Any], after: Union[StepRunFuture, Sequence[StepRunFuture], None] = None, product: bool = False) -> MapResultsFuture
Map over step inputs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step
|
BaseStep
|
The step to run. |
required |
args
|
Tuple[Any, ...]
|
The arguments for the step function. |
required |
kwargs
|
Dict[str, Any]
|
The keyword arguments for the step function. |
required |
after
|
Union[StepRunFuture, Sequence[StepRunFuture], None]
|
The step run output futures to wait for before executing the steps. |
None
|
product
|
bool
|
Whether to produce a cartesian product of the mapped inputs. |
False
|
Returns:
| Type | Description |
|---|---|
MapResultsFuture
|
A future that represents the map results. |
Source code in src/zenml/execution/pipeline/dynamic/runner.py
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 | |
run_pipeline() -> None
Run the pipeline.
Source code in src/zenml/execution/pipeline/dynamic/runner.py
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 | |
await_step_inputs(inputs: Dict[str, Any]) -> Dict[str, Any]
Await the inputs of a step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
Dict[str, Any]
|
The inputs of the step. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If a step run future with multiple output artifacts is passed as an input. |
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
The awaited inputs. |
Source code in src/zenml/execution/pipeline/dynamic/runner.py
716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 | |
compile_dynamic_step_invocation(snapshot: PipelineSnapshotResponse, pipeline: DynamicPipeline, step: BaseStep, inputs: Dict[str, Any], after: Union[StepRunFuture, ArtifactFuture, Sequence[Union[StepRunFuture, ArtifactFuture]], None] = None, id: Optional[str] = None) -> Step
Compile a dynamic step invocation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
PipelineSnapshotResponse
|
The snapshot. |
required |
pipeline
|
DynamicPipeline
|
The dynamic pipeline. |
required |
step
|
BaseStep
|
The step to compile. |
required |
id
|
Optional[str]
|
Custom invocation ID. |
None
|
inputs
|
Dict[str, Any]
|
The inputs for the step function. |
required |
after
|
Union[StepRunFuture, ArtifactFuture, Sequence[Union[StepRunFuture, ArtifactFuture]], None]
|
The step run output futures to wait for. |
None
|
Returns:
| Type | Description |
|---|---|
Step
|
The compiled step. |
Source code in src/zenml/execution/pipeline/dynamic/runner.py
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 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 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 | |
convert_to_keyword_arguments(func: Callable[..., Any], args: Tuple[Any, ...], kwargs: Dict[str, Any], apply_defaults: bool = False) -> Dict[str, Any]
Convert function arguments to keyword arguments.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
func
|
Callable[..., Any]
|
The function to convert the arguments to keyword arguments for. |
required |
args
|
Tuple[Any, ...]
|
The arguments to convert to keyword arguments. |
required |
kwargs
|
Dict[str, Any]
|
The keyword arguments to convert to keyword arguments. |
required |
apply_defaults
|
bool
|
Whether to apply the function default values. |
False
|
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
The keyword arguments. |
Source code in src/zenml/execution/pipeline/dynamic/runner.py
691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 | |
expand_mapped_inputs(inputs: Dict[str, Any], product: bool = False) -> List[Dict[str, Any]]
Find the mapped and unmapped inputs of a step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
inputs
|
Dict[str, Any]
|
The step function inputs. |
required |
product
|
bool
|
Whether to produce a cartesian product of the mapped inputs. |
False
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If no mapped inputs are found or the input combinations are not valid. |
Returns:
| Type | Description |
|---|---|
List[Dict[str, Any]]
|
The step inputs. |
Source code in src/zenml/execution/pipeline/dynamic/runner.py
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 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 | |
get_config_template(snapshot: PipelineSnapshotResponse, step: BaseStep, pipeline: DynamicPipeline) -> Optional[Step]
Get the config template for a step executed in a dynamic pipeline.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
PipelineSnapshotResponse
|
The snapshot of the pipeline. |
required |
step
|
BaseStep
|
The step to get the config template for. |
required |
pipeline
|
DynamicPipeline
|
The dynamic pipeline that the step is being executed in. |
required |
Returns:
| Type | Description |
|---|---|
Optional[Step]
|
The config template for the step. |
Source code in src/zenml/execution/pipeline/dynamic/runner.py
560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 | |
get_step_runtime(step_config: StepConfiguration, pipeline_docker_settings: DockerSettings) -> StepRuntime
Determine if a step should be run in process.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step_config
|
StepConfiguration
|
The step configuration. |
required |
pipeline_docker_settings
|
DockerSettings
|
The Docker settings of the parent pipeline. |
required |
Returns:
| Type | Description |
|---|---|
StepRuntime
|
The runtime for the step. |
Source code in src/zenml/execution/pipeline/dynamic/runner.py
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 | |
utils
Dynamic pipeline execution utilities.
unmapped(value: T) -> _Unmapped[T]
Helper function to pass an input without mapping over it.
Wrap any step input with this function and then pass it to step.map(...)
to pass the full value to all steps.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
T
|
The value to wrap. |
required |
Returns:
| Type | Description |
|---|---|
_Unmapped[T]
|
The wrapped value. |
Source code in src/zenml/execution/pipeline/dynamic/utils.py
36 37 38 39 40 41 42 43 44 45 46 47 48 | |
utils
Pipeline execution utilities.
prevent_pipeline_execution() -> Generator[None, None, None]
Context manager to prevent pipeline execution.
Yields:
| Type | Description |
|---|---|
None
|
None. |
Source code in src/zenml/execution/pipeline/utils.py
60 61 62 63 64 65 66 67 68 69 70 71 | |
should_prevent_pipeline_execution() -> bool
Whether to prevent pipeline execution.
Returns:
| Type | Description |
|---|---|
bool
|
Whether to prevent pipeline execution. |
Source code in src/zenml/execution/pipeline/utils.py
51 52 53 54 55 56 57 | |
submit_pipeline(snapshot: PipelineSnapshotResponse, stack: Stack, placeholder_run: Optional[PipelineRunResponse] = None) -> None
Submit a snapshot for execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
PipelineSnapshotResponse
|
The snapshot to submit. |
required |
stack
|
Stack
|
The stack on which to submit the snapshot. |
required |
placeholder_run
|
Optional[PipelineRunResponse]
|
An optional placeholder run for the snapshot. |
None
|
noqa: DAR401
Raises: BaseException: Any exception that happened while submitting or running (in case it happens synchronously) the pipeline.
Source code in src/zenml/execution/pipeline/utils.py
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 | |
step
Step execution.
Modules
utils
Step execution utilities.
launch_step(snapshot: PipelineSnapshotResponse, step: Step, orchestrator_run_id: str, retry: bool = False) -> StepRunResponse
Launch a step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
PipelineSnapshotResponse
|
The snapshot. |
required |
step
|
Step
|
The step to run. |
required |
orchestrator_run_id
|
str
|
The orchestrator run ID. |
required |
retry
|
bool
|
Whether to retry the step if it fails. |
False
|
Raises:
| Type | Description |
|---|---|
RunStoppedException
|
If the run was stopped. |
BaseException
|
If the step failed all retries. |
Returns:
| Type | Description |
|---|---|
StepRunResponse
|
The step run response. |
Source code in src/zenml/execution/step/utils.py
37 38 39 40 41 42 43 44 45 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 | |