List monitored deployments
This example demonstrates how you can list all the monitored deployments of a user by using the model monitoring service of the MLOps API.
You will need the values for the following constants in order to successfully carry out the task. Contact your administrator to obtain deployment specific values.
Constant | Value | Description |
---|---|---|
MLOPS_API_URL | Usually: https://api.mlops.my.domain | Defines the URL for the MLOps Gateway component. |
TOKEN_ENDPOINT_URL | https://mlops.keycloak.domain/auth/realms/[fill-in-realm-name]/protocol/openid-connect/token | Defines the token endpoint URL of the Identity Provider. This uses Keycloak as the Identity Provider. Keycloak Realm should be provided. |
REFRESH_TOKEN | <your-refresh-token> | Defines the user's refresh token |
CLIENT_ID | <your-client-id> | Sets the client id for authentication. This is the client you will be using to connect to MLOps. |
CLIENT_SECRET | <your-client-secret> | Sets the client secret. |
The following steps demonstrate how you can use the MLOps Python client to list all the monitored deployments of a user.
Change the values of the following constants in your
ListMonitoredDeployments.py
file as given in the preceding data table.ListMonitoredDeployments.py### Constants
MLOPS_API_URL = <MLOPS_API_URL>
TOKEN_ENDPOINT_URL = <TOKEN_ENDPOINT_URL>
REFRESH_TOKEN = <REFRESH_TOKEN>
CLIENT_ID = <CLIENT_ID>
CLIENT_SECRET = <CLIENT_SECRET>ListMonitoredDeployments.py### Constants
MLOPS_API_URL = "https://api.mlops.my.domain"
TOKEN_ENDPOINT_URL = "https://mlops.keycloak.domain/auth/realms/[fill-in-realm-name]/protocol/openid-connect/token"
REFRESH_TOKEN = "<your-refresh-token>"
CLIENT_ID = "<your-mlops-client>"
CLIENT_SECRET = "<your-client-secret>"Run the
ListMonitoredDeployments.py
file.python3 ListMonitoredDeployments.py
This lists all the monitored deployments created by you in MLOps. However, this does not include the deployments shared with you by other users.
Deployment details: {'deployment': [{'deployment_date': datetime.datetime(2022, 8, 17, 8, 33, 20, tzinfo=tzutc()),
'description': '',
'environment': 'DEV',
'id': 'f9fa4db1-2f30-4b10-ace2-f383a9f74880',
'mode': 'Real Time',
'models': [{'accuracy': 'UNKNOWN',
'average_scoring_requests': 17670,
'drift_status': 'UNKNOWN',
'registered_model_name': 'heart',
'registered_model_version': '1'}],
'name': 'heart',
'problem_type': 'Binary Classification',
'type': 'singleDeployment'},
{'deployment_date': datetime.datetime(2022, 8, 17, 14, 48, 23, tzinfo=tzutc()),
'description': '',
'environment': 'DEV',
'id': '3e583474-93a3-490b-bd79-8eb0a71e8793',
'mode': 'Real Time',
'models': [{'accuracy': 'UNKNOWN',
'average_scoring_requests': 250,
'drift_status': 'UNKNOWN',
'registered_model_name': 'mojo_glm_regression',
'registered_model_version': '1'}],
'name': 'mojo_glm_regression',
'problem_type': 'Regression',
'type': 'singleDeployment'},
Example walkthrough
This section provides a walkthrough of the ListMonitoredDeployments.py
file.
Set up the token provider using an existing refresh token and client secret.
List all the monitored deployments of the user by calling the
list_monitored_deployments
endpoint of the model monitoring service.ListMonitoredDeployments.py# List all the monitored deployments of the user
deployments: mlops.ApiListMonitoredDeploymentsResponse = (
mlops_client.model_monitoring.monitoring_service.list_monitored_deployments()
)
print(f"Deployment details: {deployments}")
- Submit and view feedback for this page
- Send feedback about H2O MLOps to cloud-feedback@h2o.ai