Skip to main content
Version: Cloud

Create and update Deployments

Preparation

In order to deploy models, you need a Personal Key Pair. For more information regarding authentication, see Authentication.

Another part of the preparation is getting familiar with the repository contract that Deeploy uses, you can find more information about that here. If your model is stored elsewhere and you do not yet adhere to the contract, you generate a reference.json.

Standard deployments

Create a standard deployment

See all Create Deployment arguments

from deeploy import CreateDeployment
from deeploy.enums import ModelType

create_options: CreateDeployment = {
"name": "Python Client",
"description": "Python Client Description",
"repository_id": "b6d8c781-2526-4e03-9b43-4c1a62d064db",
"branch_name": "master",
"commit": "b26af7790c1d3b27b953b37806b91cb6735c590b",
"model_type": ModelType.CUSTOM,
"model_serverless": True,
}

deployment = client.create_deployment(create_options)

Update a standard deployment

See all Update Deployment arguments

from deeploy import UpdateDeployment

update_options: UpdateDeployment = {
"model_mem_request": 256,
"model_mem_limit": 256,
"model_cpu_request": 0.1,
"model_cpu_limit": 0.5,
}

updated_deployment = client.update_deployment(deployment_id=deployment.id, options=update_options)

External deployments

Create an external deployment

See all Create Deployment arguments

from deeploy import CreateRegistrationDeployment

# example used: https://gitlab.com/deeploy-ml/sample-models/example-hello-world-external-deployment
create_options: CreateExternalDeployment = {
"name": "External deployment",
"description": "Created with Python client",
"url": "https://hello-world.external-deployment.workers.dev/hello",
"repository_id": None,
"branch_name": None,
"username": "admin",
"password": "YWRtaW46cGFzc3dvcmQxMjM="
}

deployment = client.create_external_deployment(options=create_options)

Update an external deployment

See all Create Deployment arguments

from deeploy import UpdateRegistrationDeployment

# example used: https://gitlab.com/deeploy-ml/sample-models/example-hello-world-external-deployment
update_options: UpdateExternalDeployment = {
"repository_id": "70cd264a-8023-4aab-9067-a9acc4badb42",
"branch_name": "main",
"commit": "1694c40449f6143373f28794de7b49e941a5fc65"
}

deployment = client.update_external_deployment(deployment_id=deployment.id, options=update_options)

Deployment registrations

Create a deployment registration

See all Create Deployment arguments

from deeploy import CreateRegistrationDeployment

# example used: https://gitlab.com/deeploy-ml/sample-models/example-census-registration-deployment
create_options: CreateExternalDeployment = {
"name": "Deployment registration",
"description": "Created with Python client",
"repository_id": None,
"branch_name": None,
}

deployment = client.create_registration_deployment(options=create_options)

Update a deployment registration

See all Create Deployment arguments

from deeploy import UpdateRegistrationDeployment

# example used: https://gitlab.com/deeploy-ml/sample-models/example-census-registration-deployment
update_options: UpdateExternalDeployment = {
"repository_id": "70cd264a-8023-4aab-9067-a9acc4badb42",
"branch_name": "main",
"commit": "1694c40449f6143373f28794de7b49e941a5fc65"
}

deployment = client.update_external_deployment(deployment_id=deployment.id, options=update_options)

SageMaker

Create a SageMaker Deployment

See all Create SageMaker Deployment arguments

from deeploy import CreateSageMakerDeployment
from deeploy.enums import ModelType

create_options: CreateSageMakerDeployment = {
"name": "Python Client",
"description": "Python Client Description",
"repository_id": "b6d8c781-2526-4e03-9b43-4c1a62d064db",
"branch_name": "master",
"commit": "b26af7790c1d3b27b953b37806b91cb6735c590b",
"model_type": ModelType.CUSTOM,
"model_instance_type": 'ml.c5.large',
}

sagemaker_deployment = client.create_sagemaker_deployment(options=create_options)

Update a SageMaker Deployment

See all Update SageMaker Deployment arguments

from deeploy import UpdateSageMakerDeployment

update_options: UpdateSageMakerDeployment = {
"model_instance_type": 'ml.c4.large',
}

updated_deployment = client.update_sagemaker_deployment(deployment_id=sagemaker_deployment.id, options=update_options)

Azure Machine Learning

Create an Azure Machine Learning Deployment

See all Create Azure Machine Learning Deployment arguments

from deeploy import CreateAzureMLDeployment
from deeploy.enums import ExplainerType, ModelType

create_options: CreateAzureMLDeployment = {
"name": "Python Client",
"description": "Python Client Description",
"repository_id": "b6d8c781-2526-4e03-9b43-4c1a62d064db",
"branch_name": "main",
"commit": "ea420035f347fad091e367a9ce2798aef6cae9eb",
"model_type": ModelType.CUSTOM,
"explainer_type": ExplainerType.CUSTOM,
"model_instance_type": "Standard_D2as_v4",
"model_instance_count": 1,
"explainer_instance_type": "Standard_D2as_v4",
"explainer_instance_count": 1,
}

azure_ml_deployment = client.create_azure_ml_deployment(options=create_options)

Update an Azure Machine Learning Deployment

See all Update Azure Machine Learning Deployment arguments

from deeploy import UpdateAzureMLDeployment

update_options: UpdateAzureMLDeployment = {
"model_instance_type": "Standard_D2as_v4",
"model_instance_count": 1,
"explainer_instance_type": "Standard_D2as_v4",
"explainer_instance_count": 1,
}

updated_azure_ml_deployment = client.update_azure_ml_deployment(deployment_id=azure_ml_deployment.id, options=update_options)

General

Update the Deployment description

from deeploy import UpdateDeploymentDescription

description_options: UpdateDeploymentDescription = {
"name": "Python Client v2",
"description": "Python Client Description v2",
}

updated_deployment = client.update_deployment_description(deployment_id, description_options)

Creating multiple Deployments from a monorepo

Deeploy supports creating multiple Deployments from the same repository using a contract path. The contract path is the path relative to the root of a repository where the deeploy contract for a Deployment is located. The idea is that you create your Deeploy contract path at a subfolder in the repository, as shown in the example below.

repository

├─ subfolder_1
│ ├─ model
│ │ └─ reference.json
│ ├─ explainer
│ │ └─ reference.json
│ ├─ transformer
│ │ └─ reference.json
│ └─ metadata.json

└─ subfolder_2
└─ model
└─ reference.json

To create a Deployment from a contract path, you provide the relative path from the repository root as input to the Python SDK or Core API. In the example above this is subfolder_1 or subfolder_2.

from deeploy import CreateDeployment

create_options: CreateDeployment = {
# other options
"contract_path": "/subfolder_1",
}

deployment = client.create_deployment(create_options)

Check out the API reference for more information.