Deployers
zenml.deployers
Deployers are stack components responsible for deploying pipelines as HTTP services.
Deploying pipelines is the process of hosting and running machine-learning pipelines as part of a managed web service and providing access to pipeline execution through an API endpoint like HTTP or GRPC. Once deployed, you can send execution requests to the pipeline through the web service's API and receive responses containing the pipeline results or execution status.
Add a deployer to your ZenML stack to be able to provision pipelines deployments that transform your ML pipelines into long-running HTTP services for real-time, on-demand execution instead of traditional batch processing.
When present in a stack, the deployer also acts as a registry for pipeline endpoints that are deployed with ZenML. You can use the deployer to list all deployments that are currently provisioned for online execution or filtered according to a particular snapshot or configuration, or to delete an external deployment managed through ZenML.
Attributes
__all__ = ['BaseDeployer', 'BaseDeployerFlavor', 'BaseDeployerConfig', 'ContainerizedDeployer', 'DockerDeployer', 'DockerDeployerFlavor']
module-attribute
Classes
BaseDeployer(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
, ABC
Base class for all ZenML deployers.
The deployer serves three major purposes:
-
It contains all the stack related configuration attributes required to interact with the remote pipeline deployment tool, service or platform (e.g. hostnames, URLs, references to credentials, other client related configuration parameters).
-
It implements the life-cycle management for deployments, including discovery, creation, deletion and updating.
-
It acts as a ZenML deployment registry, where every pipeline deployment is stored as a database entity through the ZenML Client. This allows the deployer to keep track of all externally running pipeline deployments and to manage their lifecycle.
Source code in src/zenml/stack/stack_component.py
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 |
|
Attributes
config: BaseDeployerConfig
property
Returns the BaseDeployerConfig
config.
Returns:
Type | Description |
---|---|
BaseDeployerConfig
|
The configuration. |
Functions
delete_deployment(deployment_name_or_id: Union[str, UUID], project: Optional[UUID] = None, force: bool = False, timeout: Optional[int] = None) -> None
Deprovision and delete a deployment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment_name_or_id
|
Union[str, UUID]
|
The name or ID of the deployment to delete. |
required |
project
|
Optional[UUID]
|
The project ID of the deployment to deprovision. Required if a name is provided. |
None
|
force
|
bool
|
if True, force the deployment to delete even if it cannot be deprovisioned. |
False
|
timeout
|
Optional[int]
|
The maximum time in seconds to wait for the pipeline deployment to be deprovisioned. If provided, will override the deployer's default timeout. |
None
|
Raises:
Type | Description |
---|---|
DeployerError
|
if an unexpected error occurs. |
Source code in src/zenml/deployers/base_deployer.py
801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 |
|
deprovision_deployment(deployment_name_or_id: Union[str, UUID], project: Optional[UUID] = None, timeout: Optional[int] = None) -> DeploymentResponse
Deprovision a deployment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment_name_or_id
|
Union[str, UUID]
|
The name or ID of the deployment to deprovision. |
required |
project
|
Optional[UUID]
|
The project ID of the deployment to deprovision. Required if a name is provided. |
None
|
timeout
|
Optional[int]
|
The maximum time in seconds to wait for the pipeline deployment to deprovision. If provided, will override the deployer's default timeout. |
None
|
Returns:
Type | Description |
---|---|
DeploymentResponse
|
The deployment. |
Raises:
Type | Description |
---|---|
DeploymentNotFoundError
|
if the deployment is not found or is not managed by this deployer. |
DeploymentDeprovisionError
|
if the deployment deprovision fails. |
DeployerError
|
if an unexpected error occurs. |
Source code in src/zenml/deployers/base_deployer.py
694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 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 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 |
|
do_deprovision_deployment(deployment: DeploymentResponse, timeout: int) -> Optional[DeploymentOperationalState]
abstractmethod
Abstract method to deprovision a deployment.
Concrete deployer subclasses must implement the following functionality in this method:
-
Deprovision the actual deployment infrastructure (e.g., FastAPI server, Kubernetes deployment, cloud function, etc.) based on the information in the deployment response.
-
Return a DeploymentOperationalState representing the operational state of the deleted deployment, or None if the deletion is completed before the call returns.
Note that the deployment infrastructure is not required to be
deleted immediately. The deployer can return a
DeploymentOperationalState with a status of
DeploymentStatus.PENDING, and the base deployer will poll
the deployment infrastructure by calling the
do_get_deployment_state
method until it is deleted or it times out.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to delete. |
required |
timeout
|
int
|
The maximum time in seconds to wait for the pipeline deployment to be deprovisioned. |
required |
Returns:
Type | Description |
---|---|
Optional[DeploymentOperationalState]
|
The DeploymentOperationalState object representing the |
Optional[DeploymentOperationalState]
|
operational state of the deprovisioned deployment, or None |
Optional[DeploymentOperationalState]
|
if the deprovision is completed before the call returns. |
Raises:
Type | Description |
---|---|
DeploymentNotFoundError
|
if no deployment is found corresponding to the provided DeploymentResponse. |
DeploymentDeprovisionError
|
if the deployment deprovision fails. |
DeployerError
|
if an unexpected error occurs. |
Source code in src/zenml/deployers/base_deployer.py
1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 |
|
do_get_deployment_state(deployment: DeploymentResponse) -> DeploymentOperationalState
abstractmethod
Abstract method to get information about a deployment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to get information about. |
required |
Returns:
Type | Description |
---|---|
DeploymentOperationalState
|
The DeploymentOperationalState object representing the |
DeploymentOperationalState
|
updated operational state of the deployment. |
Raises:
Type | Description |
---|---|
DeploymentNotFoundError
|
if no deployment is found corresponding to the provided DeploymentResponse. |
DeployerError
|
if the deployment information cannot be retrieved for any other reason or if an unexpected error occurs. |
Source code in src/zenml/deployers/base_deployer.py
954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 |
|
do_get_deployment_state_logs(deployment: DeploymentResponse, follow: bool = False, tail: Optional[int] = None) -> Generator[str, bool, None]
abstractmethod
Abstract method to get the logs of a deployment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to get the logs of. |
required |
follow
|
bool
|
if True, the logs will be streamed as they are written |
False
|
tail
|
Optional[int]
|
only retrieve the last NUM lines of log output. |
None
|
Yields:
Type | Description |
---|---|
str
|
The logs of the deployment. |
Raises:
Type | Description |
---|---|
DeploymentNotFoundError
|
if no deployment is found corresponding to the provided DeploymentResponse. |
DeploymentLogsNotFoundError
|
if the deployment logs are not found. |
DeployerError
|
if the deployment logs cannot be retrieved for any other reason or if an unexpected error occurs. |
Source code in src/zenml/deployers/base_deployer.py
976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 |
|
do_provision_deployment(deployment: DeploymentResponse, stack: Stack, environment: Dict[str, str], secrets: Dict[str, str], timeout: int) -> DeploymentOperationalState
abstractmethod
Abstract method to deploy a pipeline as an HTTP deployment.
Concrete deployer subclasses must implement the following functionality in this method:
-
Create the actual deployment infrastructure (e.g., FastAPI server, Kubernetes deployment, cloud function, etc.) based on the information in the deployment response, particularly the pipeline snapshot. When determining how to name the external resources, do not rely on the deployment name as being immutable or unique.
-
If the deployment infrastructure is already provisioned, update it to match the information in the deployment response.
-
Return a DeploymentOperationalState representing the operational state of the provisioned deployment.
Note that the deployment infrastructure is not required to be
deployed immediately. The deployer can return a
DeploymentOperationalState with a status of
DeploymentStatus.PENDING, and the base deployer will poll
the deployment infrastructure by calling the
do_get_deployment_state
method until it is ready or it times out.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to deploy as an HTTP deployment. |
required |
stack
|
Stack
|
The stack the pipeline will be deployed on. |
required |
environment
|
Dict[str, str]
|
A dictionary of environment variables to set on the deployment. |
required |
secrets
|
Dict[str, str]
|
A dictionary of secret environment variables to set on the deployment. These secret environment variables should not be exposed as regular environment variables on the deployer. |
required |
timeout
|
int
|
The maximum time in seconds to wait for the pipeline deployment to be provisioned. |
required |
Returns:
Type | Description |
---|---|
DeploymentOperationalState
|
The DeploymentOperationalState object representing the |
DeploymentOperationalState
|
operational state of the provisioned deployment. |
Raises:
Type | Description |
---|---|
DeploymentProvisionError
|
if provisioning the deployment fails. |
DeployerError
|
if an unexpected error occurs. |
Source code in src/zenml/deployers/base_deployer.py
898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 |
|
get_active_deployer() -> BaseDeployer
classmethod
Get the deployer registered in the active stack.
Returns:
Type | Description |
---|---|
BaseDeployer
|
The deployer registered in the active stack. |
Raises:
Type | Description |
---|---|
TypeError
|
if a deployer is not part of the active stack. |
Source code in src/zenml/deployers/base_deployer.py
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 |
|
get_deployment_logs(deployment_name_or_id: Union[str, UUID], project: Optional[UUID] = None, follow: bool = False, tail: Optional[int] = None) -> Generator[str, bool, None]
Get the logs of a deployment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment_name_or_id
|
Union[str, UUID]
|
The name or ID of the deployment to get the logs of. |
required |
project
|
Optional[UUID]
|
The project ID of the deployment to get the logs of. Required if a name is provided. |
None
|
follow
|
bool
|
if True, the logs will be streamed as they are written. |
False
|
tail
|
Optional[int]
|
only retrieve the last NUM lines of log output. |
None
|
Returns:
Type | Description |
---|---|
None
|
A generator that yields the logs of the deployment. |
Raises:
Type | Description |
---|---|
DeploymentNotFoundError
|
if the deployment is not found. |
DeployerError
|
if an unexpected error occurs. |
Source code in src/zenml/deployers/base_deployer.py
847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 |
|
provision_deployment(snapshot: PipelineSnapshotResponse, stack: Stack, deployment_name_or_id: Union[str, UUID], replace: bool = True, timeout: Optional[int] = None) -> DeploymentResponse
Provision a deployment.
The provision_deployment method is the main entry point for provisioning deployments using the deployer. It is used to deploy a pipeline snapshot as an HTTP deployment, or update an existing deployment instance with the same name. The method returns a DeploymentResponse object that is a representation of the external deployment instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
snapshot
|
PipelineSnapshotResponse
|
The pipeline snapshot to deploy as an HTTP deployment. |
required |
stack
|
Stack
|
The stack the pipeline will be deployed on. |
required |
deployment_name_or_id
|
Union[str, UUID]
|
Unique name or ID for the deployment. This name must be unique at the project level. |
required |
replace
|
bool
|
If True, it will update in-place any existing pipeline deployment instance with the same name. If False, and the pipeline deployment instance already exists, it will raise a DeploymentAlreadyExistsError. |
True
|
timeout
|
Optional[int]
|
The maximum time in seconds to wait for the pipeline deployment to be provisioned. If provided, will override the deployer's default timeout. |
None
|
Raises:
Type | Description |
---|---|
DeploymentAlreadyExistsError
|
if the deployment already exists and replace is False. |
DeploymentProvisionError
|
if the deployment fails. |
DeploymentSnapshotMismatchError
|
if the pipeline snapshot was not created for this deployer. |
DeploymentNotFoundError
|
if the deployment with the given ID is not found. |
DeployerError
|
if an unexpected error occurs. |
Returns:
Type | Description |
---|---|
DeploymentResponse
|
The DeploymentResponse object representing the provisioned |
DeploymentResponse
|
deployment. |
Source code in src/zenml/deployers/base_deployer.py
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 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 |
|
refresh_deployment(deployment_name_or_id: Union[str, UUID], project: Optional[UUID] = None) -> DeploymentResponse
Refresh the status of a deployment by name or ID.
Call this to refresh the operational state of a deployment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment_name_or_id
|
Union[str, UUID]
|
The name or ID of the deployment to get. |
required |
project
|
Optional[UUID]
|
The project ID of the deployment to get. Required if a name is provided. |
None
|
Returns:
Type | Description |
---|---|
DeploymentResponse
|
The deployment. |
Raises:
Type | Description |
---|---|
DeploymentNotFoundError
|
if the deployment is not found. |
DeployerError
|
if an unexpected error occurs. |
Source code in src/zenml/deployers/base_deployer.py
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 689 690 691 692 |
|
BaseDeployerConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: StackComponentConfig
Base config for all deployers.
Source code in src/zenml/stack/stack_component.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
BaseDeployerFlavor
Bases: Flavor
Base class for deployer flavors.
Attributes
config_class: Type[BaseDeployerConfig]
property
Returns BaseDeployerConfig
config class.
Returns:
Type | Description |
---|---|
Type[BaseDeployerConfig]
|
The config class. |
implementation_class: Type[BaseDeployer]
abstractmethod
property
The class that implements the deployer.
type: StackComponentType
property
ContainerizedDeployer(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: BaseDeployer
, ABC
Base class for all containerized deployers.
Source code in src/zenml/stack/stack_component.py
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 |
|
Attributes
requirements: Set[str]
property
Set of PyPI requirements for the deployer.
Returns:
Type | Description |
---|---|
Set[str]
|
A set of PyPI requirements for the deployer. |
Functions
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/deployers/containerized_deployer.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
get_image(snapshot: PipelineSnapshotResponse) -> str
staticmethod
Get the docker image used to deploy a pipeline snapshot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
snapshot
|
PipelineSnapshotResponse
|
The pipeline snapshot to get the image for. |
required |
Returns:
Type | Description |
---|---|
str
|
The docker image used to deploy the pipeline snapshot. |
Raises:
Type | Description |
---|---|
RuntimeError
|
if the pipeline snapshot does not have a build or if the deployer image is not in the build. |
Source code in src/zenml/deployers/containerized_deployer.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
DockerDeployer(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: ContainerizedDeployer
Deployer responsible for deploying pipelines locally using Docker.
Source code in src/zenml/stack/stack_component.py
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 |
|
Attributes
config: DockerDeployerConfig
property
Returns the DockerDeployerConfig
config.
Returns:
Type | Description |
---|---|
DockerDeployerConfig
|
The configuration. |
docker_client: DockerClient
property
Initialize and/or return the docker client.
Returns:
Type | Description |
---|---|
DockerClient
|
The docker client. |
settings_class: Optional[Type[BaseSettings]]
property
Settings class for the Docker deployer.
Returns:
Type | Description |
---|---|
Optional[Type[BaseSettings]]
|
The settings class. |
validator: Optional[StackValidator]
property
Ensures there is an image builder in the stack.
Returns:
Type | Description |
---|---|
Optional[StackValidator]
|
A |
Functions
do_deprovision_deployment(deployment: DeploymentResponse, timeout: int) -> Optional[DeploymentOperationalState]
Deprovision a docker deployment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to deprovision. |
required |
timeout
|
int
|
The maximum time in seconds to wait for the pipeline deployment to be deprovisioned. |
required |
Returns:
Type | Description |
---|---|
Optional[DeploymentOperationalState]
|
The DeploymentOperationalState object representing the |
Optional[DeploymentOperationalState]
|
operational state of the deleted deployment, or None if the |
Optional[DeploymentOperationalState]
|
deletion is completed before the call returns. |
Raises:
Type | Description |
---|---|
DeploymentNotFoundError
|
if no deployment is found corresponding to the provided DeploymentResponse. |
DeploymentDeprovisionError
|
if the deployment deprovision fails. |
Source code in src/zenml/deployers/docker/docker_deployer.py
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 |
|
do_get_deployment_state(deployment: DeploymentResponse) -> DeploymentOperationalState
Get information about a docker deployment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to get information about. |
required |
Returns:
Type | Description |
---|---|
DeploymentOperationalState
|
The DeploymentOperationalState object representing the |
DeploymentOperationalState
|
updated operational state of the deployment. |
Raises:
Type | Description |
---|---|
DeploymentNotFoundError
|
if no deployment is found corresponding to the provided DeploymentResponse. |
Source code in src/zenml/deployers/docker/docker_deployer.py
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 |
|
do_get_deployment_state_logs(deployment: DeploymentResponse, follow: bool = False, tail: Optional[int] = None) -> Generator[str, bool, None]
Get the logs of a Docker deployment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to get the logs of. |
required |
follow
|
bool
|
if True, the logs will be streamed as they are written |
False
|
tail
|
Optional[int]
|
only retrieve the last NUM lines of log output. |
None
|
Yields:
Type | Description |
---|---|
str
|
The logs of the deployment. |
Raises:
Type | Description |
---|---|
DeploymentNotFoundError
|
if no deployment is found corresponding to the provided DeploymentResponse. |
DeploymentLogsNotFoundError
|
if the deployment logs are not found. |
DeployerError
|
if the deployment logs cannot be retrieved for any other reason or if an unexpected error occurs. |
Source code in src/zenml/deployers/docker/docker_deployer.py
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 |
|
do_provision_deployment(deployment: DeploymentResponse, stack: Stack, environment: Dict[str, str], secrets: Dict[str, str], timeout: int) -> DeploymentOperationalState
Deploy a pipeline as a Docker container.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to run as a Docker container. |
required |
stack
|
Stack
|
The stack the pipeline will be deployed on. |
required |
environment
|
Dict[str, str]
|
A dictionary of environment variables to set on the deployment. |
required |
secrets
|
Dict[str, str]
|
A dictionary of secret environment variables to set on the deployment. These secret environment variables should not be exposed as regular environment variables on the deployer. |
required |
timeout
|
int
|
The maximum time in seconds to wait for the pipeline deployment to be provisioned. |
required |
Returns:
Type | Description |
---|---|
DeploymentOperationalState
|
The DeploymentOperationalState object representing the |
DeploymentOperationalState
|
operational state of the provisioned deployment. |
Raises:
Type | Description |
---|---|
DeploymentProvisionError
|
if provisioning the deployment fails. |
Source code in src/zenml/deployers/docker/docker_deployer.py
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 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 |
|
DockerDeployerFlavor
Bases: BaseDeployerFlavor
Flavor for the Docker deployer.
Attributes
config_class: Type[BaseDeployerConfig]
property
Config class for the base deployer flavor.
Returns:
Type | Description |
---|---|
Type[BaseDeployerConfig]
|
The config class. |
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[DockerDeployer]
property
Implementation class for this flavor.
Returns:
Type | Description |
---|---|
Type[DockerDeployer]
|
Implementation class for this flavor. |
logo_url: str
property
A url to represent the flavor in the dashboard.
Returns:
Type | Description |
---|---|
str
|
The flavor logo. |
name: str
property
Name of the deployer flavor.
Returns:
Type | Description |
---|---|
str
|
Name of the deployer flavor. |
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. |
Modules
base_deployer
Base class for all ZenML deployers.
Classes
BaseDeployer(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
, ABC
Base class for all ZenML deployers.
The deployer serves three major purposes:
-
It contains all the stack related configuration attributes required to interact with the remote pipeline deployment tool, service or platform (e.g. hostnames, URLs, references to credentials, other client related configuration parameters).
-
It implements the life-cycle management for deployments, including discovery, creation, deletion and updating.
-
It acts as a ZenML deployment registry, where every pipeline deployment is stored as a database entity through the ZenML Client. This allows the deployer to keep track of all externally running pipeline deployments and to manage their lifecycle.
Source code in src/zenml/stack/stack_component.py
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 |
|
config: BaseDeployerConfig
property
Returns the BaseDeployerConfig
config.
Returns:
Type | Description |
---|---|
BaseDeployerConfig
|
The configuration. |
delete_deployment(deployment_name_or_id: Union[str, UUID], project: Optional[UUID] = None, force: bool = False, timeout: Optional[int] = None) -> None
Deprovision and delete a deployment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment_name_or_id
|
Union[str, UUID]
|
The name or ID of the deployment to delete. |
required |
project
|
Optional[UUID]
|
The project ID of the deployment to deprovision. Required if a name is provided. |
None
|
force
|
bool
|
if True, force the deployment to delete even if it cannot be deprovisioned. |
False
|
timeout
|
Optional[int]
|
The maximum time in seconds to wait for the pipeline deployment to be deprovisioned. If provided, will override the deployer's default timeout. |
None
|
Raises:
Type | Description |
---|---|
DeployerError
|
if an unexpected error occurs. |
Source code in src/zenml/deployers/base_deployer.py
801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 |
|
deprovision_deployment(deployment_name_or_id: Union[str, UUID], project: Optional[UUID] = None, timeout: Optional[int] = None) -> DeploymentResponse
Deprovision a deployment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment_name_or_id
|
Union[str, UUID]
|
The name or ID of the deployment to deprovision. |
required |
project
|
Optional[UUID]
|
The project ID of the deployment to deprovision. Required if a name is provided. |
None
|
timeout
|
Optional[int]
|
The maximum time in seconds to wait for the pipeline deployment to deprovision. If provided, will override the deployer's default timeout. |
None
|
Returns:
Type | Description |
---|---|
DeploymentResponse
|
The deployment. |
Raises:
Type | Description |
---|---|
DeploymentNotFoundError
|
if the deployment is not found or is not managed by this deployer. |
DeploymentDeprovisionError
|
if the deployment deprovision fails. |
DeployerError
|
if an unexpected error occurs. |
Source code in src/zenml/deployers/base_deployer.py
694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 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 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 |
|
do_deprovision_deployment(deployment: DeploymentResponse, timeout: int) -> Optional[DeploymentOperationalState]
abstractmethod
Abstract method to deprovision a deployment.
Concrete deployer subclasses must implement the following functionality in this method:
-
Deprovision the actual deployment infrastructure (e.g., FastAPI server, Kubernetes deployment, cloud function, etc.) based on the information in the deployment response.
-
Return a DeploymentOperationalState representing the operational state of the deleted deployment, or None if the deletion is completed before the call returns.
Note that the deployment infrastructure is not required to be
deleted immediately. The deployer can return a
DeploymentOperationalState with a status of
DeploymentStatus.PENDING, and the base deployer will poll
the deployment infrastructure by calling the
do_get_deployment_state
method until it is deleted or it times out.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to delete. |
required |
timeout
|
int
|
The maximum time in seconds to wait for the pipeline deployment to be deprovisioned. |
required |
Returns:
Type | Description |
---|---|
Optional[DeploymentOperationalState]
|
The DeploymentOperationalState object representing the |
Optional[DeploymentOperationalState]
|
operational state of the deprovisioned deployment, or None |
Optional[DeploymentOperationalState]
|
if the deprovision is completed before the call returns. |
Raises:
Type | Description |
---|---|
DeploymentNotFoundError
|
if no deployment is found corresponding to the provided DeploymentResponse. |
DeploymentDeprovisionError
|
if the deployment deprovision fails. |
DeployerError
|
if an unexpected error occurs. |
Source code in src/zenml/deployers/base_deployer.py
1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 |
|
do_get_deployment_state(deployment: DeploymentResponse) -> DeploymentOperationalState
abstractmethod
Abstract method to get information about a deployment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to get information about. |
required |
Returns:
Type | Description |
---|---|
DeploymentOperationalState
|
The DeploymentOperationalState object representing the |
DeploymentOperationalState
|
updated operational state of the deployment. |
Raises:
Type | Description |
---|---|
DeploymentNotFoundError
|
if no deployment is found corresponding to the provided DeploymentResponse. |
DeployerError
|
if the deployment information cannot be retrieved for any other reason or if an unexpected error occurs. |
Source code in src/zenml/deployers/base_deployer.py
954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 |
|
do_get_deployment_state_logs(deployment: DeploymentResponse, follow: bool = False, tail: Optional[int] = None) -> Generator[str, bool, None]
abstractmethod
Abstract method to get the logs of a deployment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to get the logs of. |
required |
follow
|
bool
|
if True, the logs will be streamed as they are written |
False
|
tail
|
Optional[int]
|
only retrieve the last NUM lines of log output. |
None
|
Yields:
Type | Description |
---|---|
str
|
The logs of the deployment. |
Raises:
Type | Description |
---|---|
DeploymentNotFoundError
|
if no deployment is found corresponding to the provided DeploymentResponse. |
DeploymentLogsNotFoundError
|
if the deployment logs are not found. |
DeployerError
|
if the deployment logs cannot be retrieved for any other reason or if an unexpected error occurs. |
Source code in src/zenml/deployers/base_deployer.py
976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 |
|
do_provision_deployment(deployment: DeploymentResponse, stack: Stack, environment: Dict[str, str], secrets: Dict[str, str], timeout: int) -> DeploymentOperationalState
abstractmethod
Abstract method to deploy a pipeline as an HTTP deployment.
Concrete deployer subclasses must implement the following functionality in this method:
-
Create the actual deployment infrastructure (e.g., FastAPI server, Kubernetes deployment, cloud function, etc.) based on the information in the deployment response, particularly the pipeline snapshot. When determining how to name the external resources, do not rely on the deployment name as being immutable or unique.
-
If the deployment infrastructure is already provisioned, update it to match the information in the deployment response.
-
Return a DeploymentOperationalState representing the operational state of the provisioned deployment.
Note that the deployment infrastructure is not required to be
deployed immediately. The deployer can return a
DeploymentOperationalState with a status of
DeploymentStatus.PENDING, and the base deployer will poll
the deployment infrastructure by calling the
do_get_deployment_state
method until it is ready or it times out.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to deploy as an HTTP deployment. |
required |
stack
|
Stack
|
The stack the pipeline will be deployed on. |
required |
environment
|
Dict[str, str]
|
A dictionary of environment variables to set on the deployment. |
required |
secrets
|
Dict[str, str]
|
A dictionary of secret environment variables to set on the deployment. These secret environment variables should not be exposed as regular environment variables on the deployer. |
required |
timeout
|
int
|
The maximum time in seconds to wait for the pipeline deployment to be provisioned. |
required |
Returns:
Type | Description |
---|---|
DeploymentOperationalState
|
The DeploymentOperationalState object representing the |
DeploymentOperationalState
|
operational state of the provisioned deployment. |
Raises:
Type | Description |
---|---|
DeploymentProvisionError
|
if provisioning the deployment fails. |
DeployerError
|
if an unexpected error occurs. |
Source code in src/zenml/deployers/base_deployer.py
898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 |
|
get_active_deployer() -> BaseDeployer
classmethod
Get the deployer registered in the active stack.
Returns:
Type | Description |
---|---|
BaseDeployer
|
The deployer registered in the active stack. |
Raises:
Type | Description |
---|---|
TypeError
|
if a deployer is not part of the active stack. |
Source code in src/zenml/deployers/base_deployer.py
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 |
|
get_deployment_logs(deployment_name_or_id: Union[str, UUID], project: Optional[UUID] = None, follow: bool = False, tail: Optional[int] = None) -> Generator[str, bool, None]
Get the logs of a deployment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment_name_or_id
|
Union[str, UUID]
|
The name or ID of the deployment to get the logs of. |
required |
project
|
Optional[UUID]
|
The project ID of the deployment to get the logs of. Required if a name is provided. |
None
|
follow
|
bool
|
if True, the logs will be streamed as they are written. |
False
|
tail
|
Optional[int]
|
only retrieve the last NUM lines of log output. |
None
|
Returns:
Type | Description |
---|---|
None
|
A generator that yields the logs of the deployment. |
Raises:
Type | Description |
---|---|
DeploymentNotFoundError
|
if the deployment is not found. |
DeployerError
|
if an unexpected error occurs. |
Source code in src/zenml/deployers/base_deployer.py
847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 |
|
provision_deployment(snapshot: PipelineSnapshotResponse, stack: Stack, deployment_name_or_id: Union[str, UUID], replace: bool = True, timeout: Optional[int] = None) -> DeploymentResponse
Provision a deployment.
The provision_deployment method is the main entry point for provisioning deployments using the deployer. It is used to deploy a pipeline snapshot as an HTTP deployment, or update an existing deployment instance with the same name. The method returns a DeploymentResponse object that is a representation of the external deployment instance.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
snapshot
|
PipelineSnapshotResponse
|
The pipeline snapshot to deploy as an HTTP deployment. |
required |
stack
|
Stack
|
The stack the pipeline will be deployed on. |
required |
deployment_name_or_id
|
Union[str, UUID]
|
Unique name or ID for the deployment. This name must be unique at the project level. |
required |
replace
|
bool
|
If True, it will update in-place any existing pipeline deployment instance with the same name. If False, and the pipeline deployment instance already exists, it will raise a DeploymentAlreadyExistsError. |
True
|
timeout
|
Optional[int]
|
The maximum time in seconds to wait for the pipeline deployment to be provisioned. If provided, will override the deployer's default timeout. |
None
|
Raises:
Type | Description |
---|---|
DeploymentAlreadyExistsError
|
if the deployment already exists and replace is False. |
DeploymentProvisionError
|
if the deployment fails. |
DeploymentSnapshotMismatchError
|
if the pipeline snapshot was not created for this deployer. |
DeploymentNotFoundError
|
if the deployment with the given ID is not found. |
DeployerError
|
if an unexpected error occurs. |
Returns:
Type | Description |
---|---|
DeploymentResponse
|
The DeploymentResponse object representing the provisioned |
DeploymentResponse
|
deployment. |
Source code in src/zenml/deployers/base_deployer.py
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 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 |
|
refresh_deployment(deployment_name_or_id: Union[str, UUID], project: Optional[UUID] = None) -> DeploymentResponse
Refresh the status of a deployment by name or ID.
Call this to refresh the operational state of a deployment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment_name_or_id
|
Union[str, UUID]
|
The name or ID of the deployment to get. |
required |
project
|
Optional[UUID]
|
The project ID of the deployment to get. Required if a name is provided. |
None
|
Returns:
Type | Description |
---|---|
DeploymentResponse
|
The deployment. |
Raises:
Type | Description |
---|---|
DeploymentNotFoundError
|
if the deployment is not found. |
DeployerError
|
if an unexpected error occurs. |
Source code in src/zenml/deployers/base_deployer.py
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 689 690 691 692 |
|
BaseDeployerConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: StackComponentConfig
Base config for all deployers.
Source code in src/zenml/stack/stack_component.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
BaseDeployerFlavor
Bases: Flavor
Base class for deployer flavors.
config_class: Type[BaseDeployerConfig]
property
Returns BaseDeployerConfig
config class.
Returns:
Type | Description |
---|---|
Type[BaseDeployerConfig]
|
The config class. |
implementation_class: Type[BaseDeployer]
abstractmethod
property
The class that implements the deployer.
type: StackComponentType
property
BaseDeployerSettings(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseSettings
Base settings for all deployers.
Source code in src/zenml/config/secret_reference_mixin.py
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 |
|
Functions
containerized_deployer
Base class for all ZenML deployers.
Classes
ContainerizedDeployer(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: BaseDeployer
, ABC
Base class for all containerized deployers.
Source code in src/zenml/stack/stack_component.py
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 |
|
requirements: Set[str]
property
Set of PyPI requirements for the deployer.
Returns:
Type | Description |
---|---|
Set[str]
|
A set of PyPI requirements for the deployer. |
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/deployers/containerized_deployer.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 |
|
get_image(snapshot: PipelineSnapshotResponse) -> str
staticmethod
Get the docker image used to deploy a pipeline snapshot.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
snapshot
|
PipelineSnapshotResponse
|
The pipeline snapshot to get the image for. |
required |
Returns:
Type | Description |
---|---|
str
|
The docker image used to deploy the pipeline snapshot. |
Raises:
Type | Description |
---|---|
RuntimeError
|
if the pipeline snapshot does not have a build or if the deployer image is not in the build. |
Source code in src/zenml/deployers/containerized_deployer.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 |
|
Functions
docker
Implementation for the local Docker deployer.
Modules
docker_deployer
Implementation of the ZenML Docker deployer.
DockerDeployer(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: ContainerizedDeployer
Deployer responsible for deploying pipelines locally using Docker.
Source code in src/zenml/stack/stack_component.py
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 |
|
config: DockerDeployerConfig
property
Returns the DockerDeployerConfig
config.
Returns:
Type | Description |
---|---|
DockerDeployerConfig
|
The configuration. |
docker_client: DockerClient
property
Initialize and/or return the docker client.
Returns:
Type | Description |
---|---|
DockerClient
|
The docker client. |
settings_class: Optional[Type[BaseSettings]]
property
Settings class for the Docker deployer.
Returns:
Type | Description |
---|---|
Optional[Type[BaseSettings]]
|
The settings class. |
validator: Optional[StackValidator]
property
Ensures there is an image builder in the stack.
Returns:
Type | Description |
---|---|
Optional[StackValidator]
|
A |
do_deprovision_deployment(deployment: DeploymentResponse, timeout: int) -> Optional[DeploymentOperationalState]
Deprovision a docker deployment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to deprovision. |
required |
timeout
|
int
|
The maximum time in seconds to wait for the pipeline deployment to be deprovisioned. |
required |
Returns:
Type | Description |
---|---|
Optional[DeploymentOperationalState]
|
The DeploymentOperationalState object representing the |
Optional[DeploymentOperationalState]
|
operational state of the deleted deployment, or None if the |
Optional[DeploymentOperationalState]
|
deletion is completed before the call returns. |
Raises:
Type | Description |
---|---|
DeploymentNotFoundError
|
if no deployment is found corresponding to the provided DeploymentResponse. |
DeploymentDeprovisionError
|
if the deployment deprovision fails. |
Source code in src/zenml/deployers/docker/docker_deployer.py
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 |
|
do_get_deployment_state(deployment: DeploymentResponse) -> DeploymentOperationalState
Get information about a docker deployment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to get information about. |
required |
Returns:
Type | Description |
---|---|
DeploymentOperationalState
|
The DeploymentOperationalState object representing the |
DeploymentOperationalState
|
updated operational state of the deployment. |
Raises:
Type | Description |
---|---|
DeploymentNotFoundError
|
if no deployment is found corresponding to the provided DeploymentResponse. |
Source code in src/zenml/deployers/docker/docker_deployer.py
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 |
|
do_get_deployment_state_logs(deployment: DeploymentResponse, follow: bool = False, tail: Optional[int] = None) -> Generator[str, bool, None]
Get the logs of a Docker deployment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to get the logs of. |
required |
follow
|
bool
|
if True, the logs will be streamed as they are written |
False
|
tail
|
Optional[int]
|
only retrieve the last NUM lines of log output. |
None
|
Yields:
Type | Description |
---|---|
str
|
The logs of the deployment. |
Raises:
Type | Description |
---|---|
DeploymentNotFoundError
|
if no deployment is found corresponding to the provided DeploymentResponse. |
DeploymentLogsNotFoundError
|
if the deployment logs are not found. |
DeployerError
|
if the deployment logs cannot be retrieved for any other reason or if an unexpected error occurs. |
Source code in src/zenml/deployers/docker/docker_deployer.py
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 |
|
do_provision_deployment(deployment: DeploymentResponse, stack: Stack, environment: Dict[str, str], secrets: Dict[str, str], timeout: int) -> DeploymentOperationalState
Deploy a pipeline as a Docker container.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to run as a Docker container. |
required |
stack
|
Stack
|
The stack the pipeline will be deployed on. |
required |
environment
|
Dict[str, str]
|
A dictionary of environment variables to set on the deployment. |
required |
secrets
|
Dict[str, str]
|
A dictionary of secret environment variables to set on the deployment. These secret environment variables should not be exposed as regular environment variables on the deployer. |
required |
timeout
|
int
|
The maximum time in seconds to wait for the pipeline deployment to be provisioned. |
required |
Returns:
Type | Description |
---|---|
DeploymentOperationalState
|
The DeploymentOperationalState object representing the |
DeploymentOperationalState
|
operational state of the provisioned deployment. |
Raises:
Type | Description |
---|---|
DeploymentProvisionError
|
if provisioning the deployment fails. |
Source code in src/zenml/deployers/docker/docker_deployer.py
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 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 |
|
DockerDeployerConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseDeployerConfig
, DockerDeployerSettings
Docker deployer config.
Source code in src/zenml/stack/stack_component.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 |
|
is_local: bool
property
Checks if this stack component is running locally.
Returns:
Type | Description |
---|---|
bool
|
True if this config is for a local component, False otherwise. |
DockerDeployerFlavor
Bases: BaseDeployerFlavor
Flavor for the Docker deployer.
config_class: Type[BaseDeployerConfig]
property
Config class for the base deployer flavor.
Returns:
Type | Description |
---|---|
Type[BaseDeployerConfig]
|
The config class. |
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[DockerDeployer]
property
Implementation class for this flavor.
Returns:
Type | Description |
---|---|
Type[DockerDeployer]
|
Implementation class for this flavor. |
logo_url: str
property
A url to represent the flavor in the dashboard.
Returns:
Type | Description |
---|---|
str
|
The flavor logo. |
name: str
property
Name of the deployer flavor.
Returns:
Type | Description |
---|---|
str
|
Name of the deployer flavor. |
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. |
DockerDeployerSettings(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseDeployerSettings
Docker deployer settings.
Attributes:
Name | Type | Description |
---|---|---|
port |
Optional[int]
|
The port to expose the deployment on. |
allocate_port_if_busy |
bool
|
If True, allocate a free port if the configured port is busy. |
port_range |
Tuple[int, int]
|
The range of ports to search for a free port. |
run_args |
Dict[str, Any]
|
Arguments to pass to the |
Source code in src/zenml/config/secret_reference_mixin.py
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 |
|
DockerDeploymentMetadata
Bases: BaseModel
Metadata for a Docker deployment.
from_container(container: Container) -> DockerDeploymentMetadata
classmethod
Create a DockerDeploymentMetadata from a docker container.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
container
|
Container
|
The docker container to get the metadata for. |
required |
Returns:
Type | Description |
---|---|
DockerDeploymentMetadata
|
The metadata for the docker container. |
Source code in src/zenml/deployers/docker/docker_deployer.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 |
|
from_deployment(deployment: DeploymentResponse) -> DockerDeploymentMetadata
classmethod
Create a DockerDeploymentMetadata from a deployment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to get the metadata for. |
required |
Returns:
Type | Description |
---|---|
DockerDeploymentMetadata
|
The metadata for the deployment. |
Source code in src/zenml/deployers/docker/docker_deployer.py
122 123 124 125 126 127 128 129 130 131 132 133 134 |
|
exceptions
Base class for all ZenML deployers.
Classes
DeployerError
Bases: Exception
Base class for deployer errors.
DeploymentAlreadyExistsError(message: Optional[str] = None, url: Optional[str] = None)
Bases: EntityExistsError
, DeployerError
Error raised when a deployment already exists.
Source code in src/zenml/exceptions.py
22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 |
|
DeploymentDeployerMismatchError
Bases: DeployerError
Error raised when a deployment is not managed by this deployer.
DeploymentDeprovisionError
Bases: DeployerError
Error raised when a deployment deprovisioning fails.
DeploymentHTTPError
Bases: DeployerError
Error raised when an HTTP request to a deployment fails.
DeploymentInvalidParametersError
Bases: DeployerError
Error raised when the parameters for a deployment are invalid.
DeploymentLogsNotFoundError
Bases: KeyError
, DeployerError
Error raised when pipeline logs are not found.
DeploymentNotFoundError
Bases: KeyError
, DeployerError
Error raised when a deployment is not found.
DeploymentProvisionError
Bases: DeployerError
Error raised when a deployment provisioning fails.
DeploymentSnapshotMismatchError
Bases: DeployerError
Error raised when a deployment snapshot does not match the current deployer.
DeploymentTimeoutError
Bases: DeployerError
Error raised when a deployment provisioning or deprovisioning times out.
Functions
utils
ZenML deployers utilities.
Classes
Functions
get_deployment_input_schema(deployment: DeploymentResponse) -> Dict[str, Any]
Get the schema for a deployment's input parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment for which to get the schema. |
required |
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
The schema for the deployment's input parameters. |
Raises:
Type | Description |
---|---|
RuntimeError
|
If the deployment has no associated input schema. |
Source code in src/zenml/deployers/utils.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 |
|
get_deployment_invocation_example(deployment: DeploymentResponse) -> Dict[str, Any]
Generate an example invocation command for a deployment.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment for which to generate an example invocation. |
required |
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
A dictionary containing the example invocation parameters. |
Source code in src/zenml/deployers/utils.py
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 |
|
get_deployment_output_schema(deployment: DeploymentResponse) -> Dict[str, Any]
Get the schema for a deployment's output parameters.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment for which to get the schema. |
required |
Returns:
Type | Description |
---|---|
Dict[str, Any]
|
The schema for the deployment's output parameters. |
Raises:
Type | Description |
---|---|
RuntimeError
|
If the deployment has no associated output schema. |
Source code in src/zenml/deployers/utils.py
61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
invoke_deployment(deployment_name_or_id: Union[str, UUID], project: Optional[UUID] = None, timeout: int = 300, **kwargs: Any) -> Any
Call a deployment and return the result.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
deployment_name_or_id
|
Union[str, UUID]
|
The name or ID of the deployment to call. |
required |
project
|
Optional[UUID]
|
The project ID of the deployment to call. |
None
|
timeout
|
int
|
The timeout for the HTTP request to the deployment. |
300
|
**kwargs
|
Any
|
Keyword arguments to pass to the deployment. |
{}
|
Returns:
Type | Description |
---|---|
Any
|
The response from the deployment, parsed as JSON if possible, |
Any
|
otherwise returned as text. |
Raises:
Type | Description |
---|---|
DeploymentNotFoundError
|
If the deployment is not found. |
DeploymentProvisionError
|
If the deployment is not running or has no URL. |
DeploymentHTTPError
|
If the HTTP request to the endpoint fails. |
Source code in src/zenml/deployers/utils.py
124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 |
|