Skip to content

Custom models

CustomModelFileItem

class datarobot.models.custom_model_version.CustomModelFileItem

A file item attached to a DataRobot custom model version.

Added in version v2.21.

Variables

Attribute Type Description
id str The ID of the file item.
file_name str The name of the file item.
file_path str The path of the file item.
file_source str The source of the file item.
created_at Optional[str] ISO-8601 formatted timestamp of when the version was created.

CustomInferenceModel

class datarobot.CustomInferenceModel

A custom inference model.

Added in version v2.21.

Variables

Attribute Type Description
id str The ID of the custom model.
name str The name of the custom model.
language str The programming language of the custom inference model. Can be “python”, “r”, “java” or “other”.
description str The description of the custom inference model.
target_type datarobot.TARGET_TYPE Target type of the custom inference model. Values: [datarobot.TARGET_TYPE.BINARY, datarobot.TARGET_TYPE.REGRESSION, datarobot.TARGET_TYPE.MULTICLASS, datarobot.TARGET_TYPE.UNSTRUCTURED, datarobot.TARGET_TYPE.ANOMALY, datarobot.TARGET_TYPE.TEXT_GENERATION]
target_name str Target feature name. It is optional(ignored if provided) for datarobot.TARGET_TYPE.UNSTRUCTURED or datarobot.TARGET_TYPE.ANOMALY target type.
latest_version datarobot.CustomModelVersion or None The latest version of the custom model if the model has a latest version.
deployments_count int Number of a deployments of the custom models.
target_name The custom model target name.
positive_class_label str For binary classification projects, a label of a positive class.
negative_class_label str For binary classification projects, a label of a negative class.
prediction_threshold float For binary classification projects, a threshold used for predictions.
training_data_assignment_in_progress bool Flag describing if training data assignment is in progress.
training_dataset_id Optional[str] The ID of a dataset assigned to the custom model.
training_dataset_version_id Optional[str] The ID of a dataset version assigned to the custom model.
training_data_file_name Optional[str] The name of assigned training data file.
training_data_partition_column Optional[str] The name of a partition column in a training dataset assigned to the custom model.
created_by str The username of a user who created the custom model.
updated_at str ISO-8601 formatted timestamp of when the custom model was updated
created_at str ISO-8601 formatted timestamp of when the custom model was created
network_egress_policy datarobot.NETWORK_EGRESS_POLICY, optional Determines whether the given custom model is isolated, or can access the public network. Values: [datarobot.NETWORK_EGRESS_POLICY.NONE, datarobot.NETWORK_EGRESS_POLICY.PUBLIC].
maximum_memory Optional[int] The maximum memory that might be allocated by the custom-model. If exceeded, the custom-model will be killed by k8s.
replicas Optional[int] A fixed number of replicas that will be deployed in the cluster
is_training_data_for_versions_permanently_enabled Optional[bool] Whether training data assignment on the version level is permanently enabled for the model.

list()

classmethod list()

List custom inference models available to the user.

Added in version v2.21.

Parameters

Parameter Type Description
is_deployed Optional[bool] Flag for filtering custom inference models. If set to True, only deployed custom inference models are returned. If set to False, only not deployed custom inference models are returned.
search_for Optional[str] String for filtering custom inference models - only custom inference models that contain the string in name or description will be returned. If not specified, all custom models will be returned
order_by Optional[str] Property to sort custom inference models by. Supported properties are “created” and “updated”. Prefix the attribute name with a dash to sort in descending order, e.g., order_by=’-created’. By default, the order_by parameter is None which will result in custom models being returned in order of creation time descending.

Returns

Returns Description
A list of custom inference models.

Return type: List[CustomInferenceModel]

Raises

Exception Description
datarobot.errors.ClientError If the server responded with 4xx status
datarobot.errors.ServerError If the server responded with 5xx status

get()

classmethod get()

Get custom inference model by id.

Added in version v2.21.

Parameters

Parameter Type Description
custom_model_id str The ID of the custom inference model.

Returns

Returns Description
Retrieved custom inference model.

Return type: CustomInferenceModel

Raises

Exception Description
datarobot.errors.ClientError The ID the server responded with 4xx status.
datarobot.errors.ServerError The ID the server responded with 5xx status.

download_latest_version()

method download_latest_version()

Download the latest custom inference model version.

Added in version v2.21.

Parameters

Parameter Type Description
file_path str Path to create a file with custom model version content.

Raises

Exception Description
datarobot.errors.ClientError If the server responded with 4xx status.
datarobot.errors.ServerError If the server responded with 5xx status.

Return type: None

create()

classmethod create()

Create a custom inference model.

Added in version v2.21.

Parameters

Parameter Type Description
name str Name of the custom inference model.
target_type datarobot.TARGET_TYPE Target type of the custom inference model. Values: [datarobot.TARGET_TYPE.BINARY, datarobot.TARGET_TYPE.REGRESSION, datarobot.TARGET_TYPE.MULTICLASS, datarobot.TARGET_TYPE.UNSTRUCTURED, datarobot.TARGET_TYPE.TEXT_GENERATION]
target_name Optional[str] Target feature name. It is optional(ignored if provided) for datarobot.TARGET_TYPE.UNSTRUCTURED target type.
language Optional[str] Programming language of the custom learning model.
description Optional[str] Description of the custom learning model.
positive_class_label Optional[str] Custom inference model positive class label for binary classification.
negative_class_label Optional[str] Custom inference model negative class label for binary classification.
prediction_threshold Optional[float] Custom inference model prediction threshold.
class_labels List[str], optional Custom inference model class labels for multiclass classification. Cannot be used with class_labels_file.
class_labels_file Optional[str] Path to file containing newline separated class labels for multiclass classification. Cannot be used with class_labels.
network_egress_policy datarobot.NETWORK_EGRESS_POLICY, optional Determines whether the given custom model is isolated, or can access the public network. Values: [datarobot.NETWORK_EGRESS_POLICY.NONE, datarobot.NETWORK_EGRESS_POLICY.PUBLIC]
maximum_memory Optional[int] The maximum memory that might be allocated by the custom-model. If exceeded, the custom-model will be killed by k8s.
replicas Optional[int] A fixed number of replicas that will be deployed in the cluster.
is_training_data_for_versions_permanently_enabled Optional[bool] Permanently enable training data assignment on the version level for the current model, instead of training data assignment on the model level.

Returns

Returns Description
Created a custom inference model.

Return type: CustomInferenceModel

Raises

Exception Description
datarobot.errors.ClientError If the server responded with 4xx status.
datarobot.errors.ServerError If the server responded with 5xx status.

copy_custom_model()

classmethod copy_custom_model()

Create a custom inference model by copying existing one.

Added in version v2.21.

Parameters

Parameter Type Description
custom_model_id str The ID of the custom inference model to copy.

Returns

Returns Description
Created a custom inference model.

Return type: CustomInferenceModel

Raises

Exception Description
datarobot.errors.ClientError If the server responded with 4xx status.
datarobot.errors.ServerError If the server responded with 5xx status.

update()

method update()

Update custom inference model properties.

Added in version v2.21.

Parameters

Parameter Type Description
name Optional[str] New custom inference model name.
language Optional[str] New custom inference model programming language.
description Optional[str] New custom inference model description.
target_name Optional[str] New custom inference model target name.
positive_class_label Optional[str] New custom inference model positive class label.
negative_class_label Optional[str] New custom inference model negative class label.
prediction_threshold Optional[float] New custom inference model prediction threshold.
class_labels List[str], optional custom inference model class labels for multiclass classification Cannot be used with class_labels_file
class_labels_file Optional[str] Path to file containing newline separated class labels for multiclass classification. Cannot be used with class_labels
is_training_data_for_versions_permanently_enabled Optional[bool] Permanently enable training data assignment on the version level for the current model, instead of training data assignment on the model level.

Raises

Exception Description
datarobot.errors.ClientError If the server responded with 4xx status.
datarobot.errors.ServerError If the server responded with 5xx status.

Return type: None

refresh()

method refresh()

Update custom inference model with the latest data from server.

Added in version v2.21.

Raises

Exception Description
datarobot.errors.ClientError If the server responded with 4xx status.
datarobot.errors.ServerError If the server responded with 5xx status.

Return type: None

delete()

method delete()

Delete custom inference model.

Added in version v2.21.

Raises

Exception Description
datarobot.errors.ClientError If the server responded with 4xx status.
datarobot.errors.ServerError If the server responded with 5xx status.

Return type: None

assign_training_data()

method assign_training_data()

Assign training data to the custom inference model.

Added in version v2.21.

Parameters

Parameter Type Description
dataset_id str The ID of the training dataset to be assigned.
partition_column Optional[str] The name of a partition column in the training dataset.
max_wait Optional[int] The max time to wait for a training data assignment. If set to None, then method will return without waiting. Defaults to 10 min.

Raises

Exception Description
datarobot.errors.ClientError If the server responded with 4xx status
datarobot.errors.ServerError If the server responded with 5xx status

Return type: None

get_access_list()

method get_access_list()

Retrieve access control settings of this custom model.

Added in version v2.36.

Return type: list of SharingAccess

share()

method share()

Update the access control settings of this custom model.

Added in version v2.36.

Parameters

Parameter Type Description
access_list list of SharingAccess A list of SharingAccess to update.

Raises

Exception Description
datarobot.errors.ClientError if the server responded with 4xx status
datarobot.errors.ServerError if the server responded with 5xx status

Return type: None

Examples

Transfer access to the custom model from old_user@datarobot.com to new_user@datarobot.com

import datarobot as dr

new_access = dr.SharingAccess(new_user@datarobot.com,
                              dr.enums.SHARING_ROLE.OWNER, can_share=True)
access_list = [dr.SharingAccess(old_user@datarobot.com, None), new_access]

dr.CustomInferenceModel.get('custom-model-id').share(access_list)

CustomModelTest

class datarobot.CustomModelTest

An custom model test.

Added in version v2.21.

Variables

Attribute Type Description
id str test id
custom_model_image_id str id of a custom model image
image_type str the type of the image, either CUSTOM_MODEL_IMAGE_TYPE.CUSTOM_MODEL_IMAGE if the testing attempt is using a CustomModelImage as its model or CUSTOM_MODEL_IMAGE_TYPE.CUSTOM_MODEL_VERSION if the testing attempt is using a CustomModelVersion with dependency management
overall_status str a string representing testing status. Status can be - ‘not_tested’: the check not run - ‘failed’: the check failed - ‘succeeded’: the check succeeded - ‘warning’: the check resulted in a warning, or in non-critical failure - ‘in_progress’: the check is in progress
detailed_status dict detailed testing status - maps the testing types to their status and message. The keys of the dict are one of ‘errorCheck’, ‘nullValueImputation’, ‘longRunningService’, ‘sideEffects’. The values are dict with ‘message’ and ‘status’ keys.
created_by str a user who created a test
dataset_id Optional[str] id of a dataset used for testing
dataset_version_id Optional[str] id of a dataset version used for testing
completed_at Optional[str] ISO-8601 formatted timestamp of when the test has completed
created_at Optional[str] ISO-8601 formatted timestamp of when the version was created
network_egress_policy datarobot.NETWORK_EGRESS_POLICY, optional Determines whether the given custom model is isolated, or can access the public network. Values: [datarobot.NETWORK_EGRESS_POLICY.NONE, datarobot.NETWORK_EGRESS_POLICY.PUBLIC].
maximum_memory Optional[int] The maximum memory that might be allocated by the custom-model. If exceeded, the custom-model will be killed by k8s
replicas Optional[int] A fixed number of replicas that will be deployed in the cluster

create()

classmethod create()

Create and start a custom model test.

Added in version v2.21.

Parameters

Parameter Type Description
custom_model_id str the ID of the custom model
custom_model_version_id str the ID of the custom model version
dataset_id Optional[str] The id of the testing dataset for non-unstructured custom models. Ignored and not required for unstructured models.
max_wait Optional[int] max time to wait for a test completion. If set to None - method will return without waiting.
network_egress_policy datarobot.NETWORK_EGRESS_POLICY, optional Determines whether the given custom model is isolated, or can access the public network. Values: [datarobot.NETWORK_EGRESS_POLICY.NONE, datarobot.NETWORK_EGRESS_POLICY.PUBLIC].
maximum_memory Optional[int] The maximum memory that might be allocated by the custom-model. If exceeded, the custom-model will be killed by k8s
replicas Optional[int] A fixed number of replicas that will be deployed in the cluster

Returns

Returns Description
created custom model test

Return type: CustomModelTest

Raises

Exception Description
datarobot.errors.ClientError if the server responded with 4xx status
datarobot.errors.ServerError if the server responded with 5xx status

list()

classmethod list()

List custom model tests.

Added in version v2.21.

Parameters

Parameter Type Description
custom_model_id str the ID of the custom model

Returns

Returns Description
a list of custom model tests

Return type: List[CustomModelTest]

Raises

Exception Description
datarobot.errors.ClientError if the server responded with 4xx status
datarobot.errors.ServerError if the server responded with 5xx status

get()

classmethod get()

Get custom model test by id.

Added in version v2.21.

Parameters

Parameter Type Description
custom_model_test_id str the ID of the custom model test

Returns

Returns Description
retrieved custom model test

Return type: CustomModelTest

Raises

Exception Description
datarobot.errors.ClientError if the server responded with 4xx status.
datarobot.errors.ServerError if the server responded with 5xx status.

get_log()

method get_log()

Get log of a custom model test.

Added in version v2.21.

Raises

Exception Description
datarobot.errors.ClientError if the server responded with 4xx status
datarobot.errors.ServerError if the server responded with 5xx status

Return type: str

get_log_tail()

method get_log_tail()

Get log tail of a custom model test.

Added in version v2.21.

Raises

Exception Description
datarobot.errors.ClientError if the server responded with 4xx status
datarobot.errors.ServerError if the server responded with 5xx status

Return type: str

cancel()

method cancel()

Cancel custom model test that is in progress.

Added in version v2.21.

Raises

Exception Description
datarobot.errors.ClientError if the server responded with 4xx status
datarobot.errors.ServerError if the server responded with 5xx status

Return type: None

refresh()

method refresh()

Update custom model test with the latest data from server.

Added in version v2.21.

Raises

Exception Description
datarobot.errors.ClientError if the server responded with 4xx status
datarobot.errors.ServerError if the server responded with 5xx status

Return type: None

CustomModelVersion

class datarobot.CustomModelVersion

A version of a DataRobot custom model.

Added in version v2.21.

Variables

Attribute Type Description
id str The ID of the custom model version.
custom_model_id str The ID of the custom model.
version_minor int A minor version number of the custom model version.
version_major int A major version number of the custom model version.
is_frozen bool A flag if the custom model version is frozen.
items List[CustomModelFileItem] A list of file items attached to the custom model version.
base_environment_id str The ID of the environment to use with the model.
base_environment_version_id str The ID of the environment version to use with the model.
label Optional[str] A short human readable string to label the version.
description Optional[str] The custom model version description.
created_at Optional[str] ISO-8601 formatted timestamp of when the version was created.
dependencies List[CustomDependency] The parsed dependencies of the custom model version if the version has a valid requirements.txt file.
network_egress_policy datarobot.NETWORK_EGRESS_POLICY, optional Determines whether the given custom model is isolated, or can access the public network. Values: [datarobot.NETWORK_EGRESS_POLICY.NONE, datarobot.NETWORK_EGRESS_POLICY.PUBLIC].
maximum_memory Optional[int] The maximum memory that might be allocated by the custom-model. If exceeded, the custom-model will be killed by k8s.
replicas Optional[int] A fixed number of replicas that will be deployed in the cluster.
required_metadata_values List[RequiredMetadataValue] Additional parameters required by the execution environment. The required keys are defined by the fieldNames in the base environment’s requiredMetadataKeys.
training_data TrainingData, optional The information about the training data assigned to the model version.
holdout_data HoldoutData, optional The information about the holdout data assigned to the model version.
runtime_parameters List[RuntimeParameter], optional The runtime parameter definitions attached to this model version.

from_server_data()

classmethod from_server_data()

Instantiate an object of this class using the data directly from the server, meaning that the keys may have the wrong camel casing

Parameters

Parameter Type Description
data dict The directly translated dict of JSON from the server. No casing fixes have taken place
keep_attrs iterable List, set or tuple of the dotted namespace notations for attributes to keep within the object structure even if their values are None

Return type: CustomModelVersion

create_clean()

classmethod create_clean()

Create a custom model version without files from previous versions.

Create a version with training or holdout data: If training/holdout data related parameters are provided, the training data is assigned asynchronously. In this case: * if max_wait is not None, the function returns once the job is finished. * if max_wait is None, the function returns immediately. Progress can be polled by the user (see examples).

If training data assignment fails, new version is still created, but it is not allowed to create a model package (version) for the model version and to deploy it. To check for training data assignment error, check version.training_data.assignment_error[“message”].

Added in version v2.21.

Parameters

Parameter Type Description
custom_model_id str The ID of the custom model.
base_environment_id str The base environment to use with this model version. At least one of “base_environment_id” and “base_environment_version_id” must be provided. If both are specified, the version must belong to the environment.
base_environment_version_id str The base environment version ID to use with this model version. At least one of “base_environment_id” and “base_environment_version_id” must be provided. If both are specified, the version must belong to the environment. If not specified: in case previous model versions exist, the value from the latest model version is inherited, otherwise, latest successfully built version of the environment specified in “base_environment_id” is used.
is_major_update Optional[bool] The flag defining if a custom model version will be a minor or a major version. Default to True
folder_path Optional[str] The path to a folder containing files to be uploaded. Each file in the folder is uploaded under path relative to a folder path.
files Optional[List] The list of tuples, where values in each tuple are the local filesystem path and the path the file should be placed in the model. If the list is of strings, then basenames will be used for tuples. Example:[(“/home/user/Documents/myModel/file1.txt”, “file1.txt”), (“/home/user/Documents/myModel/folder/file2.txt”, “folder/file2.txt”)] or [“/home/user/Documents/myModel/file1.txt”, “/home/user/Documents/myModel/folder/file2.txt”]
network_egress_policy datarobot.NETWORK_EGRESS_POLICY, optional Determines whether the given custom model is isolated, or can access the public network. Values: [datarobot.NETWORK_EGRESS_POLICY.NONE, datarobot.NETWORK_EGRESS_POLICY.PUBLIC].
maximum_memory Optional[int] The maximum memory that might be allocated by the custom-model. If exceeded, the custom-model will be killed by k8s.
replicas Optional[int] A fixed number of replicas that will be deployed in the cluster.
required_metadata_values List[RequiredMetadataValue] Additional parameters required by the execution environment. The required keys are defined by the fieldNames in the base environment’s requiredMetadataKeys.
training_dataset_id Optional[str] The ID of the training dataset to assign to the custom model.
partition_column Optional[str] Name of a partition column in a training dataset assigned to the custom model. Can only be assigned for structured models.
holdout_dataset_id Optional[str] The ID of the holdout dataset to assign to the custom model. Can only be assigned for unstructured models.
keep_training_holdout_data Optional[bool] If the version should inherit training and holdout data from the previous version. Defaults to True. This field is only applicable if the model has training data for versions enabled, otherwise the field value will be ignored.
max_wait Optional[int] Max time to wait for training data assignment. If set to None - method will return without waiting. Defaults to 10 minutes.
runtime_parameter_values List[RuntimeParameterValue] Additional parameters to be injected into a model at runtime. The fieldName must match a fieldName that is listed in the runtimeParameterDefinitions section of the model-metadata.yaml file.

Returns

Returns Description
Created custom model version.

Return type: CustomModelVersion

Raises

Exception Description
datarobot.errors.ClientError If the server responded with 4xx status.
datarobot.errors.ServerError If the server responded with 5xx status.
datarobot.errors.InvalidUsageError If wrong parameters are provided.
datarobot.errors.TrainingDataAssignmentError If training data assignment fails.

Examples

Create a version with blocking (default max_wait=600) training data assignment:

import datarobot as dr
from datarobot.errors import TrainingDataAssignmentError

dr.Client(token=my_token, endpoint=endpoint)

try:
    version = dr.CustomModelVersion.create_clean(
        custom_model_id="6444482e5583f6ee2e572265",
        base_environment_id="642209acc563893014a41e24",
        training_dataset_id="6421f2149a4f9b1bec6ad6dd",
    )
except TrainingDataAssignmentError as e:
    print(e)

Create a version with non-blocking training data assignment:

import datarobot as dr

dr.Client(token=my_token, endpoint=endpoint)

version = dr.CustomModelVersion.create_clean(
    custom_model_id="6444482e5583f6ee2e572265",
    base_environment_id="642209acc563893014a41e24",
    training_dataset_id="6421f2149a4f9b1bec6ad6dd",
    max_wait=None,
)

while version.training_data.assignment_in_progress:
    time.sleep(10)
    version.refresh()
if version.training_data.assignment_error:
    print(version.training_data.assignment_error["message"])

create_from_previous()

classmethod create_from_previous()

Create a custom model version containing files from a previous version.

Create a version with training/holdout data: If training/holdout data related parameters are provided, the training data is assigned asynchronously. In this case: * if max_wait is not None, function returns once job is finished. * if max_wait is None, function returns immediately, progress can be polled by the user, see examples.

If training data assignment fails, new version is still created, but it is not allowed to create a model package (version) for the model version and to deploy it. To check for training data assignment error, check version.training_data.assignment_error[“message”].

Added in version v2.21.

Parameters

Parameter Type Description
custom_model_id str The ID of the custom model.
base_environment_id str The base environment to use with this model version. At least one of “base_environment_id” and “base_environment_version_id” must be provided. If both are specified, the version must belong to the environment.
base_environment_version_id str The base environment version ID to use with this model version. At least one of “base_environment_id” and “base_environment_version_id” must be provided. If both are specified, the version must belong to the environment. If not specified: in case previous model versions exist, the value from the latest model version is inherited, otherwise, latest successfully built version of the environment specified in “base_environment_id” is used.
is_major_update Optional[bool] The flag defining if a custom model version will be a minor or a major version. Defaults to True.
folder_path Optional[str] The path to a folder containing files to be uploaded. Each file in the folder is uploaded under path relative to a folder path.
files Optional[List] The list of tuples, where values in each tuple are the local filesystem path and the path the file should be placed in the model. If list is of strings, then basenames will be used for tuples Example:[(“/home/user/Documents/myModel/file1.txt”, “file1.txt”), (“/home/user/Documents/myModel/folder/file2.txt”, “folder/file2.txt”)] or [“/home/user/Documents/myModel/file1.txt”, “/home/user/Documents/myModel/folder/file2.txt”]
files_to_delete Optional[List] The list of a file items ids to be deleted. Example: [“5ea95f7a4024030aba48e4f9”, “5ea6b5da402403181895cc51”]
network_egress_policy datarobot.NETWORK_EGRESS_POLICY, optional Determines whether the given custom model is isolated, or can access the public network. Values: [datarobot.NETWORK_EGRESS_POLICY.NONE, datarobot.NETWORK_EGRESS_POLICY.PUBLIC].
maximum_memory Optional[int] The maximum memory that might be allocated by the custom-model. If exceeded, the custom-model will be killed by k8s
replicas Optional[int] A fixed number of replicas that will be deployed in the cluster
required_metadata_values List[RequiredMetadataValue] Additional parameters required by the execution environment. The required keys are defined by the fieldNames in the base environment’s requiredMetadataKeys.
training_dataset_id Optional[str] The ID of the training dataset to assign to the custom model.
partition_column Optional[str] Name of a partition column in a training dataset assigned to the custom model. Can only be assigned for structured models.
holdout_dataset_id Optional[str] The ID of the holdout dataset to assign to the custom model. Can only be assigned for unstructured models.
keep_training_holdout_data Optional[bool] If the version should inherit training and holdout data from the previous version. Defaults to True. This field is only applicable if the model has training data for versions enabled, otherwise the field value will be ignored.
max_wait Optional[int] Max time to wait for training data assignment. If set to None - method will return without waiting. Defaults to 10 minutes.
runtime_parameter_values List[RuntimeParameterValue] Additional parameters to be injected into the model at runtime. The fieldName must match a fieldName that is listed in the runtimeParameterDefinitions section of the model-metadata.yaml file. This list will be merged with any existing runtime values set from the prior version, so it is possible to specify a null value to unset specific parameters and fall back to the defaultValue from the definition. Mutually exclusive with runtime_parameters.
runtime_parameters List[RuntimeParameter], optional Full parameter definitions to create or replace on this version. Unlike runtime_parameter_values (which only sets override values), this field performs a snapshot replacement — any parameter not present in the list is deleted from the version. Mutually exclusive with runtime_parameter_values. Requires the server to have the runtime parameters batch update feature enabled;if unsupported, the server will return a ClientError.

Returns

Returns Description
created custom model version

Return type: CustomModelVersion

Raises

Exception Description
datarobot.errors.ClientError If the server responded with 4xx status.
datarobot.errors.ServerError If the server responded with 5xx status.
datarobot.errors.InvalidUsageError If wrong parameters are provided.
datarobot.errors.TrainingDataAssignmentError If training data assignment fails.

Examples

Create a version with blocking (default max_wait=600) training data assignment:

import datarobot as dr
from datarobot.errors import TrainingDataAssignmentError

dr.Client(token=my_token, endpoint=endpoint)

try:
    version = dr.CustomModelVersion.create_from_previous(
        custom_model_id="6444482e5583f6ee2e572265",
        base_environment_id="642209acc563893014a41e24",
        training_dataset_id="6421f2149a4f9b1bec6ad6dd",
    )
except TrainingDataAssignmentError as e:
    print(e)

Create a version with non-blocking training data assignment:

import datarobot as dr

dr.Client(token=my_token, endpoint=endpoint)

version = dr.CustomModelVersion.create_from_previous(
    custom_model_id="6444482e5583f6ee2e572265",
    base_environment_id="642209acc563893014a41e24",
    training_dataset_id="6421f2149a4f9b1bec6ad6dd",
    max_wait=None,
)

while version.training_data.assignment_in_progress:
    time.sleep(10)
    version.refresh()
if version.training_data.assignment_error:
    print(version.training_data.assignment_error["message"])

list()

classmethod list()

List custom model versions.

Added in version v2.21.

Parameters

Parameter Type Description
custom_model_id str The ID of the custom model.

Returns

Returns Description
A list of custom model versions.

Return type: List[CustomModelVersion]

Raises

Exception Description
datarobot.errors.ClientError If the server responded with 4xx status.
datarobot.errors.ServerError If the server responded with 5xx status.

get()

classmethod get()

Get custom model version by id.

Added in version v2.21.

Parameters

Parameter Type Description
custom_model_id str The ID of the custom model.
custom_model_version_id str The id of the custom model version to retrieve.

Returns

Returns Description
Retrieved custom model version.

Return type: CustomModelVersion

Raises

Exception Description
datarobot.errors.ClientError If the server responded with 4xx status.
datarobot.errors.ServerError If the server responded with 5xx status.

download()

method download()

Download custom model version.

Added in version v2.21.

Parameters

Parameter Type Description
file_path str Path to create a file with custom model version content.

Raises

Exception Description
datarobot.errors.ClientError If the server responded with 4xx status.
datarobot.errors.ServerError If the server responded with 5xx status.

Return type: None

update()

method update()

Update custom model version properties.

Added in version v2.21.

Parameters

Parameter Type Description
description Optional[str] New custom model version description.
required_metadata_values List[RequiredMetadataValue], optional Additional parameters required by the execution environment. The required keys are defined by the fieldNames in the base environment’s requiredMetadataKeys.

Raises

Exception Description
datarobot.errors.ClientError If the server responded with 4xx status.
datarobot.errors.ServerError If the server responded with 5xx status.

Return type: None

refresh()

method refresh()

Update custom model version with the latest data from server.

Added in version v2.21.

Raises

Exception Description
datarobot.errors.ClientError If the server responded with 4xx status.
datarobot.errors.ServerError If the server responded with 5xx status.

Return type: None

get_feature_impact()

method get_feature_impact()

Get custom model feature impact.

Added in version v2.23.

Parameters

Parameter Type Description
with_metadata bool The flag indicating if the result should include the metadata as well.

Returns

Returns Description
feature_impacts The feature impact data. Each item is a dict with the keys ‘featureName’, ‘impactNormalized’, and ‘impactUnnormalized’, and ‘redundantWith’.

Return type: list of dict

Raises

Exception Description
datarobot.errors.ClientError If the server responded with 4xx status.
datarobot.errors.ServerError If the server responded with 5xx status.

calculate_feature_impact()

method calculate_feature_impact()

Calculate custom model feature impact.

Added in version v2.23.

Parameters

Parameter Type Description
max_wait Optional[int] Max time to wait for feature impact calculation. If set to None - method will return without waiting. Defaults to 10 min

Raises

Exception Description
datarobot.errors.ClientError if the server responded with 4xx status
datarobot.errors.ServerError if the server responded with 5xx status

Return type: None

RequiredMetadataKey

class datarobot.models.execution_environment.RequiredMetadataKey

Definition of a metadata key that custom models using this environment must define

Added in version v2.25.

Variables

Attribute Type Description
field_name str The required field key. This value will be added as an environment variable when running custom models.
display_name str A human readable name for the required field.

CustomModelVersionConversion

class datarobot.models.CustomModelVersionConversion

A conversion of a DataRobot custom model version.

Added in version v2.27.

Variables

Attribute Type Description
id str The ID of the custom model version conversion.
custom_model_version_id str The ID of the custom model version.
created str ISO-8601 timestamp of when the custom model conversion created.
main_program_item_id str or None The ID of the main program item.
log_message str or None The conversion output log message.
generated_metadata dict or None The dict contains two items: ‘outputDataset’ & ‘outputColumns’.
conversion_succeeded bool Whether the conversion succeeded or not.
conversion_in_progress bool Whether a given conversion is in progress or not.
should_stop bool Whether the user asked to stop a conversion.

run_conversion()

classmethod run_conversion()

Initiate a new custom model version conversion.

Parameters

Parameter Type Description
custom_model_id str The associated custom model ID.
custom_model_version_id str The associated custom model version ID.
main_program_item_id str The selected main program item ID. This should be one of the SAS items in the associated custom model version.
max_wait int or None Max wait time in seconds. If None, then don’t wait.

Returns

Returns Description
conversion_id The ID of the newly created conversion entity.

Return type: str

Raises

Exception Description
datarobot.errors.ClientError If the server responded with 4xx status.
datarobot.errors.ServerError If the server responded with 5xx status.

stop_conversion()

classmethod stop_conversion()

Stop a conversion that is in progress.

Parameters

Parameter Type Description
custom_model_id str The ID of the associated custom model.
custom_model_version_id str The ID of the associated custom model version.
conversion_id str The ID of a conversion that is in-progress.

Raises

Exception Description
datarobot.errors.ClientError If the server responded with 4xx status.
datarobot.errors.ServerError If the server responded with 5xx status.

Return type: Response

get()

classmethod get()

Get custom model version conversion by id.

Added in version v2.27.

Parameters

Parameter Type Description
custom_model_id str The ID of the custom model.
custom_model_version_id str The ID of the custom model version.
conversion_id str The ID of the conversion to retrieve.

Returns

Returns Description
Retrieved custom model version conversion.

Return type: CustomModelVersionConversion

Raises

Exception Description
datarobot.errors.ClientError If the server responded with 4xx status.
datarobot.errors.ServerError If the server responded with 5xx status.

get_latest()

classmethod get_latest()

Get latest custom model version conversion for a given custom model version.

Added in version v2.27.

Parameters

Parameter Type Description
custom_model_id str The ID of the custom model.
custom_model_version_id str The ID of the custom model version.

Returns

Returns Description
Retrieved latest conversion for a given custom model version.

Return type: CustomModelVersionConversion or None

Raises

Exception Description
datarobot.errors.ClientError If the server responded with 4xx status.
datarobot.errors.ServerError If the server responded with 5xx status.

list()

classmethod list()

Get custom model version conversions list per custom model version.

Added in version v2.27.

Parameters

Parameter Type Description
custom_model_id str The ID of the custom model.
custom_model_version_id str The ID of the custom model version.

Returns

Returns Description
Retrieved conversions for a given custom model version.

Return type: List[CustomModelVersionConversion]

Raises

Exception Description
datarobot.errors.ClientError If the server responded with 4xx status.
datarobot.errors.ServerError If the server responded with 5xx status.

CustomModelVersionDependencyBuild

class datarobot.CustomModelVersionDependencyBuild

Metadata about a DataRobot custom model version’s dependency build

Added in version v2.22.

Variables

Attribute Type Description
custom_model_id str The ID of the custom model.
custom_model_version_id str The ID of the custom model version.
build_status str The status of the custom model version’s dependency build.
started_at str ISO-8601 formatted timestamp of when the build was started.
completed_at Optional[str] ISO-8601 formatted timestamp of when the build has completed.

get_build_info()

classmethod get_build_info()

Retrieve information about a custom model version’s dependency build

Added in version v2.22.

Parameters

Parameter Type Description
custom_model_id str The ID of the custom model.
custom_model_version_id str The ID of the custom model version.

Returns

Returns Description
The dependency build information.

Return type: CustomModelVersionDependencyBuild

start_build()

classmethod start_build()

Start the dependency build for a custom model version dependency build

Added in version v2.22.

Parameters

Parameter Type Description
custom_model_id str The ID of the custom model
custom_model_version_id str the ID of the custom model version
max_wait Optional[int] Max time to wait for a build completion. If set to None - method will return without waiting.

Return type: Optional[CustomModelVersionDependencyBuild]

get_log()

method get_log()

Get log of a custom model version dependency build.

Added in version v2.22.

Raises

Exception Description
datarobot.errors.ClientError If the server responded with 4xx status.
datarobot.errors.ServerError If the server responded with 5xx status.

Return type: str

cancel()

method cancel()

Cancel custom model version dependency build that is in progress.

Added in version v2.22.

Raises

Exception Description
datarobot.errors.ClientError If the server responded with 4xx status.
datarobot.errors.ServerError If the server responded with 5xx status.

Return type: None

refresh()

method refresh()

Update custom model version dependency build with the latest data from server.

Added in version v2.22.

Raises

Exception Description
datarobot.errors.ClientError If the server responded with 4xx status.
datarobot.errors.ServerError If the server responded with 5xx status.

Return type: None

ExecutionEnvironment

class datarobot.ExecutionEnvironment

An execution environment entity.

Added in version v2.21.

Variables

Attribute Type Description
id str The ID of the execution environment.
name str The name of the execution environment.
description Optional[str] The description of the execution environment.
programming_language Optional[str] The programming language of the execution environment. Can be “python”, “r”, “java” or “other”.
is_public Optional[bool] Public accessibility of environment, visible only for admin user.
created_at Optional[str] ISO-8601 formatted timestamp of when the execution environment version was created.
latest_version ExecutionEnvironmentVersion, optional The latest version of the execution environment.
latest_successful_version ExecutionEnvironmentVersion, optional The latest version of the execution environment, which contains a successfully built image.
required_metadata_keys Optional[List[RequiredMetadataKey]] The definition of metadata keys that custom models using this environment must define.
use_cases Optional[List[str]] A list of use-cases this environment may be used for.

create()

classmethod create()

Create an execution environment.

Added in version v2.21.

Parameters

Parameter Type Description
name str execution environment name
description Optional[str] execution environment description
programming_language Optional[str] programming language of the environment to be created. Can be “python”, “r”, “java” or “other”. Default value - “other”
required_metadata_keys List[RequiredMetadataKey] Definition of a metadata keys that custom models using this environment must define
is_public bool, optional public accessibility of environment
use_cases List[str], optional List of use-cases this environment may be used for

Returns

Returns Description
created execution environment

Return type: ExecutionEnvironment

Raises

Exception Description
datarobot.errors.ClientError if the server responded with 4xx status
datarobot.errors.ServerError if the server responded with 5xx status

list()

classmethod list()

List execution environments available to the user.

Added in version v2.21.

Parameters

Parameter Type Description
search_for Optional[str] the string for filtering execution environment - only execution environments that contain the string in name or description will be returned.
is_own bool, optional Only return execution environments that were created by the current user.
use_cases str, optional Only return execution environments that contain the specified use case
is_public Optional[bool] Only return execution environments matching this parameter value.
offset Optional[int] The starting offset of the results. The default is 0.
limit Optional[int] The maximum number of objects to return. The default is 0 to maintain previous behavior. The default on the server is 20, with a maximum of 100.

Returns

Returns Description
a list of execution environments.

Return type: List[ExecutionEnvironment]

Raises

Exception Description
datarobot.errors.ClientError if the server responded with 4xx status
datarobot.errors.ServerError if the server responded with 5xx status

get()

classmethod get()

Get execution environment by its ID.

Added in version v2.21.

Parameters

Parameter Type Description
execution_environment_id str ID of the execution environment to retrieve

Returns

Returns Description
retrieved execution environment

Return type: ExecutionEnvironment

Raises

Exception Description
datarobot.errors.ClientError if the server responded with 4xx status
datarobot.errors.ServerError if the server responded with 5xx status

delete()

method delete()

Delete execution environment.

Added in version v2.21.

Raises

Exception Description
datarobot.errors.ClientError if the server responded with 4xx status
datarobot.errors.ServerError if the server responded with 5xx status

Return type: None

update()

method update()

Update execution environment properties.

Added in version v2.21.

Parameters

Parameter Type Description
name Optional[str] new execution environment name
description Optional[str] new execution environment description
required_metadata_keys List[RequiredMetadataKey] Definition of a metadata keys that custom models using this environment must define
is_public bool, optional public accessibility of environment
use_cases List[str], optional List of use-cases this environment may be used for

Raises

Exception Description
datarobot.errors.ClientError if the server responded with 4xx status
datarobot.errors.ServerError if the server responded with 5xx status

Return type: None

refresh()

method refresh()

Update execution environment with the latest data from server.

Added in version v2.21.

Raises

Exception Description
datarobot.errors.ClientError if the server responded with 4xx status
datarobot.errors.ServerError if the server responded with 5xx status

Return type: None

get_access_list()

method get_access_list()

Retrieve access control settings of this environment.

Added in version v2.36.

Return type: list of SharingAccess

share()

method share()

Update the access control settings of this execution environment.

Added in version v2.36.

Parameters

Parameter Type Description
access_list list of SharingAccess A list of SharingAccess to update.

Raises

Exception Description
datarobot.errors.ClientError if the server responded with 4xx status
datarobot.errors.ServerError if the server responded with 5xx status

Return type: None

Examples

Transfer access to the execution environment from old_user@datarobot.com to new_user@datarobot.com

import datarobot as dr

new_access = dr.SharingAccess(new_user@datarobot.com,
                              dr.enums.SHARING_ROLE.OWNER, can_share=True)
access_list = [dr.SharingAccess(old_user@datarobot.com, None), new_access]

dr.ExecutionEnvironment.get('environment-id').share(access_list)

ExecutionEnvironmentVersion

class datarobot.ExecutionEnvironmentVersion

A version of a DataRobot execution environment.

Added in version v2.21.

Variables

Attribute Type Description
id str the ID of the execution environment version
environment_id str the ID of the execution environment the version belongs to
build_status str the status of the execution environment version build
image_id str The Docker image ID of the environment version.
label Optional[str] the label of the execution environment version
description Optional[str] the description of the execution environment version
created_at Optional[str] ISO-8601 formatted timestamp of when the execution environment version was created
docker_context_size Optional[int] The size of the uploaded Docker context in bytes if available or None if not
docker_image_size Optional[int] The size of the built Docker image in bytes if available or None if not
docker_image_uri Optional[str] The URI that the source Docker image execution environment version is based on. Set to None if there is not one provided.

create()

classmethod create()

Create an execution environment version.

Added in version v2.21.

Parameters

Parameter Type Description
execution_environment_id str the ID of the execution environment
docker_context_path Optional[str] The path to a Docker context archive or folder. This parameter has lower priority than docker_image_uri if they are both provided.
docker_image_uri Optional[str] The docker_image_uri to be used as an environment. It has priority over the docker_context_path. If both are provided, the environment is created from docker_image_uri, and context is uploaded for information purposes.
label Optional[str] A human-readable string to label the version.
description Optional[str] execution environment version description
max_wait Optional[int] max time to wait for a final build status (“success” or “failed”). If set to None - method will return without waiting.

Returns

Returns Description
created execution environment version

Return type: ExecutionEnvironmentVersion

Raises

Exception Description
datarobot.errors.AsyncTimeoutError if version did not reach final state during timeout seconds
datarobot.errors.ClientError if the server responded with 4xx status
datarobot.errors.ServerError if the server responded with 5xx status

list()

classmethod list()

List execution environment versions available to the user. .. versionadded:: v2.21

Parameters

Parameter Type Description
execution_environment_id str the ID of the execution environment
build_status Optional[str] build status of the execution environment version to filter by. See datarobot.enums.EXECUTION_ENVIRONMENT_VERSION_BUILD_STATUS for valid options

Returns

Returns Description
a list of execution environment versions.

Return type: List[ExecutionEnvironmentVersion]

Raises

Exception Description
datarobot.errors.ClientError if the server responded with 4xx status
datarobot.errors.ServerError if the server responded with 5xx status

get()

classmethod get()

Get execution environment version by id.

Added in version v2.21.

Parameters

Parameter Type Description
execution_environment_id str the ID of the execution environment
version_id str the ID of the execution environment version to retrieve

Returns

Returns Description
retrieved execution environment version

Return type: ExecutionEnvironmentVersion

Raises

Exception Description
datarobot.errors.ClientError if the server responded with 4xx status.
datarobot.errors.ServerError if the server responded with 5xx status.

download()

method download()

Download execution environment version.

Added in version v2.21.

Parameters

Parameter Type Description
file_path str path to create a file with execution environment version content

Returns

Returns Description
retrieved execution environment version

Return type: ExecutionEnvironmentVersion

Raises

Exception Description
datarobot.errors.ClientError if the server responded with 4xx status.
datarobot.errors.ServerError if the server responded with 5xx status.

get_build_log()

method get_build_log()

Get execution environment version build log and error.

Added in version v2.21.

Returns

Returns Description
retrieved execution environment version build log and error.
If there is no build error - None is returned.

Return type: Tuple[str, str]

Raises

Exception Description
datarobot.errors.ClientError if the server responded with 4xx status.
datarobot.errors.ServerError if the server responded with 5xx status.

refresh()

method refresh()

Update execution environment version with the latest data from server.

Added in version v2.21.

Raises

Exception Description
datarobot.errors.ClientError if the server responded with 4xx status
datarobot.errors.ServerError if the server responded with 5xx status

Return type: None

HoldoutData

class datarobot.models.custom_model_version.HoldoutData

Holdout data assigned to a DataRobot custom model version.

Added in version v3.2.

Variables

Attribute Type Description
dataset_id str The ID of the dataset.
dataset_version_id str The ID of the dataset version.
dataset_name str The name of the dataset.
partition_column str The name of the partitions column.

TrainingData

class datarobot.models.custom_model_version.TrainingData

Training data assigned to a DataRobot custom model version.

Added in version v3.2.

Variables

Attribute Type Description
dataset_id str The ID of the dataset.
dataset_version_id str The ID of the dataset version.
dataset_name str The name of the dataset.
assignment_in_progress bool The status of the assignment in progress.
assignment_error dict The assignment error message.

RuntimeParameter

class datarobot.models.custom_model_version.RuntimeParameter

Definition of a runtime parameter used for the custom model version, it includes : the override value if provided.

Added in version v3.4.0.

Variables

Attribute Type Description
field_name str The runtime parameter name. This value is added as an environment variable when running custom models.
type str The value type accepted by the runtime parameter.
description str Describes how the runtime parameter impacts the running model.
allow_empty bool Indicates if the runtime parameter must be set before registration.
min_value float The minimum value for a numeric field.
max_value float The maximum value for a numeric field.
default_value str, bool, float or None The default value for the given field.
override_value str, bool, float or None The value set by the user that overrides the default set in the runtime parameter definition.
current_value str, bool, float or None After the default and the override values are applied, this is the value of the runtime parameter.
credential_type str Describes the type of credential, used only for credentials parameters.
key_value_id str or None The ID of the key-value store entry that holds the current value of this parameter. Populated by the server; not required when creating or updating parameters.

to_dict()

method to_dict()

Serialize this parameter for use in the runtime_parameters creation argument.

Returns a dict with snake_case keys that are converted to camelCase before sending to the API. Only fields relevant to parameter creation are included; server-computed fields (override_value, key_value_id) are excluded. Optional fields with a None value are omitted so the server applies its own defaults.

Return type: Dict[str, Any]

RuntimeParameterValue

class datarobot.models.custom_model_version.RuntimeParameterValue

The definition of a runtime parameter value used for the custom model version, this defines the runtime parameter override.

Added in version v3.4.0.

Variables

Attribute Type Description
field_name str The runtime parameter name. This value is added as an environment variable when running custom models.
type str The value type accepted by the runtime parameter.
value str, bool or float After the default and the override values are applied, this is the value of the runtime parameter.