ModelDeployment API

class datarobot.models.ModelDeployment(id, model=None, project=None, type=None, status=None, user=None, organization_id=None, instance=None, label=None, description=None, prediction_endpoint=None, deployed=None, created_at=None, updated_at=None, service_health=None, service_health_messages=None, recent_request_count=None, prev_request_count=None, relative_requests_trend=None, trend_time_window=None, request_rates=None)

ModelDeployments provide an interface for tracking the health and activity of predictions made against a deployment model. The get_service_statistics method can be used to see current and historical trends in requests made and in user and server error rates

Notes

HealthMessage dict contains:

  • level : error level, one of [passing, warning, failing]
  • msg_id : identifier for message, like USER_ERRORS, SERVER_ERRORS, NO_GOOD_REQUESTS
  • message : human-readable message

Instance dict contains:

  • id : id of the dedicated prediction instance the model is deployed to
  • host_name : host name of the dedicated prediction instance
  • private_ip : IP address of the dedicated prediction instance
  • orm_version : On-demand Resource Manager version of the dedicated prediction instance

Model dict contains:

  • id : id of the deployed model
  • model_type : identifies the model, e.g. Nystroem Kernel SVM Regressor
  • uid : id of the user who created this model

User dict contains:

  • username : the user’s username
  • first_name : the user’s first name
  • last_name : the user’s last name

Attributes

id (str) id of the model deployment
model (dict) model associated with the model deployment
project (dict) project associated with the model deployment
type (str) type of the model deployment. Can be one of [sse, dedicated, legacy_dedicated]
status (str) status of the model deployment. Can be one of [active, inactive, archived]
user (dict) user who created the model deployment
organization_id (str) id of the organization associated with the model deployment
instance (dict) instance associated with the model deployment
label (str) label of the model deployment
description (str) description of the model deployment
prediction_endpoint (str) URL where the model is deployed and available for serving predictions
deployed (bool) has the model deployment deployed process finished or not.
created_at (datetime) timestamp when the model deployment was created
updated_at (datetime) timestamp when the model deployment was updated
service_health (str) display model health status. Can be one of [passing, warning or failing]
service_health_messages (list) list of HealthMessage objects for service health state
recent_request_count (int) the number of recent requests, within the recent time window specified in trend_time_window
prev_request_count (int) the number of requests, within the previous time window specified in trend_time_window
relative_requests_trend (float) relative difference (as a percentage) between the number of prediction requests performed within the current time window and one time window before that. The size of the time window is specified by trend_time_window
trend_time_window (str) time window (in full days from “now”) trend is calculated for
request_rates (list) history of request rates per day sorted in chronological order (last entry being the most recent, i.e. today).
classmethod create(project_id, model_id, label, instance_id=None, description=None, status=None)

Create model deployment.

Parameters:

project_id : str

id of the project the model belongs to

model_id : str

id of the model for deployment

label : str

human-readable name for the model deployment

instance_id : str, optional

id of the instance in DataRobot cloud being deployed to

description : str, optional

description for the model deployment

status : str, optional

status for the model deployment. Can be [active, inactive, archived].

Returns:

job : Job

an instance of created async job

classmethod list(limit=None, offset=None, query=None, order_by=None, status=None)

List of model_deployments

Parameters:

limit : int or None

at most this many results are returned, default: no limit

offset : int or None

this many results will be skipped, default: 0

query : str, optional

Filter the model deployments by matching labels and descriptions with the specified string. Partial matches are included, too. Matches are case insensitive

order_by : str, optional

the model deployments. Supported attributes for ordering: label, exportTarget, status, type. Prefix attribute name with dash to sort in descending order, e.g. orderBy=-label. Only one field can be selected

status : str, optional

Filter the list of deployments by status. Must be one of: [active, inactive, archived]

Returns:

model_deployments : list[ModelDeployment]

classmethod get(model_deployment_id)

Retrieve sa single model_deployment

Parameters:

model_deployment_id:

the id of the model_deployment to query

Returns:

model_deployment : ModelDeployment

The queried instance

update(label=None, description=None, status=None)

Update model_deployment object

Parameters:

label : str, optional

The new value for label to be set

description : str, optional

The new value for description to be set

status : str, optional

The new value for status to be set, Can be one of [active, inactive, archived]

get_service_statistics(start_date=None, end_date=None)

Retrieve health overview of current model_deployment

Parameters:

start_date : str, optional

datetime string that filter statistic from this timestamp

end_date: str, optional

datetime string that filter statistic till this timestamp

Returns:

service_health : dict

dict that represent ServiceHealth object

Notes

ServiceHealth dict contains:

  • total_requests: total number of requests performed. 0, if there were no requests
  • consumers : total number of unique users performing requests. 0, if there were no requests
  • period : dict with two fields - start and end, that denote the boundaries of the time period the stats are reported for. Note, that a half-open time interval is used: [start: end)
  • user_error_rate : dict with two fields - current and previous, that denote the ratio of user errors to the total number of requests performed for the given period and one time period before that. 0.0, if there were no errors (or requests)
  • server_error_rate : dict with two fields - current and previous, that denote the ratio of server errors to the total number of requests performed for the given period and one time period before that. 0.0, if there were no errors (or requests)
  • load : dict with two fields - peak and median, that denote the max and the median of the request rate (in requests per minute) across all requests for the duration of the given time period. Both will be equal to 0.0, if there were no requests.
  • median_execution_time : the median of the execution time across all performed requests (in seconds). null, if there were no requests
action_log(limit=None, offset=None)

List of actions taken affecting this deployment

Allows insight into when the ModelDeployment was created or deployed.

Parameters:

limit : int or None

at most this many results are returned, default: no limit

offset : int or None

this many results will be skipped, default: 0

Returns:

action_log : list of dict [ActionLog]

Notes

ActionLog dict contains:

  • action : identifies the action. Can be one of [deployed, created]
  • performed_by : dict with id, username, first_name and last_name of the user who performed the action.
  • performed_at : date/time when the action was performed in ISO-8601 format.