Stack
zenml.stack
Initialization of the ZenML Stack.
The stack is essentially all the configuration for the infrastructure of your MLOps platform.
A stack is made up of multiple components. Some examples are:
- An Artifact Store
- An Orchestrator
- A Step Operator (Optional)
- A Container Registry (Optional)
Attributes
__all__ = ['Flavor', 'Stack', 'StackComponent', 'StackValidator', 'StackComponentConfig']
module-attribute
Classes
Flavor
Class for ZenML Flavors.
Attributes
config_class: Type[StackComponentConfig]
abstractmethod
property
Returns StackComponentConfig config class.
Returns:
| Type | Description |
|---|---|
Type[StackComponentConfig]
|
The config class. |
config_schema: Dict[str, Any]
property
The config schema for a flavor.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
The config schema. |
display_name: Optional[str]
property
The display name of the flavor.
By default, converts the technical name to a human-readable format. For example, "vm_kubernetes" becomes "VM Kubernetes". Flavors can override this to provide custom display names.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
The display name of the flavor. |
docs_url: Optional[str]
property
A url to point at docs explaining this flavor.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
A flavor docs url. |
implementation_class: Type[StackComponent]
abstractmethod
property
Implementation class for this flavor.
Returns:
| Type | Description |
|---|---|
Type[StackComponent]
|
The implementation class for this flavor. |
logo_url: Optional[str]
property
A url to represent the flavor in the dashboard.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
The flavor logo. |
name: str
abstractmethod
property
The flavor name.
Returns:
| Type | Description |
|---|---|
str
|
The flavor name. |
sdk_docs_url: Optional[str]
property
A url to point at SDK docs explaining this flavor.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
A flavor SDK docs url. |
service_connector_requirements: Optional[ServiceConnectorRequirements]
property
Service connector resource requirements for service connectors.
Specifies resource requirements that are used to filter the available service connector types that are compatible with this flavor.
Returns:
| Type | Description |
|---|---|
Optional[ServiceConnectorRequirements]
|
Requirements for compatible service connectors, if a service |
Optional[ServiceConnectorRequirements]
|
connector is required for this flavor. |
type: StackComponentType
abstractmethod
property
Functions
from_model(flavor_model: FlavorResponse) -> Flavor
classmethod
Loads a flavor from a model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
flavor_model
|
FlavorResponse
|
The model to load from. |
required |
Raises:
| Type | Description |
|---|---|
CustomFlavorImportError
|
If the custom flavor can't be imported. |
ImportError
|
If the flavor can't be imported. |
Returns:
| Type | Description |
|---|---|
Flavor
|
The loaded flavor. |
Source code in src/zenml/stack/flavor.py
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 | |
generate_default_docs_url() -> str
Generate the doc urls for all inbuilt and integration flavors.
Note that this method is not going to be useful for custom flavors, which do not have any docs in the main zenml docs.
Returns:
| Type | Description |
|---|---|
str
|
The complete url to the zenml documentation |
Source code in src/zenml/stack/flavor.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
generate_default_sdk_docs_url() -> str
Generate SDK docs url for a flavor.
Returns:
| Type | Description |
|---|---|
str
|
The complete url to the zenml SDK docs |
Source code in src/zenml/stack/flavor.py
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 | |
to_model(integration: Optional[str] = None, is_custom: bool = True) -> FlavorRequest
Converts a flavor to a model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
integration
|
Optional[str]
|
The integration to use for the model. |
None
|
is_custom
|
bool
|
Whether the flavor is a custom flavor. |
True
|
Returns:
| Type | Description |
|---|---|
FlavorRequest
|
The model. |
Source code in src/zenml/stack/flavor.py
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 | |
Stack(id: UUID, name: str, *, environment: Optional[Dict[str, str]] = None, secrets: Optional[List[UUID]] = None, orchestrator: BaseOrchestrator, artifact_store: BaseArtifactStore, container_registry: Optional[BaseContainerRegistry] = None, step_operator: Optional[Union[BaseStepOperator, List[BaseStepOperator]]] = None, feature_store: Optional[BaseFeatureStore] = None, model_deployer: Optional[BaseModelDeployer] = None, experiment_tracker: Optional[Union[BaseExperimentTracker, List[BaseExperimentTracker]]] = None, alerter: Optional[Union[BaseAlerter, List[BaseAlerter]]] = None, annotator: Optional[BaseAnnotator] = None, data_validator: Optional[BaseDataValidator] = None, image_builder: Optional[BaseImageBuilder] = None, model_registry: Optional[BaseModelRegistry] = None, deployer: Optional[BaseDeployer] = None, log_store: Optional[BaseLogStore] = None)
ZenML stack class.
A ZenML stack is a collection of multiple stack components that are required to run ZenML pipelines. Some of these components (orchestrator, and artifact store) are required to run any kind of pipeline, other components like the container registry are only required if other stack components depend on them.
Initializes and validates a stack instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
UUID
|
Unique ID of the stack. |
required |
name
|
str
|
Name of the stack. |
required |
environment
|
Optional[Dict[str, str]]
|
Environment variables to set when running on this stack. |
None
|
secrets
|
Optional[List[UUID]]
|
Secrets to set as environment variables when running on this stack. |
None
|
orchestrator
|
BaseOrchestrator
|
Orchestrator component of the stack. |
required |
artifact_store
|
BaseArtifactStore
|
Artifact store component of the stack. |
required |
container_registry
|
Optional[BaseContainerRegistry]
|
Container registry component of the stack. |
None
|
step_operator
|
Optional[Union[BaseStepOperator, List[BaseStepOperator]]]
|
Step operator component of the stack. |
None
|
feature_store
|
Optional[BaseFeatureStore]
|
Feature store component of the stack. |
None
|
model_deployer
|
Optional[BaseModelDeployer]
|
Model deployer component of the stack. |
None
|
experiment_tracker
|
Optional[Union[BaseExperimentTracker, List[BaseExperimentTracker]]]
|
Experiment tracker component of the stack. |
None
|
alerter
|
Optional[Union[BaseAlerter, List[BaseAlerter]]]
|
Alerter component of the stack. |
None
|
annotator
|
Optional[BaseAnnotator]
|
Annotator component of the stack. |
None
|
data_validator
|
Optional[BaseDataValidator]
|
Data validator component of the stack. |
None
|
image_builder
|
Optional[BaseImageBuilder]
|
Image builder component of the stack. |
None
|
model_registry
|
Optional[BaseModelRegistry]
|
Model registry component of the stack. |
None
|
deployer
|
Optional[BaseDeployer]
|
Deployer component of the stack. |
None
|
log_store
|
Optional[BaseLogStore]
|
Log store component of the stack. |
None
|
Source code in src/zenml/stack/stack.py
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 | |
Attributes
alerter: Optional[BaseAlerter]
property
alerters: Dict[str, BaseAlerter]
property
All attached alerters keyed by component name.
Returns:
| Type | Description |
|---|---|
Dict[str, BaseAlerter]
|
The stack alerters keyed by their names. |
all_components: List[StackComponent]
property
All attached components of the stack.
Returns:
| Type | Description |
|---|---|
List[StackComponent]
|
A flat list of all components attached to the stack. |
annotator: Optional[BaseAnnotator]
property
The annotator of the stack.
Returns:
| Type | Description |
|---|---|
Optional[BaseAnnotator]
|
The annotator of the stack. |
apt_packages: List[str]
property
List of APT package requirements for the stack.
Returns:
| Type | Description |
|---|---|
List[str]
|
A list of APT package requirements for the stack. |
artifact_store: BaseArtifactStore
property
The artifact store of the stack.
Returns:
| Type | Description |
|---|---|
BaseArtifactStore
|
The artifact store of the stack. |
component_flavor_metadata: Dict[str, str]
property
Flavor metadata for attached components grouped by type.
Returns:
| Type | Description |
|---|---|
Dict[str, str]
|
A mapping from stack component type values to comma-separated |
Dict[str, str]
|
flavor names. Repeated flavors are only included once and the |
Dict[str, str]
|
component order is preserved. |
components: Dict[StackComponentType, StackComponent]
property
All components of the stack.
Returns:
| Type | Description |
|---|---|
Dict[StackComponentType, StackComponent]
|
A dictionary of all components of the stack. |
container_registry: Optional[BaseContainerRegistry]
property
The container registry of the stack.
Returns:
| Type | Description |
|---|---|
Optional[BaseContainerRegistry]
|
The container registry of the stack or None if the stack does not |
Optional[BaseContainerRegistry]
|
have a container registry. |
data_validator: Optional[BaseDataValidator]
property
The data validator of the stack.
Returns:
| Type | Description |
|---|---|
Optional[BaseDataValidator]
|
The data validator of the stack. |
deployer: Optional[BaseDeployer]
property
The deployer of the stack.
Returns:
| Type | Description |
|---|---|
Optional[BaseDeployer]
|
The deployer of the stack. |
environment: Dict[str, str]
property
Environment variables to set when running on this stack.
Returns:
| Type | Description |
|---|---|
Dict[str, str]
|
Environment variables to set when running on this stack. |
experiment_tracker: Optional[BaseExperimentTracker]
property
The experiment tracker of the stack.
Returns:
| Type | Description |
|---|---|
Optional[BaseExperimentTracker]
|
The experiment tracker of the stack. |
experiment_trackers: Dict[str, BaseExperimentTracker]
property
All attached experiment trackers keyed by component name.
Returns:
| Type | Description |
|---|---|
Dict[str, BaseExperimentTracker]
|
The stack experiment trackers keyed by their names. |
feature_store: Optional[BaseFeatureStore]
property
The feature store of the stack.
Returns:
| Type | Description |
|---|---|
Optional[BaseFeatureStore]
|
The feature store of the stack. |
id: UUID
property
The ID of the stack.
Returns:
| Type | Description |
|---|---|
UUID
|
The ID of the stack. |
image_builder: Optional[BaseImageBuilder]
property
The image builder of the stack.
Returns:
| Type | Description |
|---|---|
Optional[BaseImageBuilder]
|
The image builder of the stack. |
log_store: BaseLogStore
property
model_deployer: Optional[BaseModelDeployer]
property
The model deployer of the stack.
Returns:
| Type | Description |
|---|---|
Optional[BaseModelDeployer]
|
The model deployer of the stack. |
model_registry: Optional[BaseModelRegistry]
property
The model registry of the stack.
Returns:
| Type | Description |
|---|---|
Optional[BaseModelRegistry]
|
The model registry of the stack. |
name: str
property
The name of the stack.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The name of the stack. |
orchestrator: BaseOrchestrator
property
The orchestrator of the stack.
Returns:
| Type | Description |
|---|---|
BaseOrchestrator
|
The orchestrator of the stack. |
required_secrets: Set[secret_utils.SecretReference]
property
All required secrets for this stack.
Returns:
| Type | Description |
|---|---|
Set[SecretReference]
|
The required secrets of this stack. |
requires_remote_server: bool
property
If the stack requires a remote ZenServer to run.
This is the case if any code is getting executed remotely. This is the case for both remote orchestrators as well as remote step operators.
Returns:
| Type | Description |
|---|---|
bool
|
If the stack requires a remote ZenServer to run. |
secrets: List[UUID]
property
Secrets to set as environment variables when running on this stack.
Returns:
| Type | Description |
|---|---|
List[UUID]
|
Secrets to set as environment variables when running on this stack. |
setting_classes: Dict[str, Type[BaseSettings]]
property
Setting classes of all components of this stack.
Returns:
| Type | Description |
|---|---|
Dict[str, Type[BaseSettings]]
|
All setting classes and their respective keys. |
step_operator: Optional[BaseStepOperator]
property
The step operator of the stack.
Returns:
| Type | Description |
|---|---|
Optional[BaseStepOperator]
|
The step operator of the stack. |
step_operators: Dict[str, BaseStepOperator]
property
All attached step operators keyed by component name.
Returns:
| Type | Description |
|---|---|
Dict[str, BaseStepOperator]
|
The stack step operators keyed by their names. |
Functions
check_local_paths() -> bool
Checks if the stack has local paths.
Returns:
| Type | Description |
|---|---|
bool
|
True if the stack has local paths, False otherwise. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the stack has local paths that do not conform to the convention that all local path must be relative to the local stores directory. |
Source code in src/zenml/stack/stack.py
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 | |
cleanup_step_run(info: StepRunInfo, step_failed: bool) -> None
Cleans up resources after the step run is finished.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
info
|
StepRunInfo
|
Info about the step that was executed. |
required |
step_failed
|
bool
|
Whether the step failed. |
required |
Source code in src/zenml/stack/stack.py
1553 1554 1555 1556 1557 1558 1559 1560 1561 | |
deploy_pipeline(snapshot: PipelineSnapshotResponse, deployment_name: str, timeout: Optional[int] = None) -> DeploymentResponse
Deploys a pipeline on this stack.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
PipelineSnapshotResponse
|
The pipeline snapshot. |
required |
deployment_name
|
str
|
The name to use for the deployment. |
required |
timeout
|
Optional[int]
|
The maximum time in seconds to wait for the pipeline to be deployed. |
None
|
Returns:
| Type | Description |
|---|---|
DeploymentResponse
|
The deployment response. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the stack does not have a deployer. |
Source code in src/zenml/stack/stack.py
1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 | |
dict() -> Dict[str, str]
Converts the stack into a dictionary.
Returns:
| Type | Description |
|---|---|
Dict[str, str]
|
A dictionary containing the stack components. |
Source code in src/zenml/stack/stack.py
985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 | |
from_components(id: UUID, name: str, components: Dict[StackComponentType, StackComponent], environment: Optional[Dict[str, str]] = None, secrets: Optional[List[UUID]] = None) -> Stack
classmethod
Creates a stack instance from a dict of stack components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
UUID
|
Unique ID of the stack. |
required |
name
|
str
|
The name of the stack. |
required |
components
|
Dict[StackComponentType, StackComponent]
|
The components of the stack. |
required |
environment
|
Optional[Dict[str, str]]
|
Environment variables to set when running on this stack. |
None
|
secrets
|
Optional[List[UUID]]
|
Secrets to set as environment variables when running on this stack. |
None
|
Returns:
| Type | Description |
|---|---|
Stack
|
A stack instance consisting of the given components. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If a required component is missing or a component doesn't inherit from the expected base class. |
Source code in src/zenml/stack/stack.py
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 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 | |
from_components_v2(id: UUID, name: str, components: Mapping[StackComponentType, List[StackComponent]], environment: Optional[Dict[str, str]] = None, secrets: Optional[List[UUID]] = None) -> Stack
classmethod
Creates a stack instance from a dict of stack components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
UUID
|
Unique ID of the stack. |
required |
name
|
str
|
The name of the stack. |
required |
components
|
Mapping[StackComponentType, List[StackComponent]]
|
The components of the stack grouped by type. Callers may pass either a single component per type or a list. The first component in a repeatable component list is treated as the default component for that type. |
required |
environment
|
Optional[Dict[str, str]]
|
Environment variables to set when running on this stack. |
None
|
secrets
|
Optional[List[UUID]]
|
Secrets to set as environment variables when running on this stack. |
None
|
Returns:
| Type | Description |
|---|---|
Stack
|
A stack instance consisting of the given components. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If a required component is missing or a component doesn't inherit from the expected base class. |
Source code in src/zenml/stack/stack.py
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 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 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 | |
from_model(stack_model: StackResponse) -> Stack
classmethod
Creates a Stack instance from a StackModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stack_model
|
StackResponse
|
The StackModel to create the Stack from. |
required |
Returns:
| Type | Description |
|---|---|
Stack
|
The created Stack instance. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If a stack component's dependencies cannot be imported. |
Source code in src/zenml/stack/stack.py
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 | |
get_components_by_type(component_type: StackComponentType) -> Sequence[StackComponent]
Returns all components of a given type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_type
|
StackComponentType
|
The component type to fetch. |
required |
Returns:
| Type | Description |
|---|---|
Sequence[StackComponent]
|
A list of attached components of the given type. |
Source code in src/zenml/stack/stack.py
694 695 696 697 698 699 700 701 702 703 704 705 | |
get_docker_builds(snapshot: PipelineSnapshotBase) -> List[BuildConfiguration]
Gets the Docker builds required for the stack.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
PipelineSnapshotBase
|
The pipeline snapshot for which to get the builds. |
required |
Returns:
| Type | Description |
|---|---|
List[BuildConfiguration]
|
The required Docker builds. |
Source code in src/zenml/stack/stack.py
1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 | |
get_pipeline_run_metadata(run_id: UUID) -> Dict[UUID, Dict[str, MetadataType]]
Get general component-specific metadata for a pipeline run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_id
|
UUID
|
ID of the pipeline run. |
required |
Returns:
| Type | Description |
|---|---|
Dict[UUID, Dict[str, MetadataType]]
|
A dictionary mapping component IDs to the metadata they created. |
Source code in src/zenml/stack/stack.py
1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 | |
get_step_run_metadata(info: StepRunInfo) -> Dict[UUID, Dict[str, MetadataType]]
Get component-specific metadata for a step run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
info
|
StepRunInfo
|
Info about the step that was executed. |
required |
Returns:
| Type | Description |
|---|---|
Dict[UUID, Dict[str, MetadataType]]
|
A dictionary mapping component IDs to the metadata they created. |
Source code in src/zenml/stack/stack.py
1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 | |
prepare_pipeline_submission(snapshot: PipelineSnapshotResponse) -> None
Prepares the stack for a pipeline submission.
This method is called before a pipeline is submitted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
PipelineSnapshotResponse
|
The pipeline snapshot |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If trying to submit a pipeline that requires a remote ZenML server with a local one. |
Source code in src/zenml/stack/stack.py
1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 | |
prepare_step_run(info: StepRunInfo) -> None
Prepares running a step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
info
|
StepRunInfo
|
Info about the step that will be executed. |
required |
Source code in src/zenml/stack/stack.py
1494 1495 1496 1497 1498 1499 1500 1501 | |
requirements(exclude_components: Optional[AbstractSet[StackComponentType]] = None) -> Set[str]
Set of PyPI requirements for the stack.
This method combines the requirements of all stack components (except
the ones specified in exclude_components).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exclude_components
|
Optional[AbstractSet[StackComponentType]]
|
Set of component types for which the requirements should not be included in the output. |
None
|
Returns:
| Type | Description |
|---|---|
Set[str]
|
Set of PyPI requirements. |
Source code in src/zenml/stack/stack.py
1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 | |
submit_pipeline(snapshot: PipelineSnapshotResponse, placeholder_run: Optional[PipelineRunResponse] = None) -> None
Submits a pipeline on this stack.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
PipelineSnapshotResponse
|
The pipeline snapshot. |
required |
placeholder_run
|
Optional[PipelineRunResponse]
|
An optional placeholder run for the snapshot. |
None
|
Source code in src/zenml/stack/stack.py
1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 | |
validate(fail_if_secrets_missing: bool = False) -> None
Checks whether the stack configuration is valid.
To check if a stack configuration is valid, the following criteria must
be met:
- the stack must have an image builder if other components require it
- the StackValidator of each stack component has to validate the
stack to make sure all the components are compatible with each other
- the required secrets of all components need to exist
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fail_if_secrets_missing
|
bool
|
If this is |
False
|
Source code in src/zenml/stack/stack.py
1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 | |
validate_image_builder() -> None
Validates that the stack has an image builder if required.
If the stack requires an image builder, but none is specified, a local image builder will be created and assigned to the stack to ensure backwards compatibility.
Source code in src/zenml/stack/stack.py
1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 | |
validate_log_store() -> None
Validates that the stack has a log store.
Source code in src/zenml/stack/stack.py
1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 | |
StackComponent(name: str, id: UUID, config: StackComponentConfig, flavor: str, type: StackComponentType, user: Optional[UUID], created: datetime, updated: datetime, environment: Optional[Dict[str, str]] = None, secrets: Optional[List[UUID]] = None, labels: Optional[Dict[str, Any]] = None, connector_requirements: Optional[ServiceConnectorRequirements] = None, connector: Optional[UUID] = None, connector_resource_id: Optional[str] = None, *args: Any, **kwargs: Any)
Abstract StackComponent class for all components of a ZenML stack.
Initializes a StackComponent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the component. |
required |
id
|
UUID
|
The unique ID of the component. |
required |
config
|
StackComponentConfig
|
The config of the component. |
required |
flavor
|
str
|
The flavor of the component. |
required |
type
|
StackComponentType
|
The type of the component. |
required |
user
|
Optional[UUID]
|
The ID of the user who created the component. |
required |
created
|
datetime
|
The creation time of the component. |
required |
updated
|
datetime
|
The last update time of the component. |
required |
environment
|
Optional[Dict[str, str]]
|
Environment variables to set when running on this component. |
None
|
secrets
|
Optional[List[UUID]]
|
Secrets to set as environment variables when running on this component. |
None
|
labels
|
Optional[Dict[str, Any]]
|
The labels of the component. |
None
|
connector_requirements
|
Optional[ServiceConnectorRequirements]
|
The requirements for the connector. |
None
|
connector
|
Optional[UUID]
|
The ID of a connector linked to the component. |
None
|
connector_resource_id
|
Optional[str]
|
The custom resource ID to access through the connector. |
None
|
*args
|
Any
|
Additional positional arguments. |
()
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If a secret reference is passed as name. |
Source code in src/zenml/stack/stack_component.py
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 | |
Attributes
apt_packages: List[str]
property
List of APT package requirements for the component.
Returns:
| Type | Description |
|---|---|
List[str]
|
A list of APT package requirements for the component. |
config: StackComponentConfig
property
Returns the configuration of the stack component.
This should be overwritten by any subclasses that define custom configs to return the correct config class.
Returns:
| Type | Description |
|---|---|
StackComponentConfig
|
The configuration of the stack component. |
local_path: Optional[str]
property
Path to a local directory to store persistent information.
This property should only be implemented by components that need to store persistent information in a directory on the local machine and also need that information to be available during pipeline runs.
IMPORTANT: the path returned by this property must always be a path that is relative to the ZenML local store's directory. The local orchestrators rely on this convention to correctly mount the local folders in the containers. This is an example of a valid path:
from zenml.config.global_config import GlobalConfiguration
...
@property
def local_path(self) -> Optional[str]:
return os.path.join(
GlobalConfiguration().local_stores_path,
str(self.uuid),
)
Returns:
| Type | Description |
|---|---|
Optional[str]
|
A path to a local directory used by the component to store |
Optional[str]
|
persistent information. |
log_file: Optional[str]
property
Optional path to a log file for the stack component.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Optional path to a log file for the stack component. |
post_registration_message: Optional[str]
property
Optional message printed after the stack component is registered.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
An optional message. |
requirements: Set[str]
property
Set of PyPI requirements for the component.
Returns:
| Type | Description |
|---|---|
Set[str]
|
A set of PyPI requirements for the component. |
settings_class: Optional[Type[BaseSettings]]
property
Class specifying available settings for this component.
Returns:
| Type | Description |
|---|---|
Optional[Type[BaseSettings]]
|
Optional settings class. |
validator: Optional[StackValidator]
property
The optional validator of the stack component.
This validator will be called each time a stack with the stack
component is initialized. Subclasses should override this property
and return a StackValidator that makes sure they're not included in
any stack that they're not compatible with.
Returns:
| Type | Description |
|---|---|
Optional[StackValidator]
|
An optional |
Functions
cleanup() -> None
Cleans up the component after it has been used.
Source code in src/zenml/stack/stack_component.py
794 795 796 | |
cleanup_step_run(info: StepRunInfo, step_failed: bool) -> None
Cleans up resources after the step run is finished.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
info
|
StepRunInfo
|
Info about the step that was executed. |
required |
step_failed
|
bool
|
Whether the step failed. |
required |
Source code in src/zenml/stack/stack_component.py
763 764 765 766 767 768 769 | |
connector_has_expired() -> bool
Checks whether the connector linked to this stack component has expired.
Returns:
| Type | Description |
|---|---|
bool
|
Whether the connector linked to this stack component has expired, or isn't linked to a connector. |
Source code in src/zenml/stack/stack_component.py
562 563 564 565 566 567 568 569 570 571 572 573 574 575 | |
from_model(component_model: ComponentResponse) -> StackComponent
classmethod
Creates a StackComponent from a ComponentModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_model
|
ComponentResponse
|
The ComponentModel to create the StackComponent |
required |
Returns:
| Type | Description |
|---|---|
StackComponent
|
The created StackComponent. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If the flavor can't be imported. |
Source code in src/zenml/stack/stack_component.py
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 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
get_connector() -> Optional[ServiceConnector]
Returns the connector linked to this stack component.
Returns:
| Type | Description |
|---|---|
Optional[ServiceConnector]
|
The connector linked to this stack component. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the stack component does not specify connector requirements or if the connector linked to the component is not compatible or not found. |
Source code in src/zenml/stack/stack_component.py
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 | |
get_docker_builds(snapshot: PipelineSnapshotBase) -> List[BuildConfiguration]
Gets the Docker builds required for the component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
PipelineSnapshotBase
|
The pipeline snapshot for which to get the builds. |
required |
Returns:
| Type | Description |
|---|---|
List[BuildConfiguration]
|
The required Docker builds. |
Source code in src/zenml/stack/stack_component.py
717 718 719 720 721 722 723 724 725 726 727 728 | |
get_pipeline_run_metadata(run_id: UUID) -> Dict[str, MetadataType]
Get general component-specific metadata for a pipeline run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_id
|
UUID
|
The ID of the pipeline run. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, MetadataType]
|
A dictionary of metadata. |
Source code in src/zenml/stack/stack_component.py
730 731 732 733 734 735 736 737 738 739 740 741 | |
get_settings(container: Union[Step, StepRunResponse, StepRunInfo, PipelineSnapshotBase, PipelineSnapshotResponse, PipelineRunResponse]) -> BaseSettings
Gets settings for this stack component.
This will return None if the stack component doesn't specify a
settings class or the container doesn't contain runtime
options for this component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container
|
Union[Step, StepRunResponse, StepRunInfo, PipelineSnapshotBase, PipelineSnapshotResponse, PipelineRunResponse]
|
The |
required |
Returns:
| Type | Description |
|---|---|
BaseSettings
|
Settings for this stack component. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the stack component does not specify a settings class. |
Source code in src/zenml/stack/stack_component.py
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 | |
get_step_run_metadata(info: StepRunInfo) -> Dict[str, MetadataType]
Get component- and step-specific metadata after a step ran.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
info
|
StepRunInfo
|
Info about the step that was executed. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, MetadataType]
|
A dictionary of metadata. |
Source code in src/zenml/stack/stack_component.py
750 751 752 753 754 755 756 757 758 759 760 761 | |
prepare_step_run(info: StepRunInfo) -> None
Prepares running a step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
info
|
StepRunInfo
|
Info about the step that will be executed. |
required |
Source code in src/zenml/stack/stack_component.py
743 744 745 746 747 748 | |
StackComponentConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseModel, ABC
Base class for all ZenML stack component configs.
Ensures that secret references don't clash with pydantic validation.
StackComponents allow the specification of all their string attributes
using secret references of the form {{secret_name.key}}. This however
is only possible when the stack component does not perform any explicit
validation of this attribute using pydantic validators. If this were
the case, the validation would run on the secret reference and would
fail or in the worst case, modify the secret reference and lead to
unexpected behavior. This method ensures that no attributes that require
custom pydantic validation are set as secret references.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
warn_about_plain_text_secrets
|
bool
|
If true, then warns about using plain-text secrets. |
False
|
**kwargs
|
Any
|
Arguments to initialize this stack component. |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If an attribute that requires custom pydantic validation
is passed as a secret reference, or if the |
Source code in src/zenml/stack/stack_component.py
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 | |
Attributes
is_local: bool
property
Checks if this stack component is running locally.
Concrete stack component configuration classes should override this method to return True if the stack component is relying on local resources or capabilities (e.g. local filesystem, local database or other services).
Examples:
- Artifact Stores that store artifacts in the local filesystem
- Orchestrators that are connected to local orchestration runtime services (e.g. local Kubernetes clusters, Docker containers etc).
Returns:
| Type | Description |
|---|---|
bool
|
True if this config is for a local component, False otherwise. |
is_remote: bool
property
Checks if this stack component is running remotely.
Concrete stack component configuration classes should override this method to return True if the stack component is running in a remote location, and it needs to access the ZenML database.
This designation is used to determine if the stack component can be used with a local ZenML database or if it requires a remote ZenML server.
Examples:
- Orchestrators that are running pipelines in the cloud or in a location other than the local host
- Step Operators that are running steps in the cloud or in a location other than the local host
Returns:
| Type | Description |
|---|---|
bool
|
True if this config is for a remote component, False otherwise. |
is_valid: bool
property
Checks if the stack component configurations are valid.
Concrete stack component configuration classes should override this method to return False if the stack component configurations are invalid.
Returns:
| Type | Description |
|---|---|
bool
|
True if the stack component config is valid, False otherwise. |
required_secrets: Set[secret_utils.SecretReference]
property
All required secrets for this stack component.
Returns:
| Type | Description |
|---|---|
Set[SecretReference]
|
The required secrets of this stack component. |
Functions
StackValidator(required_components: Optional[AbstractSet[StackComponentType]] = None, custom_validation_function: Optional[Callable[[Stack], Tuple[bool, str]]] = None)
A StackValidator is used to validate a stack configuration.
Each StackComponent can provide a StackValidator to make sure it is
compatible with all components of the stack. The KubeflowOrchestrator
for example will always require the stack to have a container registry
in order to push the docker images that are required to run a pipeline
in Kubeflow Pipelines.
Initializes a StackValidator instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
required_components
|
Optional[AbstractSet[StackComponentType]]
|
Optional set of stack components that must exist in the stack. |
None
|
custom_validation_function
|
Optional[Callable[[Stack], Tuple[bool, str]]]
|
Optional function that returns whether a stack is valid and an error message to show if not valid. |
None
|
Source code in src/zenml/stack/stack_validator.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
Functions
validate(stack: Stack) -> None
Validates the given stack.
Checks if the stack contains all the required components and passes the custom validation function of the validator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stack
|
Stack
|
The stack to validate. |
required |
Raises:
| Type | Description |
|---|---|
StackValidationError
|
If the stack does not meet all the validation criteria. |
Source code in src/zenml/stack/stack_validator.py
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 | |
Modules
authentication_mixin
Stack component mixin for authentication.
Classes
AuthenticationConfigMixin(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: StackComponentConfig
Base config for authentication mixins.
Any stack component that implements AuthenticationMixin should have a
config that inherits from this class.
Field descriptions are defined inline using Field() descriptors.
Source code in src/zenml/stack/stack_component.py
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 | |
AuthenticationMixin(name: str, id: UUID, config: StackComponentConfig, flavor: str, type: StackComponentType, user: Optional[UUID], created: datetime, updated: datetime, environment: Optional[Dict[str, str]] = None, secrets: Optional[List[UUID]] = None, labels: Optional[Dict[str, Any]] = None, connector_requirements: Optional[ServiceConnectorRequirements] = None, connector: Optional[UUID] = None, connector_resource_id: Optional[str] = None, *args: Any, **kwargs: Any)
Bases: StackComponent
Stack component mixin for authentication.
Any stack component that implements this mixin should have a config that
inherits from AuthenticationConfigMixin.
Source code in src/zenml/stack/stack_component.py
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 | |
config: AuthenticationConfigMixin
property
Returns the AuthenticationConfigMixin config.
Returns:
| Type | Description |
|---|---|
AuthenticationConfigMixin
|
The configuration. |
get_authentication_secret() -> Optional[SecretResponse]
Gets the secret referred to by the authentication secret attribute.
Returns:
| Type | Description |
|---|---|
Optional[SecretResponse]
|
The secret if the |
Optional[SecretResponse]
|
|
Raises:
| Type | Description |
|---|---|
KeyError
|
If the secret does not exist. |
Source code in src/zenml/stack/authentication_mixin.py
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 | |
get_typed_authentication_secret(expected_schema_type: Type[T]) -> Optional[T]
Gets a typed secret referred to by the authentication secret attribute.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
expected_schema_type
|
Type[T]
|
A Pydantic model class that represents the expected schema type of the secret. |
required |
Returns:
| Type | Description |
|---|---|
Optional[T]
|
The secret values extracted from the secret and converted into the |
Optional[T]
|
indicated Pydantic type, if the |
Optional[T]
|
set, |
Raises:
| Type | Description |
|---|---|
TypeError
|
If the secret cannot be converted into the indicated Pydantic type. |
Source code in src/zenml/stack/authentication_mixin.py
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 | |
flavor
Base ZenML Flavor implementation.
Classes
Flavor
Class for ZenML Flavors.
config_class: Type[StackComponentConfig]
abstractmethod
property
Returns StackComponentConfig config class.
Returns:
| Type | Description |
|---|---|
Type[StackComponentConfig]
|
The config class. |
config_schema: Dict[str, Any]
property
The config schema for a flavor.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
The config schema. |
display_name: Optional[str]
property
The display name of the flavor.
By default, converts the technical name to a human-readable format. For example, "vm_kubernetes" becomes "VM Kubernetes". Flavors can override this to provide custom display names.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
The display name of the flavor. |
docs_url: Optional[str]
property
A url to point at docs explaining this flavor.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
A flavor docs url. |
implementation_class: Type[StackComponent]
abstractmethod
property
Implementation class for this flavor.
Returns:
| Type | Description |
|---|---|
Type[StackComponent]
|
The implementation class for this flavor. |
logo_url: Optional[str]
property
A url to represent the flavor in the dashboard.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
The flavor logo. |
name: str
abstractmethod
property
The flavor name.
Returns:
| Type | Description |
|---|---|
str
|
The flavor name. |
sdk_docs_url: Optional[str]
property
A url to point at SDK docs explaining this flavor.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
A flavor SDK docs url. |
service_connector_requirements: Optional[ServiceConnectorRequirements]
property
Service connector resource requirements for service connectors.
Specifies resource requirements that are used to filter the available service connector types that are compatible with this flavor.
Returns:
| Type | Description |
|---|---|
Optional[ServiceConnectorRequirements]
|
Requirements for compatible service connectors, if a service |
Optional[ServiceConnectorRequirements]
|
connector is required for this flavor. |
type: StackComponentType
abstractmethod
property
from_model(flavor_model: FlavorResponse) -> Flavor
classmethod
Loads a flavor from a model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
flavor_model
|
FlavorResponse
|
The model to load from. |
required |
Raises:
| Type | Description |
|---|---|
CustomFlavorImportError
|
If the custom flavor can't be imported. |
ImportError
|
If the flavor can't be imported. |
Returns:
| Type | Description |
|---|---|
Flavor
|
The loaded flavor. |
Source code in src/zenml/stack/flavor.py
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 | |
generate_default_docs_url() -> str
Generate the doc urls for all inbuilt and integration flavors.
Note that this method is not going to be useful for custom flavors, which do not have any docs in the main zenml docs.
Returns:
| Type | Description |
|---|---|
str
|
The complete url to the zenml documentation |
Source code in src/zenml/stack/flavor.py
219 220 221 222 223 224 225 226 227 228 229 230 231 232 | |
generate_default_sdk_docs_url() -> str
Generate SDK docs url for a flavor.
Returns:
| Type | Description |
|---|---|
str
|
The complete url to the zenml SDK docs |
Source code in src/zenml/stack/flavor.py
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 | |
to_model(integration: Optional[str] = None, is_custom: bool = True) -> FlavorRequest
Converts a flavor to a model.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
integration
|
Optional[str]
|
The integration to use for the model. |
None
|
is_custom
|
bool
|
Whether the flavor is a custom flavor. |
True
|
Returns:
| Type | Description |
|---|---|
FlavorRequest
|
The model. |
Source code in src/zenml/stack/flavor.py
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 | |
Functions
validate_flavor_source(source: str, component_type: StackComponentType) -> Type[Flavor]
Import a StackComponent class from a given source and validate its type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source
|
str
|
source path of the implementation |
required |
component_type
|
StackComponentType
|
the type of the stack component |
required |
Returns:
| Type | Description |
|---|---|
Type[Flavor]
|
the imported class |
Raises:
| Type | Description |
|---|---|
ValueError
|
If ZenML cannot find the given module path |
TypeError
|
If the given module path does not point to a subclass of a StackComponent which has the right component type. |
Source code in src/zenml/stack/flavor.py
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 | |
Modules
flavor_registry
Implementation of the ZenML flavor registry.
Classes
FlavorRegistry()
Registry for stack component flavors.
The flavors defined by ZenML must be registered here.
Initialization of the flavors.
Source code in src/zenml/stack/flavor_registry.py
40 41 42 43 44 | |
builtin_flavors: List[Type[Flavor]]
property
A list of all default in-built flavors.
Returns:
| Type | Description |
|---|---|
List[Type[Flavor]]
|
A list of builtin flavors. |
integration_flavors: List[Type[Flavor]]
property
A list of all default integration flavors.
Returns:
| Type | Description |
|---|---|
List[Type[Flavor]]
|
A list of integration flavors. |
register_builtin_flavors(store: BaseZenStore) -> None
Registers the default built-in flavors.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store
|
BaseZenStore
|
The instance of the zen_store to use |
required |
Source code in src/zenml/stack/flavor_registry.py
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 | |
register_flavors(store: BaseZenStore) -> None
Register all flavors to the DB.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store
|
BaseZenStore
|
The instance of a store to use for persistence |
required |
Source code in src/zenml/stack/flavor_registry.py
46 47 48 49 50 51 52 53 | |
register_integration_flavors(store: BaseZenStore) -> None
staticmethod
Registers the flavors implemented by integrations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
store
|
BaseZenStore
|
The instance of the zen_store to use |
required |
Source code in src/zenml/stack/flavor_registry.py
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 | |
Functions
stack
Implementation of the ZenML Stack class.
Classes
Stack(id: UUID, name: str, *, environment: Optional[Dict[str, str]] = None, secrets: Optional[List[UUID]] = None, orchestrator: BaseOrchestrator, artifact_store: BaseArtifactStore, container_registry: Optional[BaseContainerRegistry] = None, step_operator: Optional[Union[BaseStepOperator, List[BaseStepOperator]]] = None, feature_store: Optional[BaseFeatureStore] = None, model_deployer: Optional[BaseModelDeployer] = None, experiment_tracker: Optional[Union[BaseExperimentTracker, List[BaseExperimentTracker]]] = None, alerter: Optional[Union[BaseAlerter, List[BaseAlerter]]] = None, annotator: Optional[BaseAnnotator] = None, data_validator: Optional[BaseDataValidator] = None, image_builder: Optional[BaseImageBuilder] = None, model_registry: Optional[BaseModelRegistry] = None, deployer: Optional[BaseDeployer] = None, log_store: Optional[BaseLogStore] = None)
ZenML stack class.
A ZenML stack is a collection of multiple stack components that are required to run ZenML pipelines. Some of these components (orchestrator, and artifact store) are required to run any kind of pipeline, other components like the container registry are only required if other stack components depend on them.
Initializes and validates a stack instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
UUID
|
Unique ID of the stack. |
required |
name
|
str
|
Name of the stack. |
required |
environment
|
Optional[Dict[str, str]]
|
Environment variables to set when running on this stack. |
None
|
secrets
|
Optional[List[UUID]]
|
Secrets to set as environment variables when running on this stack. |
None
|
orchestrator
|
BaseOrchestrator
|
Orchestrator component of the stack. |
required |
artifact_store
|
BaseArtifactStore
|
Artifact store component of the stack. |
required |
container_registry
|
Optional[BaseContainerRegistry]
|
Container registry component of the stack. |
None
|
step_operator
|
Optional[Union[BaseStepOperator, List[BaseStepOperator]]]
|
Step operator component of the stack. |
None
|
feature_store
|
Optional[BaseFeatureStore]
|
Feature store component of the stack. |
None
|
model_deployer
|
Optional[BaseModelDeployer]
|
Model deployer component of the stack. |
None
|
experiment_tracker
|
Optional[Union[BaseExperimentTracker, List[BaseExperimentTracker]]]
|
Experiment tracker component of the stack. |
None
|
alerter
|
Optional[Union[BaseAlerter, List[BaseAlerter]]]
|
Alerter component of the stack. |
None
|
annotator
|
Optional[BaseAnnotator]
|
Annotator component of the stack. |
None
|
data_validator
|
Optional[BaseDataValidator]
|
Data validator component of the stack. |
None
|
image_builder
|
Optional[BaseImageBuilder]
|
Image builder component of the stack. |
None
|
model_registry
|
Optional[BaseModelRegistry]
|
Model registry component of the stack. |
None
|
deployer
|
Optional[BaseDeployer]
|
Deployer component of the stack. |
None
|
log_store
|
Optional[BaseLogStore]
|
Log store component of the stack. |
None
|
Source code in src/zenml/stack/stack.py
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 | |
alerter: Optional[BaseAlerter]
property
alerters: Dict[str, BaseAlerter]
property
All attached alerters keyed by component name.
Returns:
| Type | Description |
|---|---|
Dict[str, BaseAlerter]
|
The stack alerters keyed by their names. |
all_components: List[StackComponent]
property
All attached components of the stack.
Returns:
| Type | Description |
|---|---|
List[StackComponent]
|
A flat list of all components attached to the stack. |
annotator: Optional[BaseAnnotator]
property
The annotator of the stack.
Returns:
| Type | Description |
|---|---|
Optional[BaseAnnotator]
|
The annotator of the stack. |
apt_packages: List[str]
property
List of APT package requirements for the stack.
Returns:
| Type | Description |
|---|---|
List[str]
|
A list of APT package requirements for the stack. |
artifact_store: BaseArtifactStore
property
The artifact store of the stack.
Returns:
| Type | Description |
|---|---|
BaseArtifactStore
|
The artifact store of the stack. |
component_flavor_metadata: Dict[str, str]
property
Flavor metadata for attached components grouped by type.
Returns:
| Type | Description |
|---|---|
Dict[str, str]
|
A mapping from stack component type values to comma-separated |
Dict[str, str]
|
flavor names. Repeated flavors are only included once and the |
Dict[str, str]
|
component order is preserved. |
components: Dict[StackComponentType, StackComponent]
property
All components of the stack.
Returns:
| Type | Description |
|---|---|
Dict[StackComponentType, StackComponent]
|
A dictionary of all components of the stack. |
container_registry: Optional[BaseContainerRegistry]
property
The container registry of the stack.
Returns:
| Type | Description |
|---|---|
Optional[BaseContainerRegistry]
|
The container registry of the stack or None if the stack does not |
Optional[BaseContainerRegistry]
|
have a container registry. |
data_validator: Optional[BaseDataValidator]
property
The data validator of the stack.
Returns:
| Type | Description |
|---|---|
Optional[BaseDataValidator]
|
The data validator of the stack. |
deployer: Optional[BaseDeployer]
property
The deployer of the stack.
Returns:
| Type | Description |
|---|---|
Optional[BaseDeployer]
|
The deployer of the stack. |
environment: Dict[str, str]
property
Environment variables to set when running on this stack.
Returns:
| Type | Description |
|---|---|
Dict[str, str]
|
Environment variables to set when running on this stack. |
experiment_tracker: Optional[BaseExperimentTracker]
property
The experiment tracker of the stack.
Returns:
| Type | Description |
|---|---|
Optional[BaseExperimentTracker]
|
The experiment tracker of the stack. |
experiment_trackers: Dict[str, BaseExperimentTracker]
property
All attached experiment trackers keyed by component name.
Returns:
| Type | Description |
|---|---|
Dict[str, BaseExperimentTracker]
|
The stack experiment trackers keyed by their names. |
feature_store: Optional[BaseFeatureStore]
property
The feature store of the stack.
Returns:
| Type | Description |
|---|---|
Optional[BaseFeatureStore]
|
The feature store of the stack. |
id: UUID
property
The ID of the stack.
Returns:
| Type | Description |
|---|---|
UUID
|
The ID of the stack. |
image_builder: Optional[BaseImageBuilder]
property
The image builder of the stack.
Returns:
| Type | Description |
|---|---|
Optional[BaseImageBuilder]
|
The image builder of the stack. |
log_store: BaseLogStore
property
model_deployer: Optional[BaseModelDeployer]
property
The model deployer of the stack.
Returns:
| Type | Description |
|---|---|
Optional[BaseModelDeployer]
|
The model deployer of the stack. |
model_registry: Optional[BaseModelRegistry]
property
The model registry of the stack.
Returns:
| Type | Description |
|---|---|
Optional[BaseModelRegistry]
|
The model registry of the stack. |
name: str
property
The name of the stack.
Returns:
| Name | Type | Description |
|---|---|---|
str |
str
|
The name of the stack. |
orchestrator: BaseOrchestrator
property
The orchestrator of the stack.
Returns:
| Type | Description |
|---|---|
BaseOrchestrator
|
The orchestrator of the stack. |
required_secrets: Set[secret_utils.SecretReference]
property
All required secrets for this stack.
Returns:
| Type | Description |
|---|---|
Set[SecretReference]
|
The required secrets of this stack. |
requires_remote_server: bool
property
If the stack requires a remote ZenServer to run.
This is the case if any code is getting executed remotely. This is the case for both remote orchestrators as well as remote step operators.
Returns:
| Type | Description |
|---|---|
bool
|
If the stack requires a remote ZenServer to run. |
secrets: List[UUID]
property
Secrets to set as environment variables when running on this stack.
Returns:
| Type | Description |
|---|---|
List[UUID]
|
Secrets to set as environment variables when running on this stack. |
setting_classes: Dict[str, Type[BaseSettings]]
property
Setting classes of all components of this stack.
Returns:
| Type | Description |
|---|---|
Dict[str, Type[BaseSettings]]
|
All setting classes and their respective keys. |
step_operator: Optional[BaseStepOperator]
property
The step operator of the stack.
Returns:
| Type | Description |
|---|---|
Optional[BaseStepOperator]
|
The step operator of the stack. |
step_operators: Dict[str, BaseStepOperator]
property
All attached step operators keyed by component name.
Returns:
| Type | Description |
|---|---|
Dict[str, BaseStepOperator]
|
The stack step operators keyed by their names. |
check_local_paths() -> bool
Checks if the stack has local paths.
Returns:
| Type | Description |
|---|---|
bool
|
True if the stack has local paths, False otherwise. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the stack has local paths that do not conform to the convention that all local path must be relative to the local stores directory. |
Source code in src/zenml/stack/stack.py
1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 | |
cleanup_step_run(info: StepRunInfo, step_failed: bool) -> None
Cleans up resources after the step run is finished.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
info
|
StepRunInfo
|
Info about the step that was executed. |
required |
step_failed
|
bool
|
Whether the step failed. |
required |
Source code in src/zenml/stack/stack.py
1553 1554 1555 1556 1557 1558 1559 1560 1561 | |
deploy_pipeline(snapshot: PipelineSnapshotResponse, deployment_name: str, timeout: Optional[int] = None) -> DeploymentResponse
Deploys a pipeline on this stack.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
PipelineSnapshotResponse
|
The pipeline snapshot. |
required |
deployment_name
|
str
|
The name to use for the deployment. |
required |
timeout
|
Optional[int]
|
The maximum time in seconds to wait for the pipeline to be deployed. |
None
|
Returns:
| Type | Description |
|---|---|
DeploymentResponse
|
The deployment response. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the stack does not have a deployer. |
Source code in src/zenml/stack/stack.py
1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 | |
dict() -> Dict[str, str]
Converts the stack into a dictionary.
Returns:
| Type | Description |
|---|---|
Dict[str, str]
|
A dictionary containing the stack components. |
Source code in src/zenml/stack/stack.py
985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 | |
from_components(id: UUID, name: str, components: Dict[StackComponentType, StackComponent], environment: Optional[Dict[str, str]] = None, secrets: Optional[List[UUID]] = None) -> Stack
classmethod
Creates a stack instance from a dict of stack components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
UUID
|
Unique ID of the stack. |
required |
name
|
str
|
The name of the stack. |
required |
components
|
Dict[StackComponentType, StackComponent]
|
The components of the stack. |
required |
environment
|
Optional[Dict[str, str]]
|
Environment variables to set when running on this stack. |
None
|
secrets
|
Optional[List[UUID]]
|
Secrets to set as environment variables when running on this stack. |
None
|
Returns:
| Type | Description |
|---|---|
Stack
|
A stack instance consisting of the given components. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If a required component is missing or a component doesn't inherit from the expected base class. |
Source code in src/zenml/stack/stack.py
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 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 | |
from_components_v2(id: UUID, name: str, components: Mapping[StackComponentType, List[StackComponent]], environment: Optional[Dict[str, str]] = None, secrets: Optional[List[UUID]] = None) -> Stack
classmethod
Creates a stack instance from a dict of stack components.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
id
|
UUID
|
Unique ID of the stack. |
required |
name
|
str
|
The name of the stack. |
required |
components
|
Mapping[StackComponentType, List[StackComponent]]
|
The components of the stack grouped by type. Callers may pass either a single component per type or a list. The first component in a repeatable component list is treated as the default component for that type. |
required |
environment
|
Optional[Dict[str, str]]
|
Environment variables to set when running on this stack. |
None
|
secrets
|
Optional[List[UUID]]
|
Secrets to set as environment variables when running on this stack. |
None
|
Returns:
| Type | Description |
|---|---|
Stack
|
A stack instance consisting of the given components. |
Raises:
| Type | Description |
|---|---|
TypeError
|
If a required component is missing or a component doesn't inherit from the expected base class. |
Source code in src/zenml/stack/stack.py
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 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 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 | |
from_model(stack_model: StackResponse) -> Stack
classmethod
Creates a Stack instance from a StackModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stack_model
|
StackResponse
|
The StackModel to create the Stack from. |
required |
Returns:
| Type | Description |
|---|---|
Stack
|
The created Stack instance. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If a stack component's dependencies cannot be imported. |
Source code in src/zenml/stack/stack.py
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 | |
get_components_by_type(component_type: StackComponentType) -> Sequence[StackComponent]
Returns all components of a given type.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_type
|
StackComponentType
|
The component type to fetch. |
required |
Returns:
| Type | Description |
|---|---|
Sequence[StackComponent]
|
A list of attached components of the given type. |
Source code in src/zenml/stack/stack.py
694 695 696 697 698 699 700 701 702 703 704 705 | |
get_docker_builds(snapshot: PipelineSnapshotBase) -> List[BuildConfiguration]
Gets the Docker builds required for the stack.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
PipelineSnapshotBase
|
The pipeline snapshot for which to get the builds. |
required |
Returns:
| Type | Description |
|---|---|
List[BuildConfiguration]
|
The required Docker builds. |
Source code in src/zenml/stack/stack.py
1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 | |
get_pipeline_run_metadata(run_id: UUID) -> Dict[UUID, Dict[str, MetadataType]]
Get general component-specific metadata for a pipeline run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_id
|
UUID
|
ID of the pipeline run. |
required |
Returns:
| Type | Description |
|---|---|
Dict[UUID, Dict[str, MetadataType]]
|
A dictionary mapping component IDs to the metadata they created. |
Source code in src/zenml/stack/stack.py
1503 1504 1505 1506 1507 1508 1509 1510 1511 1512 1513 1514 1515 1516 1517 1518 1519 1520 1521 1522 1523 1524 1525 1526 1527 | |
get_step_run_metadata(info: StepRunInfo) -> Dict[UUID, Dict[str, MetadataType]]
Get component-specific metadata for a step run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
info
|
StepRunInfo
|
Info about the step that was executed. |
required |
Returns:
| Type | Description |
|---|---|
Dict[UUID, Dict[str, MetadataType]]
|
A dictionary mapping component IDs to the metadata they created. |
Source code in src/zenml/stack/stack.py
1529 1530 1531 1532 1533 1534 1535 1536 1537 1538 1539 1540 1541 1542 1543 1544 1545 1546 1547 1548 1549 1550 1551 | |
prepare_pipeline_submission(snapshot: PipelineSnapshotResponse) -> None
Prepares the stack for a pipeline submission.
This method is called before a pipeline is submitted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
PipelineSnapshotResponse
|
The pipeline snapshot |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If trying to submit a pipeline that requires a remote ZenML server with a local one. |
Source code in src/zenml/stack/stack.py
1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 | |
prepare_step_run(info: StepRunInfo) -> None
Prepares running a step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
info
|
StepRunInfo
|
Info about the step that will be executed. |
required |
Source code in src/zenml/stack/stack.py
1494 1495 1496 1497 1498 1499 1500 1501 | |
requirements(exclude_components: Optional[AbstractSet[StackComponentType]] = None) -> Set[str]
Set of PyPI requirements for the stack.
This method combines the requirements of all stack components (except
the ones specified in exclude_components).
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
exclude_components
|
Optional[AbstractSet[StackComponentType]]
|
Set of component types for which the requirements should not be included in the output. |
None
|
Returns:
| Type | Description |
|---|---|
Set[str]
|
Set of PyPI requirements. |
Source code in src/zenml/stack/stack.py
1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 | |
submit_pipeline(snapshot: PipelineSnapshotResponse, placeholder_run: Optional[PipelineRunResponse] = None) -> None
Submits a pipeline on this stack.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
PipelineSnapshotResponse
|
The pipeline snapshot. |
required |
placeholder_run
|
Optional[PipelineRunResponse]
|
An optional placeholder run for the snapshot. |
None
|
Source code in src/zenml/stack/stack.py
1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 | |
validate(fail_if_secrets_missing: bool = False) -> None
Checks whether the stack configuration is valid.
To check if a stack configuration is valid, the following criteria must
be met:
- the stack must have an image builder if other components require it
- the StackValidator of each stack component has to validate the
stack to make sure all the components are compatible with each other
- the required secrets of all components need to exist
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
fail_if_secrets_missing
|
bool
|
If this is |
False
|
Source code in src/zenml/stack/stack.py
1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 | |
validate_image_builder() -> None
Validates that the stack has an image builder if required.
If the stack requires an image builder, but none is specified, a local image builder will be created and assigned to the stack to ensure backwards compatibility.
Source code in src/zenml/stack/stack.py
1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 | |
validate_log_store() -> None
Validates that the stack has a log store.
Source code in src/zenml/stack/stack.py
1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 | |
Functions
Modules
stack_component
Implementation of the ZenML Stack Component class.
Classes
StackComponent(name: str, id: UUID, config: StackComponentConfig, flavor: str, type: StackComponentType, user: Optional[UUID], created: datetime, updated: datetime, environment: Optional[Dict[str, str]] = None, secrets: Optional[List[UUID]] = None, labels: Optional[Dict[str, Any]] = None, connector_requirements: Optional[ServiceConnectorRequirements] = None, connector: Optional[UUID] = None, connector_resource_id: Optional[str] = None, *args: Any, **kwargs: Any)
Abstract StackComponent class for all components of a ZenML stack.
Initializes a StackComponent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
The name of the component. |
required |
id
|
UUID
|
The unique ID of the component. |
required |
config
|
StackComponentConfig
|
The config of the component. |
required |
flavor
|
str
|
The flavor of the component. |
required |
type
|
StackComponentType
|
The type of the component. |
required |
user
|
Optional[UUID]
|
The ID of the user who created the component. |
required |
created
|
datetime
|
The creation time of the component. |
required |
updated
|
datetime
|
The last update time of the component. |
required |
environment
|
Optional[Dict[str, str]]
|
Environment variables to set when running on this component. |
None
|
secrets
|
Optional[List[UUID]]
|
Secrets to set as environment variables when running on this component. |
None
|
labels
|
Optional[Dict[str, Any]]
|
The labels of the component. |
None
|
connector_requirements
|
Optional[ServiceConnectorRequirements]
|
The requirements for the connector. |
None
|
connector
|
Optional[UUID]
|
The ID of a connector linked to the component. |
None
|
connector_resource_id
|
Optional[str]
|
The custom resource ID to access through the connector. |
None
|
*args
|
Any
|
Additional positional arguments. |
()
|
**kwargs
|
Any
|
Additional keyword arguments. |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If a secret reference is passed as name. |
Source code in src/zenml/stack/stack_component.py
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 | |
apt_packages: List[str]
property
List of APT package requirements for the component.
Returns:
| Type | Description |
|---|---|
List[str]
|
A list of APT package requirements for the component. |
config: StackComponentConfig
property
Returns the configuration of the stack component.
This should be overwritten by any subclasses that define custom configs to return the correct config class.
Returns:
| Type | Description |
|---|---|
StackComponentConfig
|
The configuration of the stack component. |
local_path: Optional[str]
property
Path to a local directory to store persistent information.
This property should only be implemented by components that need to store persistent information in a directory on the local machine and also need that information to be available during pipeline runs.
IMPORTANT: the path returned by this property must always be a path that is relative to the ZenML local store's directory. The local orchestrators rely on this convention to correctly mount the local folders in the containers. This is an example of a valid path:
from zenml.config.global_config import GlobalConfiguration
...
@property
def local_path(self) -> Optional[str]:
return os.path.join(
GlobalConfiguration().local_stores_path,
str(self.uuid),
)
Returns:
| Type | Description |
|---|---|
Optional[str]
|
A path to a local directory used by the component to store |
Optional[str]
|
persistent information. |
log_file: Optional[str]
property
Optional path to a log file for the stack component.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Optional path to a log file for the stack component. |
post_registration_message: Optional[str]
property
Optional message printed after the stack component is registered.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
An optional message. |
requirements: Set[str]
property
Set of PyPI requirements for the component.
Returns:
| Type | Description |
|---|---|
Set[str]
|
A set of PyPI requirements for the component. |
settings_class: Optional[Type[BaseSettings]]
property
Class specifying available settings for this component.
Returns:
| Type | Description |
|---|---|
Optional[Type[BaseSettings]]
|
Optional settings class. |
validator: Optional[StackValidator]
property
The optional validator of the stack component.
This validator will be called each time a stack with the stack
component is initialized. Subclasses should override this property
and return a StackValidator that makes sure they're not included in
any stack that they're not compatible with.
Returns:
| Type | Description |
|---|---|
Optional[StackValidator]
|
An optional |
cleanup() -> None
Cleans up the component after it has been used.
Source code in src/zenml/stack/stack_component.py
794 795 796 | |
cleanup_step_run(info: StepRunInfo, step_failed: bool) -> None
Cleans up resources after the step run is finished.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
info
|
StepRunInfo
|
Info about the step that was executed. |
required |
step_failed
|
bool
|
Whether the step failed. |
required |
Source code in src/zenml/stack/stack_component.py
763 764 765 766 767 768 769 | |
connector_has_expired() -> bool
Checks whether the connector linked to this stack component has expired.
Returns:
| Type | Description |
|---|---|
bool
|
Whether the connector linked to this stack component has expired, or isn't linked to a connector. |
Source code in src/zenml/stack/stack_component.py
562 563 564 565 566 567 568 569 570 571 572 573 574 575 | |
from_model(component_model: ComponentResponse) -> StackComponent
classmethod
Creates a StackComponent from a ComponentModel.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
component_model
|
ComponentResponse
|
The ComponentModel to create the StackComponent |
required |
Returns:
| Type | Description |
|---|---|
StackComponent
|
The created StackComponent. |
Raises:
| Type | Description |
|---|---|
ImportError
|
If the flavor can't be imported. |
Source code in src/zenml/stack/stack_component.py
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 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 | |
get_connector() -> Optional[ServiceConnector]
Returns the connector linked to this stack component.
Returns:
| Type | Description |
|---|---|
Optional[ServiceConnector]
|
The connector linked to this stack component. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the stack component does not specify connector requirements or if the connector linked to the component is not compatible or not found. |
Source code in src/zenml/stack/stack_component.py
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 | |
get_docker_builds(snapshot: PipelineSnapshotBase) -> List[BuildConfiguration]
Gets the Docker builds required for the component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
PipelineSnapshotBase
|
The pipeline snapshot for which to get the builds. |
required |
Returns:
| Type | Description |
|---|---|
List[BuildConfiguration]
|
The required Docker builds. |
Source code in src/zenml/stack/stack_component.py
717 718 719 720 721 722 723 724 725 726 727 728 | |
get_pipeline_run_metadata(run_id: UUID) -> Dict[str, MetadataType]
Get general component-specific metadata for a pipeline run.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
run_id
|
UUID
|
The ID of the pipeline run. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, MetadataType]
|
A dictionary of metadata. |
Source code in src/zenml/stack/stack_component.py
730 731 732 733 734 735 736 737 738 739 740 741 | |
get_settings(container: Union[Step, StepRunResponse, StepRunInfo, PipelineSnapshotBase, PipelineSnapshotResponse, PipelineRunResponse]) -> BaseSettings
Gets settings for this stack component.
This will return None if the stack component doesn't specify a
settings class or the container doesn't contain runtime
options for this component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
container
|
Union[Step, StepRunResponse, StepRunInfo, PipelineSnapshotBase, PipelineSnapshotResponse, PipelineRunResponse]
|
The |
required |
Returns:
| Type | Description |
|---|---|
BaseSettings
|
Settings for this stack component. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the stack component does not specify a settings class. |
Source code in src/zenml/stack/stack_component.py
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 | |
get_step_run_metadata(info: StepRunInfo) -> Dict[str, MetadataType]
Get component- and step-specific metadata after a step ran.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
info
|
StepRunInfo
|
Info about the step that was executed. |
required |
Returns:
| Type | Description |
|---|---|
Dict[str, MetadataType]
|
A dictionary of metadata. |
Source code in src/zenml/stack/stack_component.py
750 751 752 753 754 755 756 757 758 759 760 761 | |
prepare_step_run(info: StepRunInfo) -> None
Prepares running a step.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
info
|
StepRunInfo
|
Info about the step that will be executed. |
required |
Source code in src/zenml/stack/stack_component.py
743 744 745 746 747 748 | |
StackComponentConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseModel, ABC
Base class for all ZenML stack component configs.
Ensures that secret references don't clash with pydantic validation.
StackComponents allow the specification of all their string attributes
using secret references of the form {{secret_name.key}}. This however
is only possible when the stack component does not perform any explicit
validation of this attribute using pydantic validators. If this were
the case, the validation would run on the secret reference and would
fail or in the worst case, modify the secret reference and lead to
unexpected behavior. This method ensures that no attributes that require
custom pydantic validation are set as secret references.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
warn_about_plain_text_secrets
|
bool
|
If true, then warns about using plain-text secrets. |
False
|
**kwargs
|
Any
|
Arguments to initialize this stack component. |
{}
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If an attribute that requires custom pydantic validation
is passed as a secret reference, or if the |
Source code in src/zenml/stack/stack_component.py
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 | |
is_local: bool
property
Checks if this stack component is running locally.
Concrete stack component configuration classes should override this method to return True if the stack component is relying on local resources or capabilities (e.g. local filesystem, local database or other services).
Examples:
- Artifact Stores that store artifacts in the local filesystem
- Orchestrators that are connected to local orchestration runtime services (e.g. local Kubernetes clusters, Docker containers etc).
Returns:
| Type | Description |
|---|---|
bool
|
True if this config is for a local component, False otherwise. |
is_remote: bool
property
Checks if this stack component is running remotely.
Concrete stack component configuration classes should override this method to return True if the stack component is running in a remote location, and it needs to access the ZenML database.
This designation is used to determine if the stack component can be used with a local ZenML database or if it requires a remote ZenML server.
Examples:
- Orchestrators that are running pipelines in the cloud or in a location other than the local host
- Step Operators that are running steps in the cloud or in a location other than the local host
Returns:
| Type | Description |
|---|---|
bool
|
True if this config is for a remote component, False otherwise. |
is_valid: bool
property
Checks if the stack component configurations are valid.
Concrete stack component configuration classes should override this method to return False if the stack component configurations are invalid.
Returns:
| Type | Description |
|---|---|
bool
|
True if the stack component config is valid, False otherwise. |
required_secrets: Set[secret_utils.SecretReference]
property
All required secrets for this stack component.
Returns:
| Type | Description |
|---|---|
Set[SecretReference]
|
The required secrets of this stack component. |
Functions
Modules
stack_validator
Implementation of the ZenML Stack Validator.
Classes
StackValidator(required_components: Optional[AbstractSet[StackComponentType]] = None, custom_validation_function: Optional[Callable[[Stack], Tuple[bool, str]]] = None)
A StackValidator is used to validate a stack configuration.
Each StackComponent can provide a StackValidator to make sure it is
compatible with all components of the stack. The KubeflowOrchestrator
for example will always require the stack to have a container registry
in order to push the docker images that are required to run a pipeline
in Kubeflow Pipelines.
Initializes a StackValidator instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
required_components
|
Optional[AbstractSet[StackComponentType]]
|
Optional set of stack components that must exist in the stack. |
None
|
custom_validation_function
|
Optional[Callable[[Stack], Tuple[bool, str]]]
|
Optional function that returns whether a stack is valid and an error message to show if not valid. |
None
|
Source code in src/zenml/stack/stack_validator.py
38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
validate(stack: Stack) -> None
Validates the given stack.
Checks if the stack contains all the required components and passes the custom validation function of the validator.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
stack
|
Stack
|
The stack to validate. |
required |
Raises:
| Type | Description |
|---|---|
StackValidationError
|
If the stack does not meet all the validation criteria. |
Source code in src/zenml/stack/stack_validator.py
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 | |
Functions
utils
Util functions for handling stacks, components, and flavors.
Classes
Functions
get_flavor_by_name_and_type_from_zen_store(zen_store: BaseZenStore, flavor_name: str, component_type: StackComponentType) -> FlavorResponse
Get a stack component flavor by name and type from a ZenStore.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
zen_store
|
BaseZenStore
|
The ZenStore to query. |
required |
flavor_name
|
str
|
The name of a stack component flavor. |
required |
component_type
|
StackComponentType
|
The type of the stack component. |
required |
Returns:
| Type | Description |
|---|---|
FlavorResponse
|
The flavor model. |
Raises:
| Type | Description |
|---|---|
KeyError
|
If no flavor with the given name and type exists. |
Source code in src/zenml/stack/utils.py
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 | |
validate_stack_component_config(configuration_dict: Dict[str, Any], flavor: Union[FlavorResponse, str], component_type: StackComponentType, zen_store: Optional[BaseZenStore] = None, validate_custom_flavors: bool = True, existing_config: Optional[Dict[str, Any]] = None) -> Optional[StackComponentConfig]
Validate the configuration of a stack component.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
configuration_dict
|
Dict[str, Any]
|
The stack component configuration to validate. |
required |
flavor
|
Union[FlavorResponse, str]
|
The model or name of the flavor of the stack component. |
required |
component_type
|
StackComponentType
|
The type of the stack component. |
required |
zen_store
|
Optional[BaseZenStore]
|
An optional ZenStore in which to look for the flavor. If not provided, the flavor will be fetched via the regular ZenML Client. This is mainly useful for checks running inside the ZenML server. |
None
|
validate_custom_flavors
|
bool
|
When loading custom flavors from the local environment, this flag decides whether the import failures are raised or an empty value is returned. |
True
|
existing_config
|
Optional[Dict[str, Any]]
|
The existing stack component configuration. |
None
|
Returns:
| Type | Description |
|---|---|
Optional[StackComponentConfig]
|
The validated stack component configuration or None, if the |
Optional[StackComponentConfig]
|
flavor is a custom flavor that could not be imported from the local |
Optional[StackComponentConfig]
|
environment and the |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the configuration is invalid. |
ImportError
|
If the flavor class could not be imported. |
ModuleNotFoundError
|
If the flavor class could not be imported. |
Source code in src/zenml/stack/utils.py
29 30 31 32 33 34 35 36 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 104 105 106 | |
warn_if_config_server_mismatch(configuration: StackComponentConfig) -> None
Warn if a component configuration is mismatched with the ZenML server.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
configuration
|
StackComponentConfig
|
The component configuration to check. |
required |
Source code in src/zenml/stack/utils.py
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 | |