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', 'DockerDeployerConfig', 'DockerDeployerFlavor', 'DockerDeployerSettings', 'LocalDeployer', 'LocalDeployerConfig', 'LocalDeployerFlavor', 'LocalDeployerSettings']
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
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 | |
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
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
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
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 | |
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
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 | |
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
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 | |
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
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 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 | |
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 | |
Attributes
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.
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. |
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 | |
LocalDeployer(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
Deployer that runs deployments as local daemon processes.
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: LocalDeployerConfig
property
Returns the LocalDeployerConfig config.
Returns:
| Type | Description |
|---|---|
LocalDeployerConfig
|
The configuration. |
settings_class: Optional[Type[BaseSettings]]
property
Settings class for the local deployer.
Returns:
| Type | Description |
|---|---|
Optional[Type[BaseSettings]]
|
The settings class. |
Functions
do_deprovision_deployment(deployment: DeploymentResponse, timeout: int) -> Optional[DeploymentOperationalState]
Deprovision a local daemon deployment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to stop. |
required |
timeout
|
int
|
Unused for local daemon stop. |
required |
Returns:
| Type | Description |
|---|---|
Optional[DeploymentOperationalState]
|
None, indicating immediate deletion completed. |
Raises:
| Type | Description |
|---|---|
DeploymentNotFoundError
|
If the daemon is not found. |
DeploymentDeprovisionError
|
If stopping fails. |
Source code in src/zenml/deployers/local/local_deployer.py
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 | |
do_get_deployment_state(deployment: DeploymentResponse) -> DeploymentOperationalState
Get information about a local daemon deployment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to inspect. |
required |
Returns:
| Type | Description |
|---|---|
DeploymentOperationalState
|
Operational state of the deployment. |
Source code in src/zenml/deployers/local/local_deployer.py
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 | |
do_get_deployment_state_logs(deployment: DeploymentResponse, follow: bool = False, tail: Optional[int] = None) -> Generator[str, bool, None]
Read logs from the local daemon log file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to read logs for. |
required |
follow
|
bool
|
Stream logs if True. |
False
|
tail
|
Optional[int]
|
Return only last N lines if set. |
None
|
Yields:
| Type | Description |
|---|---|
str
|
Log lines. |
Raises:
| Type | Description |
|---|---|
DeploymentLogsNotFoundError
|
If the log file is missing. |
DeployerError
|
For unexpected errors. |
Source code in src/zenml/deployers/local/local_deployer.py
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 | |
do_provision_deployment(deployment: DeploymentResponse, stack: Stack, environment: Dict[str, str], secrets: Dict[str, str], timeout: int) -> DeploymentOperationalState
Provision a local daemon deployment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to run. |
required |
stack
|
Stack
|
The active stack (unused by local deployer). |
required |
environment
|
Dict[str, str]
|
Environment variables for the app. |
required |
secrets
|
Dict[str, str]
|
Secret environment variables for the app. |
required |
timeout
|
int
|
Unused for immediate daemonization. |
required |
Returns:
| Type | Description |
|---|---|
DeploymentOperationalState
|
Operational state of the provisioned deployment. |
Raises:
| Type | Description |
|---|---|
DeploymentProvisionError
|
If the daemon cannot be started. |
Source code in src/zenml/deployers/local/local_deployer.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | |
LocalDeployerConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseDeployerConfig, LocalDeployerSettings
Local 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 | |
Attributes
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. |
LocalDeployerFlavor
Bases: BaseDeployerFlavor
Flavor for the Local daemon deployer.
Attributes
config_class: Type[BaseDeployerConfig]
property
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[LocalDeployer]
property
Implementation class for this flavor.
Returns:
| Type | Description |
|---|---|
Type[LocalDeployer]
|
The implementation class. |
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
|
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. |
LocalDeployerSettings(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseDeployerSettings
Local deployer settings.
Attributes:
| Name | Type | Description |
|---|---|---|
port |
Optional[int]
|
Preferred port to run on. |
allocate_port_if_busy |
bool
|
Whether to allocate a free port if busy. |
port_range |
Tuple[int, int]
|
Range to scan when allocating a free port. |
address |
str
|
Address to bind the server to. |
blocking |
bool
|
Whether to run the deployment in the current process instead of running it as a daemon process. |
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 | |
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 containerized 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
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 | |
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
42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 | |
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
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 | |
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
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 | |
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
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 | |
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
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 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 | |
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
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 | |
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
120 121 122 123 124 125 126 127 128 129 130 131 132 | |
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
local
Local daemon deployer implementation.
Modules
local_deployer
Implementation of the ZenML Local deployer.
LocalDeployer(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
Deployer that runs deployments as local daemon processes.
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: LocalDeployerConfig
property
Returns the LocalDeployerConfig config.
Returns:
| Type | Description |
|---|---|
LocalDeployerConfig
|
The configuration. |
settings_class: Optional[Type[BaseSettings]]
property
Settings class for the local deployer.
Returns:
| Type | Description |
|---|---|
Optional[Type[BaseSettings]]
|
The settings class. |
do_deprovision_deployment(deployment: DeploymentResponse, timeout: int) -> Optional[DeploymentOperationalState]
Deprovision a local daemon deployment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to stop. |
required |
timeout
|
int
|
Unused for local daemon stop. |
required |
Returns:
| Type | Description |
|---|---|
Optional[DeploymentOperationalState]
|
None, indicating immediate deletion completed. |
Raises:
| Type | Description |
|---|---|
DeploymentNotFoundError
|
If the daemon is not found. |
DeploymentDeprovisionError
|
If stopping fails. |
Source code in src/zenml/deployers/local/local_deployer.py
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 | |
do_get_deployment_state(deployment: DeploymentResponse) -> DeploymentOperationalState
Get information about a local daemon deployment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to inspect. |
required |
Returns:
| Type | Description |
|---|---|
DeploymentOperationalState
|
Operational state of the deployment. |
Source code in src/zenml/deployers/local/local_deployer.py
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 | |
do_get_deployment_state_logs(deployment: DeploymentResponse, follow: bool = False, tail: Optional[int] = None) -> Generator[str, bool, None]
Read logs from the local daemon log file.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to read logs for. |
required |
follow
|
bool
|
Stream logs if True. |
False
|
tail
|
Optional[int]
|
Return only last N lines if set. |
None
|
Yields:
| Type | Description |
|---|---|
str
|
Log lines. |
Raises:
| Type | Description |
|---|---|
DeploymentLogsNotFoundError
|
If the log file is missing. |
DeployerError
|
For unexpected errors. |
Source code in src/zenml/deployers/local/local_deployer.py
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 | |
do_provision_deployment(deployment: DeploymentResponse, stack: Stack, environment: Dict[str, str], secrets: Dict[str, str], timeout: int) -> DeploymentOperationalState
Provision a local daemon deployment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to run. |
required |
stack
|
Stack
|
The active stack (unused by local deployer). |
required |
environment
|
Dict[str, str]
|
Environment variables for the app. |
required |
secrets
|
Dict[str, str]
|
Secret environment variables for the app. |
required |
timeout
|
int
|
Unused for immediate daemonization. |
required |
Returns:
| Type | Description |
|---|---|
DeploymentOperationalState
|
Operational state of the provisioned deployment. |
Raises:
| Type | Description |
|---|---|
DeploymentProvisionError
|
If the daemon cannot be started. |
Source code in src/zenml/deployers/local/local_deployer.py
197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 | |
LocalDeployerConfig(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseDeployerConfig, LocalDeployerSettings
Local 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. |
LocalDeployerFlavor
Bases: BaseDeployerFlavor
Flavor for the Local daemon deployer.
config_class: Type[BaseDeployerConfig]
property
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[LocalDeployer]
property
Implementation class for this flavor.
Returns:
| Type | Description |
|---|---|
Type[LocalDeployer]
|
The implementation class. |
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
|
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. |
LocalDeployerSettings(warn_about_plain_text_secrets: bool = False, **kwargs: Any)
Bases: BaseDeployerSettings
Local deployer settings.
Attributes:
| Name | Type | Description |
|---|---|---|
port |
Optional[int]
|
Preferred port to run on. |
allocate_port_if_busy |
bool
|
Whether to allocate a free port if busy. |
port_range |
Tuple[int, int]
|
Range to scan when allocating a free port. |
address |
str
|
Address to bind the server to. |
blocking |
bool
|
Whether to run the deployment in the current process instead of running it as a daemon process. |
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 | |
LocalDeploymentMetadata
Bases: BaseModel
Metadata for a local daemon deployment.
Attributes:
| Name | Type | Description |
|---|---|---|
pid |
Optional[int]
|
PID of the daemon process. |
port |
Optional[int]
|
TCP port the app listens on. |
address |
Optional[str]
|
IP address the app binds to. |
log_file |
Optional[str]
|
Path to log file. |
from_deployment(deployment: DeploymentResponse) -> LocalDeploymentMetadata
classmethod
Build metadata object from a deployment record.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment
|
DeploymentResponse
|
The deployment to read metadata from. |
required |
Returns:
| Type | Description |
|---|---|
LocalDeploymentMetadata
|
Parsed local deployment metadata. |
Source code in src/zenml/deployers/local/local_deployer.py
90 91 92 93 94 95 96 97 98 99 100 101 102 | |
server
Deployment server web application implementation.
Classes
BaseAppExtension
Bases: ABC
Abstract base for app extensions.
Extensions provide advanced framework-specific capabilities like: - Custom authentication/authorization - Observability (logging, tracing, metrics) - Complex routers with framework-specific features - OpenAPI customizations - Advanced middleware patterns
Subclasses must implement install() to modify the app.
install(app_runner: BaseDeploymentAppRunner) -> None
abstractmethod
Install extension into the application.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_runner
|
BaseDeploymentAppRunner
|
The deployment app runner instance being used to build and run the web application. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If installation fails. |
Source code in src/zenml/deployers/server/extensions.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
BaseDeploymentAppRunner(deployment: Union[str, UUID, DeploymentResponse], **kwargs: Any)
Bases: ABC
Base class for deployment app runners.
This class is responsible for building and running the ASGI compatible web application (e.g. FastAPI, Django, Flask, Falcon, Quart, BlackSheep, etc.) and the associated deployment service for the pipeline deployment. It also acts as a adaptation layer between the REST API interface and deployment service to preserve the following separation of concerns between the two components:
- the ASGI application is responsible for handling the HTTP requests and responses to the user
- the deployment service is responsible for handling the business logic
The deployment service code should be free of any ASGI application specific code and concerns and vice-versa. This allows them to be independently extendable and easily swappable.
Implementations of this class must use the deployment and its settings to configure and run the web application (e.g. FastAPI, Flask, Falcon, Quart, BlackSheep, etc.) that wraps the deployment service according to the user's specifications, particularly concerning the following:
- exposed endpoints (URL paths, methods, input/output models)
- middleware (CORS, authentication, logging, etc.)
- error handling
- lifecycle management (startup, shutdown)
- custom hooks (startup, shutdown)
- app configuration (workers, host, port, thread pool size, etc.)
The following methods must be provided by implementations of this class:
- flavor: Return the flavor class associated with this deployment application runner.
- build: Build and return an ASGI compatible web application (i.e. an
ASGIApplication object that can be run with uvicorn). Most Python ASGI
frameworks provide an ASGIApplication object. This method also has to
register all the endpoints, middleware and extensions that are either
required internally or supplied to it. It must also configure the
startupandshutdownmethods to be run as part of the ASGI application's lifespan or overload the_run_asgi_appmethod to handle the startup and shutdown as an alternative. - _get_dashboard_endpoints: Gets the dashboard endpoints specs from the deployment configuration. Only required if the dashboard files path is set in the deployment configuration and the app runner supports serving a dashboard alongside the API.
- _build_cors_middleware: Builds the CORS middleware from the CORS settings in the deployment configuration.
Initialize the deployment app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment
|
Union[str, UUID, DeploymentResponse]
|
The deployment to run. |
required |
**kwargs
|
Any
|
Additional keyword arguments for the deployment app runner. |
{}
|
Source code in src/zenml/deployers/server/app.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
asgi_app: ASGIApplication
property
Get the ASGI application.
Returns:
| Type | Description |
|---|---|
ASGIApplication
|
The ASGI application. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the ASGI application is not built yet. |
flavor: BaseDeploymentAppRunnerFlavor
abstractmethod
property
Return the flavor associated with this deployment application runner.
Returns:
| Type | Description |
|---|---|
BaseDeploymentAppRunnerFlavor
|
The flavor associated with this deployment application runner. |
build(middlewares: List[MiddlewareSpec], endpoints: List[EndpointSpec], extensions: List[AppExtensionSpec]) -> ASGIApplication
abstractmethod
Build the ASGI compatible web application.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
middlewares
|
List[MiddlewareSpec]
|
The middleware to register. |
required |
endpoints
|
List[EndpointSpec]
|
The endpoints to register. |
required |
extensions
|
List[AppExtensionSpec]
|
The extensions to install. |
required |
Returns:
| Type | Description |
|---|---|
ASGIApplication
|
The ASGI compatible web application. |
Source code in src/zenml/deployers/server/app.py
882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 | |
dashboard_files_path() -> Optional[str]
Get the absolute path of the dashboard files directory.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Absolute path. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the dashboard files path is absolute. |
RuntimeError
|
If the dashboard files path does not exist. |
Source code in src/zenml/deployers/server/app.py
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 | |
install_extensions(*extension_specs: AppExtensionSpec) -> None
Install the given app extensions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
extension_specs
|
AppExtensionSpec
|
The app extensions to install. |
()
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the extension is not a subclass of BaseAppExtension. |
RuntimeError
|
If the extension cannot be initialized. |
Source code in src/zenml/deployers/server/app.py
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 | |
load_app_runner(deployment: Union[str, UUID, DeploymentResponse]) -> BaseDeploymentAppRunner
classmethod
Load the app runner for the deployment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment
|
Union[str, UUID, DeploymentResponse]
|
The deployment to load the app runner for. |
required |
Returns:
| Type | Description |
|---|---|
BaseDeploymentAppRunner
|
The app runner for the deployment. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the deployment app runner cannot be loaded. |
Source code in src/zenml/deployers/server/app.py
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 | |
load_deployment(deployment: Union[str, UUID, DeploymentResponse]) -> DeploymentResponse
classmethod
Load the deployment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment
|
Union[str, UUID, DeploymentResponse]
|
The deployment to load. |
required |
Returns:
| Type | Description |
|---|---|
DeploymentResponse
|
The deployment. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the deployment or its snapshot cannot be loaded. |
Source code in src/zenml/deployers/server/app.py
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 | |
load_deployment_service() -> BasePipelineDeploymentService
Load the service for the deployment.
Returns:
| Type | Description |
|---|---|
BasePipelineDeploymentService
|
The deployment service for the deployment. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the deployment service cannot be loaded. |
Source code in src/zenml/deployers/server/app.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | |
register_endpoints(*endpoint_specs: EndpointSpec) -> None
Register the given endpoints.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint_specs
|
EndpointSpec
|
The endpoints to register. |
()
|
Source code in src/zenml/deployers/server/app.py
645 646 647 648 649 650 651 652 653 654 | |
register_middlewares(*middleware_specs: MiddlewareSpec) -> None
Register the given middleware.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
middleware_specs
|
MiddlewareSpec
|
The middleware to register. |
()
|
Source code in src/zenml/deployers/server/app.py
656 657 658 659 660 661 662 663 664 665 | |
run() -> None
Run the deployment app.
Source code in src/zenml/deployers/server/app.py
875 876 877 878 879 880 | |
shutdown() -> None
Shutdown the deployment app.
Raises:
| Type | Description |
|---|---|
Exception
|
If the service cleanup fails. |
Source code in src/zenml/deployers/server/app.py
748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 | |
startup() -> None
Startup the deployment app.
Raises:
| Type | Description |
|---|---|
Exception
|
If the service initialization fails. |
Source code in src/zenml/deployers/server/app.py
695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 | |
EndpointAdapter
Bases: ABC
Converts framework-agnostic endpoint specs to framework endpoints.
register_endpoint(app_runner: BaseDeploymentAppRunner, spec: EndpointSpec) -> None
abstractmethod
Register an endpoint on the app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_runner
|
BaseDeploymentAppRunner
|
Deployment app runner instance. |
required |
spec
|
EndpointSpec
|
Framework-agnostic endpoint specification. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If endpoint registration fails. |
Source code in src/zenml/deployers/server/adapters.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
resolve_endpoint_handler(app_runner: BaseDeploymentAppRunner, endpoint_spec: EndpointSpec) -> Any
Resolve an endpoint handler from its specification.
This method handles three types of handlers as defined in EndpointSpec: 1. Direct endpoint function - returned as-is 2. Endpoint builder class - instantiated with app_runner, app, and init_kwargs 3. Endpoint builder function - called with app_runner, app, and init_kwargs to obtain the actual endpoint
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_runner
|
BaseDeploymentAppRunner
|
Deployment app runner instance. |
required |
endpoint_spec
|
EndpointSpec
|
The endpoint specification to resolve the handler from. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The actual endpoint callable ready to be registered. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If handler is not callable or builder returns non-callable. |
RuntimeError
|
If handler resolution fails. |
Source code in src/zenml/deployers/server/adapters.py
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 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 | |
MiddlewareAdapter
Bases: ABC
Converts framework-agnostic middleware specs to framework middleware.
register_middleware(app_runner: BaseDeploymentAppRunner, spec: MiddlewareSpec) -> None
abstractmethod
Register middleware on the app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_runner
|
BaseDeploymentAppRunner
|
Deployment app runner instance. |
required |
spec
|
MiddlewareSpec
|
Framework-agnostic middleware specification. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If middleware scope requires missing parameters. |
RuntimeError
|
If middleware registration fails. |
Source code in src/zenml/deployers/server/adapters.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
resolve_middleware_handler(app_runner: BaseDeploymentAppRunner, middleware_spec: MiddlewareSpec) -> Any
Resolve a middleware handler from its specification.
This method handles three types of middleware as defined in MiddlewareSpec: 1. Middleware callable class 2. Middleware callable function 3. Native middleware object
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_runner
|
BaseDeploymentAppRunner
|
Deployment app runner instance. |
required |
middleware_spec
|
MiddlewareSpec
|
The middleware specification to resolve the handler from. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The actual middleware callable ready to be registered. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If middleware is not callable or builder returns non-callable. |
Source code in src/zenml/deployers/server/adapters.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
Modules
adapters
Framework adapter interfaces.
EndpointAdapter
Bases: ABC
Converts framework-agnostic endpoint specs to framework endpoints.
register_endpoint(app_runner: BaseDeploymentAppRunner, spec: EndpointSpec) -> None
abstractmethod
Register an endpoint on the app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_runner
|
BaseDeploymentAppRunner
|
Deployment app runner instance. |
required |
spec
|
EndpointSpec
|
Framework-agnostic endpoint specification. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If endpoint registration fails. |
Source code in src/zenml/deployers/server/adapters.py
134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
resolve_endpoint_handler(app_runner: BaseDeploymentAppRunner, endpoint_spec: EndpointSpec) -> Any
Resolve an endpoint handler from its specification.
This method handles three types of handlers as defined in EndpointSpec: 1. Direct endpoint function - returned as-is 2. Endpoint builder class - instantiated with app_runner, app, and init_kwargs 3. Endpoint builder function - called with app_runner, app, and init_kwargs to obtain the actual endpoint
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_runner
|
BaseDeploymentAppRunner
|
Deployment app runner instance. |
required |
endpoint_spec
|
EndpointSpec
|
The endpoint specification to resolve the handler from. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The actual endpoint callable ready to be registered. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If handler is not callable or builder returns non-callable. |
RuntimeError
|
If handler resolution fails. |
Source code in src/zenml/deployers/server/adapters.py
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 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 | |
MiddlewareAdapter
Bases: ABC
Converts framework-agnostic middleware specs to framework middleware.
register_middleware(app_runner: BaseDeploymentAppRunner, spec: MiddlewareSpec) -> None
abstractmethod
Register middleware on the app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_runner
|
BaseDeploymentAppRunner
|
Deployment app runner instance. |
required |
spec
|
MiddlewareSpec
|
Framework-agnostic middleware specification. |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If middleware scope requires missing parameters. |
RuntimeError
|
If middleware registration fails. |
Source code in src/zenml/deployers/server/adapters.py
225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 | |
resolve_middleware_handler(app_runner: BaseDeploymentAppRunner, middleware_spec: MiddlewareSpec) -> Any
Resolve a middleware handler from its specification.
This method handles three types of middleware as defined in MiddlewareSpec: 1. Middleware callable class 2. Middleware callable function 3. Native middleware object
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_runner
|
BaseDeploymentAppRunner
|
Deployment app runner instance. |
required |
middleware_spec
|
MiddlewareSpec
|
The middleware specification to resolve the handler from. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The actual middleware callable ready to be registered. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If middleware is not callable or builder returns non-callable. |
Source code in src/zenml/deployers/server/adapters.py
154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 | |
app
Base deployment app runner.
BaseDeploymentAppRunner(deployment: Union[str, UUID, DeploymentResponse], **kwargs: Any)
Bases: ABC
Base class for deployment app runners.
This class is responsible for building and running the ASGI compatible web application (e.g. FastAPI, Django, Flask, Falcon, Quart, BlackSheep, etc.) and the associated deployment service for the pipeline deployment. It also acts as a adaptation layer between the REST API interface and deployment service to preserve the following separation of concerns between the two components:
- the ASGI application is responsible for handling the HTTP requests and responses to the user
- the deployment service is responsible for handling the business logic
The deployment service code should be free of any ASGI application specific code and concerns and vice-versa. This allows them to be independently extendable and easily swappable.
Implementations of this class must use the deployment and its settings to configure and run the web application (e.g. FastAPI, Flask, Falcon, Quart, BlackSheep, etc.) that wraps the deployment service according to the user's specifications, particularly concerning the following:
- exposed endpoints (URL paths, methods, input/output models)
- middleware (CORS, authentication, logging, etc.)
- error handling
- lifecycle management (startup, shutdown)
- custom hooks (startup, shutdown)
- app configuration (workers, host, port, thread pool size, etc.)
The following methods must be provided by implementations of this class:
- flavor: Return the flavor class associated with this deployment application runner.
- build: Build and return an ASGI compatible web application (i.e. an
ASGIApplication object that can be run with uvicorn). Most Python ASGI
frameworks provide an ASGIApplication object. This method also has to
register all the endpoints, middleware and extensions that are either
required internally or supplied to it. It must also configure the
startupandshutdownmethods to be run as part of the ASGI application's lifespan or overload the_run_asgi_appmethod to handle the startup and shutdown as an alternative. - _get_dashboard_endpoints: Gets the dashboard endpoints specs from the deployment configuration. Only required if the dashboard files path is set in the deployment configuration and the app runner supports serving a dashboard alongside the API.
- _build_cors_middleware: Builds the CORS middleware from the CORS settings in the deployment configuration.
Initialize the deployment app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment
|
Union[str, UUID, DeploymentResponse]
|
The deployment to run. |
required |
**kwargs
|
Any
|
Additional keyword arguments for the deployment app runner. |
{}
|
Source code in src/zenml/deployers/server/app.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
asgi_app: ASGIApplication
property
Get the ASGI application.
Returns:
| Type | Description |
|---|---|
ASGIApplication
|
The ASGI application. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the ASGI application is not built yet. |
flavor: BaseDeploymentAppRunnerFlavor
abstractmethod
property
Return the flavor associated with this deployment application runner.
Returns:
| Type | Description |
|---|---|
BaseDeploymentAppRunnerFlavor
|
The flavor associated with this deployment application runner. |
build(middlewares: List[MiddlewareSpec], endpoints: List[EndpointSpec], extensions: List[AppExtensionSpec]) -> ASGIApplication
abstractmethod
Build the ASGI compatible web application.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
middlewares
|
List[MiddlewareSpec]
|
The middleware to register. |
required |
endpoints
|
List[EndpointSpec]
|
The endpoints to register. |
required |
extensions
|
List[AppExtensionSpec]
|
The extensions to install. |
required |
Returns:
| Type | Description |
|---|---|
ASGIApplication
|
The ASGI compatible web application. |
Source code in src/zenml/deployers/server/app.py
882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 | |
dashboard_files_path() -> Optional[str]
Get the absolute path of the dashboard files directory.
Returns:
| Type | Description |
|---|---|
Optional[str]
|
Absolute path. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the dashboard files path is absolute. |
RuntimeError
|
If the dashboard files path does not exist. |
Source code in src/zenml/deployers/server/app.py
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 | |
install_extensions(*extension_specs: AppExtensionSpec) -> None
Install the given app extensions.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
extension_specs
|
AppExtensionSpec
|
The app extensions to install. |
()
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If the extension is not a subclass of BaseAppExtension. |
RuntimeError
|
If the extension cannot be initialized. |
Source code in src/zenml/deployers/server/app.py
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 | |
load_app_runner(deployment: Union[str, UUID, DeploymentResponse]) -> BaseDeploymentAppRunner
classmethod
Load the app runner for the deployment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment
|
Union[str, UUID, DeploymentResponse]
|
The deployment to load the app runner for. |
required |
Returns:
| Type | Description |
|---|---|
BaseDeploymentAppRunner
|
The app runner for the deployment. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the deployment app runner cannot be loaded. |
Source code in src/zenml/deployers/server/app.py
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 | |
load_deployment(deployment: Union[str, UUID, DeploymentResponse]) -> DeploymentResponse
classmethod
Load the deployment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment
|
Union[str, UUID, DeploymentResponse]
|
The deployment to load. |
required |
Returns:
| Type | Description |
|---|---|
DeploymentResponse
|
The deployment. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the deployment or its snapshot cannot be loaded. |
Source code in src/zenml/deployers/server/app.py
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 | |
load_deployment_service() -> BasePipelineDeploymentService
Load the service for the deployment.
Returns:
| Type | Description |
|---|---|
BasePipelineDeploymentService
|
The deployment service for the deployment. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the deployment service cannot be loaded. |
Source code in src/zenml/deployers/server/app.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 | |
register_endpoints(*endpoint_specs: EndpointSpec) -> None
Register the given endpoints.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
endpoint_specs
|
EndpointSpec
|
The endpoints to register. |
()
|
Source code in src/zenml/deployers/server/app.py
645 646 647 648 649 650 651 652 653 654 | |
register_middlewares(*middleware_specs: MiddlewareSpec) -> None
Register the given middleware.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
middleware_specs
|
MiddlewareSpec
|
The middleware to register. |
()
|
Source code in src/zenml/deployers/server/app.py
656 657 658 659 660 661 662 663 664 665 | |
run() -> None
Run the deployment app.
Source code in src/zenml/deployers/server/app.py
875 876 877 878 879 880 | |
shutdown() -> None
Shutdown the deployment app.
Raises:
| Type | Description |
|---|---|
Exception
|
If the service cleanup fails. |
Source code in src/zenml/deployers/server/app.py
748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 | |
startup() -> None
Startup the deployment app.
Raises:
| Type | Description |
|---|---|
Exception
|
If the service initialization fails. |
Source code in src/zenml/deployers/server/app.py
695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 | |
BaseDeploymentAppRunnerFlavor
Bases: ABC
Base class for deployment app runner flavors.
BaseDeploymentAppRunner implementations must also provide implementations for this class. The flavor class implementation should be kept separate from the implementation class to allow it to be imported without importing the implementation class and all its dependencies.
implementation_class: Type[BaseDeploymentAppRunner]
abstractmethod
property
The class that implements the deployment app runner.
Returns:
| Type | Description |
|---|---|
Type[BaseDeploymentAppRunner]
|
The implementation class for the deployment app runner. |
name: str
abstractmethod
property
The name of the deployment app runner flavor.
Returns:
| Type | Description |
|---|---|
str
|
The name of the deployment app runner flavor. |
requirements: List[str]
property
The software requirements for the deployment app runner.
Returns:
| Type | Description |
|---|---|
List[str]
|
The software requirements for the deployment app runner. |
load_app_runner_flavor(settings: DeploymentSettings) -> BaseDeploymentAppRunnerFlavor
classmethod
Load the app runner flavor for the deployment settings.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
settings
|
DeploymentSettings
|
The deployment settings to load the app runner flavor for. |
required |
Returns:
| Type | Description |
|---|---|
BaseDeploymentAppRunnerFlavor
|
The app runner flavor for the deployment. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the deployment app runner flavor cannot be loaded. |
Source code in src/zenml/deployers/server/app.py
937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 | |
start_deployment_app(deployment_id: UUID, pid_file: Optional[str] = None, log_file: Optional[str] = None, host: Optional[str] = None, port: Optional[int] = None) -> None
Start the deployment app.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment_id
|
UUID
|
The deployment ID. |
required |
pid_file
|
Optional[str]
|
The PID file to use for the deployment. |
None
|
log_file
|
Optional[str]
|
The log file to use for the deployment. |
None
|
host
|
Optional[str]
|
The custom host to use for the deployment. |
None
|
port
|
Optional[int]
|
The custom port to use for the deployment. |
None
|
Source code in src/zenml/deployers/server/app.py
1001 1002 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 | |
entrypoint_configuration
ZenML Pipeline Deployment Entrypoint Configuration.
DeploymentEntrypointConfiguration(arguments: List[str])
Bases: BaseEntrypointConfiguration
Entrypoint configuration for ZenML Pipeline Deployment.
This entrypoint configuration handles the startup and configuration of the ZenML pipeline deployment FastAPI application.
Source code in src/zenml/entrypoints/base_entrypoint_configuration.py
60 61 62 63 64 65 66 | |
get_entrypoint_arguments(**kwargs: Any) -> List[str]
classmethod
Gets arguments for the deployment entrypoint command.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
**kwargs
|
Any
|
Keyword arguments containing deployment configuration |
{}
|
Returns:
| Type | Description |
|---|---|
List[str]
|
List of command-line arguments |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the deployment ID is not a valid UUID. |
Source code in src/zenml/deployers/server/entrypoint_configuration.py
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 | |
get_entrypoint_options() -> Set[str]
classmethod
Gets all options required for the deployment entrypoint.
Returns:
| Type | Description |
|---|---|
Set[str]
|
Set of required option names |
Source code in src/zenml/deployers/server/entrypoint_configuration.py
41 42 43 44 45 46 47 48 49 50 | |
load_deployment() -> DeploymentResponse
Loads the deployment.
Returns:
| Type | Description |
|---|---|
DeploymentResponse
|
The deployment. |
Source code in src/zenml/deployers/server/entrypoint_configuration.py
85 86 87 88 89 90 91 92 93 94 95 | |
run() -> None
Run the ZenML pipeline deployment application.
This method starts the FastAPI server with the configured parameters and the specified pipeline deployment.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the deployment has no snapshot. |
Source code in src/zenml/deployers/server/entrypoint_configuration.py
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 | |
extensions
Base app extension interface.
BaseAppExtension
Bases: ABC
Abstract base for app extensions.
Extensions provide advanced framework-specific capabilities like: - Custom authentication/authorization - Observability (logging, tracing, metrics) - Complex routers with framework-specific features - OpenAPI customizations - Advanced middleware patterns
Subclasses must implement install() to modify the app.
install(app_runner: BaseDeploymentAppRunner) -> None
abstractmethod
Install extension into the application.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_runner
|
BaseDeploymentAppRunner
|
The deployment app runner instance being used to build and run the web application. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If installation fails. |
Source code in src/zenml/deployers/server/extensions.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 | |
fastapi
FastAPI implementation of the deployment app factory and adapters.
FastAPIDeploymentAppRunnerFlavor
Bases: BaseDeploymentAppRunnerFlavor
FastAPI deployment app runner flavor.
implementation_class: Type[BaseDeploymentAppRunner]
property
The class that implements the deployment app runner.
Returns:
| Type | Description |
|---|---|
Type[BaseDeploymentAppRunner]
|
The implementation class for the deployment app runner. |
name: str
property
The name of the deployment app runner flavor.
Returns:
| Type | Description |
|---|---|
str
|
The name of the deployment app runner flavor. |
requirements: List[str]
property
The software requirements for the deployment app runner.
Returns:
| Type | Description |
|---|---|
List[str]
|
The software requirements for the deployment app runner. |
adapters
FastAPI adapter implementations.
FastAPIEndpointAdapter
Bases: EndpointAdapter
FastAPI implementation of endpoint adapter.
register_endpoint(app_runner: BaseDeploymentAppRunner, spec: EndpointSpec) -> None
Register endpoint with FastAPI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_runner
|
BaseDeploymentAppRunner
|
Deployment app runner instance. |
required |
spec
|
EndpointSpec
|
Framework-agnostic endpoint specification. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the adapter is not used with a FastAPI application. |
Source code in src/zenml/deployers/server/fastapi/adapters.py
80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 | |
FastAPIMiddlewareAdapter
Bases: MiddlewareAdapter
FastAPI implementation of middleware adapter.
We support two types of native middleware:
- A middleware class like that receives the ASGIApp object in the constructor and implements the call method to dispatch the middleware, e.g.:
from starlette.types import ASGIApp, Receive, Scope, Send
class MyMiddleware:
def __init__(self, app: ASGIApp) -> None:
self.app = app
async def __call__(self, scope: Scope, receive: Receive, send: Send) -> None:
...
await self.app(scope, receive, send)
- A middleware function that takes request and next callable and returns a response, e.g.:
from fastapi import Request, Response
async def my_middleware(request: Request, call_next: Callable[[Request], Awaitable[Response]]) -> Response:
...
return await call_next(request)
register_middleware(app_runner: BaseDeploymentAppRunner, spec: MiddlewareSpec) -> None
Register middleware with FastAPI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_runner
|
BaseDeploymentAppRunner
|
Deployment app runner instance. |
required |
spec
|
MiddlewareSpec
|
Framework-agnostic middleware specification. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the adapter is not used with a FastAPI application. |
Source code in src/zenml/deployers/server/fastapi/adapters.py
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 | |
app
FastAPI application for running ZenML pipeline deployments.
FastAPIDeploymentAppRunner(deployment: Union[str, UUID, DeploymentResponse], **kwargs: Any)
Bases: BaseDeploymentAppRunner
FastAPI deployment app runner.
Source code in src/zenml/deployers/server/app.py
126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 | |
flavor: BaseDeploymentAppRunnerFlavor
property
Return the flavor associated with this deployment application runner.
Returns:
| Type | Description |
|---|---|
BaseDeploymentAppRunnerFlavor
|
The flavor associated with this deployment application runner. |
build(middlewares: List[MiddlewareSpec], endpoints: List[EndpointSpec], extensions: List[AppExtensionSpec]) -> ASGIApplication
Build the FastAPI app for the deployment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
middlewares
|
List[MiddlewareSpec]
|
The middleware to register. |
required |
endpoints
|
List[EndpointSpec]
|
The endpoints to register. |
required |
extensions
|
List[AppExtensionSpec]
|
The extensions to install. |
required |
Returns:
| Type | Description |
|---|---|
ASGIApplication
|
The configured FastAPI application instance. |
Source code in src/zenml/deployers/server/fastapi/app.py
248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 | |
error_handler(request: Request, exc: ValueError) -> JSONResponse
FastAPI error handler.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
Request
|
The request. |
required |
exc
|
ValueError
|
The exception. |
required |
Returns:
| Type | Description |
|---|---|
JSONResponse
|
The error response. |
Source code in src/zenml/deployers/server/fastapi/app.py
235 236 237 238 239 240 241 242 243 244 245 246 | |
lifespan(app: FastAPI) -> AsyncGenerator[None, None]
async
Manage the deployment application lifespan.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app
|
FastAPI
|
The FastAPI application instance being deployed. |
required |
Yields:
| Name | Type | Description |
|---|---|---|
None |
AsyncGenerator[None, None]
|
Control is handed back to FastAPI once initialization completes. |
Source code in src/zenml/deployers/server/fastapi/app.py
309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 | |
models
FastAPI application models.
AppInfo
Bases: BaseModel
App info model.
BaseDeploymentInvocationRequest
Bases: BaseModel
Base pipeline invoke request model.
BaseDeploymentInvocationResponse
Bases: BaseModel
Base pipeline invoke response model.
DeploymentInfo
Bases: BaseModel
Deployment info model.
DeploymentInvocationResponseMetadata
Bases: BaseModel
Pipeline invoke response metadata model.
ExecutionMetrics
Bases: BaseModel
Execution metrics model.
PipelineInfo
Bases: BaseModel
Pipeline info model.
ServiceInfo
Bases: BaseModel
Service info model.
SnapshotInfo
Bases: BaseModel
Snapshot info model.
runtime
Thread-safe runtime context for deployments.
This module provides request-scoped state for deployment invocations using contextvars to ensure thread safety and proper request isolation. Each deployment request gets its own isolated context that doesn't interfere with concurrent requests.
It also provides parameter override functionality for the orchestrator to access deployment parameters without tight coupling.
get_in_memory_data(uri: str) -> Any
Get data from memory for the given URI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
The artifact URI to retrieve data for. |
required |
Returns:
| Type | Description |
|---|---|
Any
|
The stored data, or None if not found. |
Source code in src/zenml/deployers/server/runtime.py
158 159 160 161 162 163 164 165 166 167 168 169 170 | |
get_outputs() -> Dict[str, Dict[str, Any]]
Return the outputs for all steps in the current context.
Returns:
| Type | Description |
|---|---|
Dict[str, Dict[str, Any]]
|
A dictionary of outputs for all steps. |
Source code in src/zenml/deployers/server/runtime.py
125 126 127 128 129 130 131 | |
is_active() -> bool
Return whether deployment state is active in the current context.
Returns:
| Type | Description |
|---|---|
bool
|
True if the deployment state is active in the current context, False otherwise. |
Source code in src/zenml/deployers/server/runtime.py
101 102 103 104 105 106 107 | |
put_in_memory_data(uri: str, data: Any) -> None
Store data in memory for the given URI.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
uri
|
str
|
The artifact URI to store data for. |
required |
data
|
Any
|
The data to store in memory. |
required |
Source code in src/zenml/deployers/server/runtime.py
146 147 148 149 150 151 152 153 154 155 | |
record_step_outputs(step_name: str, outputs: Dict[str, Any]) -> None
Record raw outputs for a step by invocation id.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
step_name
|
str
|
The name of the step to record the outputs for. |
required |
outputs
|
Dict[str, Any]
|
A dictionary of outputs to record. |
required |
Source code in src/zenml/deployers/server/runtime.py
110 111 112 113 114 115 116 117 118 119 120 121 122 | |
should_skip_artifact_materialization() -> bool
Check if the current request should skip artifact materialization.
Returns:
| Type | Description |
|---|---|
bool
|
True if artifact materialization is skipped for this request. |
Source code in src/zenml/deployers/server/runtime.py
134 135 136 137 138 139 140 141 142 143 | |
start(request_id: str, snapshot: PipelineSnapshotResponse, parameters: Dict[str, Any], skip_artifact_materialization: bool = False) -> None
Initialize deployment state for the current request context.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request_id
|
str
|
The ID of the request. |
required |
snapshot
|
PipelineSnapshotResponse
|
The snapshot to deploy. |
required |
parameters
|
Dict[str, Any]
|
The parameters to deploy. |
required |
skip_artifact_materialization
|
bool
|
Whether to skip artifact materialization. |
False
|
Source code in src/zenml/deployers/server/runtime.py
71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
stop() -> None
Clear the deployment state for the current request context.
Source code in src/zenml/deployers/server/runtime.py
95 96 97 98 | |
service
Pipeline deployment service.
BasePipelineDeploymentService(app_runner: BaseDeploymentAppRunner, **kwargs: Any)
Bases: ABC
Abstract base class for pipeline deployment services.
Subclasses must implement lifecycle management, execution, health, and schema accessors. This contract enables swapping implementations via import-source configuration without modifying the FastAPI app wiring code.
Initialize the deployment service.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
app_runner
|
BaseDeploymentAppRunner
|
The deployment application runner used with this service. |
required |
**kwargs
|
Any
|
Additional keyword arguments for the deployment service. |
{}
|
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If snapshot cannot be loaded. |
Source code in src/zenml/deployers/server/service.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
input_model: Type[BaseModel]
property
Construct a Pydantic model representing pipeline input parameters.
Load the pipeline class from pipeline_spec.source and derive the
entrypoint signature types to create a dynamic Pydantic model
(extra='forbid') to use for parameter validation.
Returns:
| Type | Description |
|---|---|
Type[BaseModel]
|
A Pydantic |
Type[BaseModel]
|
parameters. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the pipeline class cannot be loaded or if no parameters model can be constructed for the pipeline. |
input_schema: Dict[str, Any]
property
Return the JSON schema for pipeline input parameters.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
The JSON schema for pipeline parameters. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the pipeline input schema is not available. |
output_schema: Dict[str, Any]
property
Return the JSON schema for the pipeline outputs.
Returns:
| Type | Description |
|---|---|
Dict[str, Any]
|
The JSON schema for the pipeline outputs. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the pipeline output schema is not available. |
cleanup() -> None
abstractmethod
Cleanup service resources and run cleanup hooks.
Source code in src/zenml/deployers/server/service.py
159 160 161 | |
execute_pipeline(request: BaseDeploymentInvocationRequest) -> BaseDeploymentInvocationResponse
abstractmethod
Execute the deployment with the given parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
BaseDeploymentInvocationRequest
|
Runtime parameters supplied by the caller. |
required |
Returns:
| Type | Description |
|---|---|
BaseDeploymentInvocationResponse
|
A BaseDeploymentInvocationResponse describing the execution result. |
Source code in src/zenml/deployers/server/service.py
163 164 165 166 167 168 169 170 171 172 173 174 | |
get_execution_metrics() -> ExecutionMetrics
abstractmethod
Return lightweight execution metrics for observability.
Returns:
| Type | Description |
|---|---|
ExecutionMetrics
|
A dictionary containing execution metrics. |
Source code in src/zenml/deployers/server/service.py
184 185 186 187 188 189 190 | |
get_pipeline_invoke_models() -> Tuple[Type[BaseModel], Type[BaseModel]]
Generate the request and response models for the pipeline invoke endpoint.
Returns:
| Type | Description |
|---|---|
Tuple[Type[BaseModel], Type[BaseModel]]
|
A tuple containing the request and response models. |
Source code in src/zenml/deployers/server/service.py
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 | |
get_service_info() -> ServiceInfo
abstractmethod
Get service information.
Returns:
| Type | Description |
|---|---|
ServiceInfo
|
A dictionary containing service information. |
Source code in src/zenml/deployers/server/service.py
176 177 178 179 180 181 182 | |
health_check() -> None
abstractmethod
Check service health.
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the service is not healthy. |
Source code in src/zenml/deployers/server/service.py
192 193 194 195 196 197 198 | |
initialize() -> None
abstractmethod
Initialize service resources and run init hooks.
Raises:
| Type | Description |
|---|---|
Exception
|
If the service cannot be initialized. |
Source code in src/zenml/deployers/server/service.py
151 152 153 154 155 156 157 | |
PipelineDeploymentService(app_runner: BaseDeploymentAppRunner, **kwargs: Any)
Bases: BasePipelineDeploymentService
Default pipeline deployment service implementation.
Source code in src/zenml/deployers/server/service.py
133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 | |
cleanup() -> None
Execute cleanup hook if present.
Source code in src/zenml/deployers/server/service.py
356 357 358 | |
execute_pipeline(request: BaseDeploymentInvocationRequest) -> BaseDeploymentInvocationResponse
Execute the deployment with the given parameters.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
request
|
BaseDeploymentInvocationRequest
|
Runtime parameters supplied by the caller. |
required |
Returns:
| Type | Description |
|---|---|
BaseDeploymentInvocationResponse
|
A BaseDeploymentInvocationResponse describing the execution result. |
Source code in src/zenml/deployers/server/service.py
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 | |
get_execution_metrics() -> ExecutionMetrics
Return lightweight execution metrics for observability.
Returns:
| Type | Description |
|---|---|
ExecutionMetrics
|
Aggregated execution metrics. |
Source code in src/zenml/deployers/server/service.py
458 459 460 461 462 463 464 465 466 467 | |
get_service_info() -> ServiceInfo
Get service information.
Returns:
| Type | Description |
|---|---|
ServiceInfo
|
A dictionary containing service information. |
Source code in src/zenml/deployers/server/service.py
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 | |
health_check() -> None
Check service health.
Source code in src/zenml/deployers/server/service.py
469 470 471 | |
initialize() -> None
Initialize service with proper error handling.
Raises:
| Type | Description |
|---|---|
Exception
|
If the service cannot be initialized. |
Source code in src/zenml/deployers/server/service.py
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 | |
SharedLocalOrchestrator(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: LocalOrchestrator
Local orchestrator tweaked for deployments.
This is a slight modification of the LocalOrchestrator: - uses request-scoped orchestrator run ids by storing them in contextvars - bypasses the init/cleanup hook execution because they are run globally by the deployment service
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 | |
get_orchestrator_run_id() -> str
Get the orchestrator run id.
Returns:
| Type | Description |
|---|---|
str
|
The orchestrator run id. |
Source code in src/zenml/deployers/server/service.py
89 90 91 92 93 94 95 96 97 98 99 | |
run_cleanup_hook(snapshot: PipelineSnapshotResponse) -> None
classmethod
Runs the cleanup hook.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
PipelineSnapshotResponse
|
The snapshot to run the cleanup hook for. |
required |
Source code in src/zenml/deployers/server/service.py
112 113 114 115 116 117 118 119 120 121 | |
run_init_hook(snapshot: PipelineSnapshotResponse) -> None
classmethod
Runs the init hook.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
snapshot
|
PipelineSnapshotResponse
|
The snapshot to run the init hook for. |
required |
Source code in src/zenml/deployers/server/service.py
101 102 103 104 105 106 107 108 109 110 | |
utils
ZenML deployers utilities.
Classes
Functions
deployment_snapshot_request_from_source_snapshot(source_snapshot: PipelineSnapshotResponse, deployment_parameters: Dict[str, Any]) -> PipelineSnapshotRequest
Generate a snapshot request for deployment execution.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
source_snapshot
|
PipelineSnapshotResponse
|
The source snapshot from which to create the snapshot request. |
required |
deployment_parameters
|
Dict[str, Any]
|
Parameters to override for deployment execution. |
required |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the source snapshot does not have an associated stack. |
Returns:
| Type | Description |
|---|---|
PipelineSnapshotRequest
|
The generated snapshot request. |
Source code in src/zenml/deployers/utils.py
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 | |
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
46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 | |
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
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 | |
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
72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 | |
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
135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 | |
load_deployment_requirements(deployment_settings: DeploymentSettings) -> List[str]
Load the software requirements for a deployment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
deployment_settings
|
DeploymentSettings
|
The deployment settings for which to load the software requirements. |
required |
Returns:
| Type | Description |
|---|---|
List[str]
|
The software requirements for the deployment. |
Raises:
| Type | Description |
|---|---|
RuntimeError
|
If the deployment app runner flavor cannot be loaded. |
Source code in src/zenml/deployers/utils.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 | |