Skip to main content
Version: v0.68.0

Configurable endpoints

Endpoints provide a static URL that can be pointed to any deployment in the deployment environment of the endpoint. This page describes how to configure endpoints using the H2O MLOps Python client.

  1. Connect to H2O MLOps.
import h2o_mlops
import httpx


mlops = h2o_mlops.Client()
  1. First, we'll grab some deployments for demonstration purposes.
project = mlops.projects.get("fe96aa18-6aa5-4f26-80f7-a682f1741f84")

environment = project.environments.list(name="DEV")[0]

deployment_one = environment.deployments.list()[0]
deployment_two = environment.deployments.list()[1]

Create an endpoint

Note: Endpoint must be in the same environment as the deployment.

endpoint = environment.endpoints.create(
name="Demo Endpoint",
description="Endpoint for giving demos.",
path="static/path",
target_deployment=deployment_one
)

List endpoints

environment.endpoints.list()

Output:

    | name          | path        | uid
----+---------------+-------------+--------------------------------------
0 | Demo Endpoint | static/path | fb185ef2-f179-419b-914c-caec166aa6d7

Get endpoint

endpoint = environment.endpoints.get(endpoint.uid)

Use an endpoint

Once we have an endpoint, it provides a static URL that can be pointed to any deployment in the deployment environment of the endpoint.

Note: Endpoints take a little time to become ready to receive HTTP requests.

static_url = f"https://model.cloud-qa.h2o.ai/{endpoint.path}/model"

static_url

Output:

'https://model.cloud-qa.h2o.ai/static/path/model'

Any of the model methods available from the deployment (capabilities, schema, id, sample_request, score) are available at the endpoint.

Input:

httpx.get(f"{static_url}/capabilities").json()

Output:

['SCORE_PREDICTION_INTERVAL', 'SCORE']

Input:

sample_request = httpx.get(f"{static_url}/sample_request").json()

httpx.post(
url=f"{static_url}/score",
json=sample_request
).json()

Output:

{'fields': ['C11.0', 'C11.1'],
'id': 'c19bdd94-e673-4094-bd68-da5d077dc096',
'score': [['0.49786656666743145', '0.5021334333325685']]}

Input:

httpx.get(f"{static_url}/id").text

Output:

'c19bdd94-e673-4094-bd68-da5d077dc096'

Update the endpoint

Note: Only display_name, description, and target fields may be updated. Setting the target field to an empty string disables the endpoint.

Input:

endpoint.update(target_deployment=deployment_two)
sample_request = httpx.get(f"{static_url}/sample_request").json()

httpx.post(
url=f"{static_url}/score",
json=sample_request
).json()

Output:

{'fields': ['C11.0', 'C11.1'],
'id': 'c19bdd94-e673-4094-bd68-da5d077dc096',
'score': [['0.49786656666743145', '0.5021334333325685']]}

Input:

endpoint.target_deployment.uid != deployment_one.uid

Output:

True

Delete an endpoint

endpoint.delete()

Feedback