To deploy and manage your trained machine learning models, ZenML provides a stack component calledDocumentation Index
Fetch the complete documentation index at: https://zenml.mintlify.app/llms.txt
Use this file to discover all available pages before exploring further.
Model Deployer. This component is responsible for interacting with the deployment tool, framework or platform.
When present in a stack, the model deployer can also act as a registry for models that are served with ZenML. You can use the model deployer to list all models that are currently deployed for online inference or filtered according to a particular pipeline run or step, or to suspend, resume or delete an external model server managed through ZenML.
Base Abstraction
In ZenML, the base abstraction of the model deployer is built on top of three major criteria:- It needs to contain all the stack-related configuration attributes required to interact with the remote model serving tool, service or platform (e.g. hostnames, URLs, references to credentials, other client-related configuration parameters).
-
It needs to implement the continuous deployment logic necessary to deploy models in a way that updates an existing model server that is already serving a previous version of the same model instead of creating a new model server for every new model version (see the
deploy_modelabstract method). This functionality can be consumed directly from ZenML pipeline steps, but it can also be used outside the pipeline to deploy ad-hoc models. It is also usually coupled with a standard model deployer step, implemented by each integration, that hides the details of the deployment process from the user. -
It needs to act as a ZenML BaseService registry, where every BaseService instance is used as an internal representation of a remote model server (see the
find_model_serverabstract method). To achieve this, it must be able to re-create the configuration of a BaseService from information that is persisted externally, alongside or even as part of the remote model server configuration itself. For example, for model servers that are implemented as Kubernetes resources, the BaseService instances can be serialized and saved as Kubernetes resource annotations. This allows the model deployer to keep track of all externally running model servers and to re-create their corresponding BaseService instance representations at any given time. The model deployer also defines methods that implement basic life-cycle management on remote model servers outside the coverage of a pipeline (seestop_model_server,start_model_serveranddelete_model_server).
Building your own model deployers
If you want to create your own custom flavor for a model deployer, you can follow the following steps:- Create a class which inherits from the
BaseModelDeployerclass and implement the abstract methods. - If you need to provide any configuration, create a class which inherits from the
BaseModelDeployerConfigclass add your configuration parameters. - Bring both of the implementation and the configuration together by inheriting from the
BaseModelDeployerFlavorclass. Make sure that you give anameto the flavor through its abstract property.
- The CustomModelDeployerFlavor class is imported and utilized upon the creation of the custom flavor through the CLI.
- The CustomModelDeployerConfig class is imported when someone tries to register/update a stack component with this custom flavor. Especially, during the registration process of the stack component, the config will be used to validate the values given by the user. As
Configobject are inherentlypydanticobjects, you can also add your own custom validators here. - The CustomModelDeployer only comes into play when the component is ultimately in use.
CustomModelDeployerFlavor and the CustomModelDeployerConfig are implemented in a different module/path than the actual CustomModelDeployer).