Skip to main content
Version: 1.41

Add environment variables

Deeploy supports adding environment variables or startup arguments to the containers that you use in the Deployment. Deeploy supports both default model and explainer images and custom images. A list of supported environment variables and startup arguments is available at the bottom of this article.

info

Take into account that environment variables and arguments only change when updating a Deployment.

Environment variables

Deeploy allows you to create environment variables that can be used in your model, explainer or transformer.

Create an environment variable

from deeploy import CreateEnvironmentVariable

create_options: CreateEnvironmentVariable = {
"name": "A unique name",
"key": "EXAMPLE_VARIABLE",
"value": "example",
}

environment_variable = client.create_environment_variable(create_options)

Create a Deployment with environment variables

from deeploy import CreateDeployment

# select the environment variables you want to include in your Deployment
# use the IDs of the environment variables as input for your Deployment
environment_variables = client.get_all_environment_variables()

create_options: CreateDeployment = {
# other options
"model_environment_variable_ids": ["b6d8c781-2526-4e03-9b43-4c1a62d064db"],
"explainer_environment_variable_ids": ["b6d8c781-2526-4e03-9b43-4c1a62d064db"],
}

deployment = client.create_deployment(create_options)

Update a Deployment with environment variables

To update the environment variables of a Deployment, you have to sent a complete list of the environment variable IDs you wish to include. To do so, first retrieve which environment variables are active on your Deployment, add or remove the environment variable IDs you'd like to change, and then call update_deployment.

from deeploy import UpdateDeployment
from deeploy.enums import Artifact

# check which environment variables are currently used in your Deployment
model_environment_variable_ids = client.get_environment_variable_ids_for_deployment_artifact(deployment_id, Artifact.MODEL)

# add new environment variables to the list
new_environment_variable_ids = ["b6d8c781-2526-4e03-9b43-4c1a62d064db", *model_environment_variable_ids]

update_options: UpdateDeployment = {
# other options
"model_environment_variable_ids": new_environment_variable_ids,
"explainer_environment_variable_ids": [], # leave empty to remove all environment variables
}

updated_deployment = client.update_deployment(deployment_id, update_options)

Startup arguments

Startup arguments, also known as command-line arguments, are inputs to a program that are specified when the program starts. These arguments can affect the behavior of the program. For example, a program might accept a --verbose true startup argument that causes it to output more status data as it runs.

Adding a startup argument when updating a Deployment in Deeploy

Choose one of the following UpdateDeployment options to add your arguments to the model, explainer or transformer:

  • model_args: dict
  • explainer_args: dict
  • transformer_args: dict

Example:

from deeploy import Client, UpdateDeployment
from deeploy.enums import ModelType

# initialise the client
client = Client(
# if using the Deeploy cloud version 'host' is 'app.deeploy.ml'
host="app.deeploy.ml",
workspace_id="xxxx-example",
access_key="dexamplekey",
secret_key="examplesecretkey",
)

# define the update options
update_options: UpdateDeployment = {
"name": "Python Client",
"description": "Python Client Description",
"model_args": {"verbose": "true"}
}

# defining the local_repository_path here uses the local git configuration to create the deployment.
deployment = client.update_deployment(options=update_options, deployment_id="xxx", local_repository_path=".")

Supported variables default images

The list below is expect to increase in the future.

Default imagevariablepossible values
kserve/sklearnserver:v0.11.0PREDICT_PROBA'true', 'false'