Deployment environment variables
This page describes how to manage custom environment variables in the scoring runtime.
Connect to H2O MLOps
import h2o_mlops
import time
mlops = h2o_mlops.Client()
New deployment
- Prepare everything you need to create a deployment.
project = mlops.projects.create(name="demo")
experiment = project.experiments.create(
data="/Users/jgranados/Downloads/GBM_model_python_1649367037255_1.zip",
name="experiment-from-client"
)
model = project.models.create(name="model-from-client")
model.register(experiment=experiment)
environment = project.environments.list(name="DEV")[0]
scoring_runtime = mlops.runtimes.scoring.list(
artifact_type=model.get_experiment().scoring_artifact_types[0]
)[0]
- Define a few environment variables to add to the scoring runtime.
environment_variables = {"MY_CUSTOM_VAR_1": "abc", "MY_CUSTOM_VAR_2": "xyz"}
- Deploy using the environment variables argument.
deployment = environment.deployments.create_single(
name="deployment-from-client",
model=model,
scoring_runtime=scoring_runtime,
environment_variables=environment_variables,
)
while not deployment.is_healthy():
deployment.raise_for_failure()
time.sleep(5)
deployment.environment_variables
Output:
{'MY_CUSTOM_VAR_1': 'abc', 'MY_CUSTOM_VAR_2': 'xyz'}
Existing deployment
You can also set environment variables in an existing deployment. Note that this removes all environment variables that were previously set.
deployment.set_environment_variables({"MY_OTHER_CUSTOM_VAR": "123"})
while not deployment.is_healthy():
deployment.raise_for_failure()
time.sleep(5)
deployment.environment_variables
Output:
{'MY_OTHER_CUSTOM_VAR': '123'}
Feedback
- Submit and view feedback for this page
- Send feedback about H2O MLOps to cloud-feedback@h2o.ai