Custom models

class datarobot.models.custom_model_version.CustomModelFileItem

A file item attached to a DataRobot custom model version.

Added in version v2.21.

Variables:
  • 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.

class datarobot.CustomInferenceModel

A custom inference model.

Added in version v2.21.

Variables:
  • 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.

classmethod list(is_deployed=None, search_for=None, order_by=None)

Returns a list of custom inference models available to the user.

Added in version v2.21.

Parameters:
  • 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:

A list of custom inference models.

Return type:

List[CustomInferenceModel]

Raises:
classmethod get(custom_model_id)

Returns the custom inference model by ID.

Added in version v2.21.

Parameters:

custom_model_id (str) – The ID of the custom inference model.

Returns:

Retrieved custom inference model.

Return type:

CustomInferenceModel

Raises:
download_latest_version(file_path)

Download the latest custom inference model version.

Added in version v2.21.

Parameters:

file_path (str) – Path to create a file with custom model version content.

Raises:
Return type:

None

classmethod create(name, target_type, target_name=None, language=None, description=None, positive_class_label=None, negative_class_label=None, prediction_threshold=None, class_labels=None, class_labels_file=None, network_egress_policy=None, maximum_memory=None, replicas=None, is_training_data_for_versions_permanently_enabled=None)

Create a custom inference model.

Added in version v2.21.

Parameters:
  • 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:

Created a custom inference model.

Return type:

CustomInferenceModel

Raises:
classmethod copy_custom_model(custom_model_id)

Create a custom inference model by copying existing one.

Added in version v2.21.

Parameters:

custom_model_id (str) – The ID of the custom inference model to copy.

Returns:

Created a custom inference model.

Return type:

CustomInferenceModel

Raises:
update(name=None, language=None, description=None, target_name=None, positive_class_label=None, negative_class_label=None, prediction_threshold=None, class_labels=None, class_labels_file=None, is_training_data_for_versions_permanently_enabled=None)

Updates the custom inference model properties.

Added in version v2.21.

Parameters:
  • 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:
Return type:

None

refresh()

Updates the custom inference model with the latest data from server.

Added in version v2.21.

Raises:
Return type:

None

delete()

Deletes the custom inference model.

Added in version v2.21.

Raises:
Return type:

None

assign_training_data(dataset_id, partition_column=None, max_wait=600)

Assign training data to the custom inference model.

Added in version v2.21.

Parameters:
  • 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:
Return type:

None

get_access_list()

Retrieve access control settings of this custom model.

Added in version v2.36.

Return type:

list of SharingAccess

share(access_list)

Update the access control settings of this custom model.

Added in version v2.36.

Parameters:

access_list (list of SharingAccess) – A list of SharingAccess to update.

Raises:
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)
class datarobot.CustomModelTest

A custom model test.

Added in version v2.21.

Variables:
  • id (str) – The test ID.

  • custom_model_image_id (str) – The ID of a custom model image.

  • image_type (str) – The image type, 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 did 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 that maps the testing types to their status and message. The keys of the dict are one of errorCheck, nullValueImputation, longRunningService, sideEffects. The values are dicts with message and status keys.

  • created_by (str) – The user who created the test.

  • dataset_id (Optional[str]) – The ID of a dataset used for testing.

  • dataset_version_id (Optional[str]) – The 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.

classmethod create(custom_model_id, custom_model_version_id, dataset_id=None, max_wait=600, network_egress_policy=None, maximum_memory=None, replicas=None)

Creates a custom model test and starts it.

Added in version v2.21.

Parameters:
  • 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]) – The maximum 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:

The created custom model test.

Return type:

CustomModelTest

Raises:
classmethod list(custom_model_id)

Returns a list of custom model tests.

Added in version v2.21.

Parameters:

custom_model_id (str) – The ID of the custom model.

Returns:

A list of custom model tests.

Return type:

List[CustomModelTest]

Raises:
classmethod get(custom_model_test_id)

Returns the custom model test by ID.

Added in version v2.21.

Parameters:

custom_model_test_id (str) – The ID of the custom model test.

Returns:

The retrieved custom model test.

Return type:

CustomModelTest

Raises:
get_log()

Returns the log of a custom model test.

Added in version v2.21.

Raises:
Return type:

str

get_log_tail()

Returns the log tail of a custom model test.

Added in version v2.21.

Raises:
Return type:

str

cancel()

Cancels a custom model test that is in progress.

Added in version v2.21.

Raises:
Return type:

None

refresh()

Updates the custom model test with the latest data from the server.

Added in version v2.21.

Raises:
Return type:

None

class datarobot.CustomModelVersion

A version of a DataRobot custom model.

Added in version v2.21.

Variables:
  • 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.

classmethod from_server_data(data, keep_attrs=None)

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

Parameters:
  • data (dict) – The directly translated dict of JSON from the server. DataRobot has not applied casing fixes yet.

  • keep_attrs (iterable) – A 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

classmethod create_clean(custom_model_id, base_environment_id=None, is_major_update=True, folder_path=None, files=None, network_egress_policy=None, maximum_memory=None, replicas=None, required_metadata_values=None, training_dataset_id=None, partition_column=None, holdout_dataset_id=None, keep_training_holdout_data=None, max_wait=600, runtime_parameter_values=None, base_environment_version_id=None)

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:
  • 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 each tuple contains the local filesystem path and the target path in the model. If a list of strings is provided, basenames are used as target paths.

  • 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:

The created custom model version.

Return type:

CustomModelVersion

Raises:

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"])
classmethod create_from_previous(custom_model_id, base_environment_id=None, is_major_update=True, folder_path=None, files=None, files_to_delete=None, network_egress_policy=None, maximum_memory=None, replicas=None, required_metadata_values=None, training_dataset_id=None, partition_column=None, holdout_dataset_id=None, keep_training_holdout_data=None, max_wait=600, runtime_parameter_values=None, base_environment_version_id=None, runtime_parameters=None)

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:
  • 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 each tuple contains the local filesystem path and the target path in the model. If a list of strings is provided, basenames are used as target paths.

  • files_to_delete (Optional[List]) – The list of file item IDs to be deleted. For 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:

The created custom model version.

Return type:

CustomModelVersion

Raises:

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"])
classmethod list(custom_model_id)

Returns a list of custom model versions.

Added in version v2.21.

Parameters:

custom_model_id (str) – The ID of the custom model.

Returns:

A list of custom model versions.

Return type:

List[CustomModelVersion]

Raises:
classmethod get(custom_model_id, custom_model_version_id)

Returns the custom model version by ID.

Added in version v2.21.

Parameters:
  • 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:

Retrieved custom model version.

Return type:

CustomModelVersion

Raises:
download(file_path)

Downloads the custom model version.

Added in version v2.21.

Parameters:

file_path (str) – Path to create a file with custom model version content.

Raises:
Return type:

None

update(description=None, required_metadata_values=None)

Updates the custom model version properties.

Added in version v2.21.

Parameters:
  • 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:
Return type:

None

refresh()

Updates the custom model version with the latest data from the server.

Added in version v2.21.

Raises:
Return type:

None

get_feature_impact(with_metadata=False)

Returns the custom model feature impact.

Added in version v2.23.

Parameters:

with_metadata (bool) – The flag indicating if the result should include the metadata as well.

Returns:

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:
calculate_feature_impact(max_wait=600)

Calculates the custom model feature impact.

Added in version v2.23.

Parameters:

max_wait (Optional[int]) – The maximum time to wait for feature impact calculation. If set to None - method will return without waiting. Defaults to 10 minutes.

Raises:
Return type:

None

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:
  • 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.

class datarobot.models.CustomModelVersionConversion

A conversion of a DataRobot custom model version.

Added in version v2.27.

Variables:
  • 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 and 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.

classmethod run_conversion(custom_model_id, custom_model_version_id, main_program_item_id, max_wait=None)

Initiate a new custom model version conversion.

Parameters:
  • 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:

conversion_id – The ID of the newly created conversion entity.

Return type:

str

Raises:
classmethod stop_conversion(custom_model_id, custom_model_version_id, conversion_id)

Stop a conversion that is in progress.

Parameters:
  • 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:
Return type:

Response

classmethod get(custom_model_id, custom_model_version_id, conversion_id)

Returns the custom model version conversion by ID.

Added in version v2.27.

Parameters:
  • 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:

Retrieved custom model version conversion.

Return type:

CustomModelVersionConversion

Raises:
classmethod get_latest(custom_model_id, custom_model_version_id)

Returns the latest custom model version conversion for a given custom model version.

Added in version v2.27.

Parameters:
  • custom_model_id (str) – The ID of the custom model.

  • custom_model_version_id (str) – The ID of the custom model version.

Returns:

Retrieved latest conversion for a given custom model version.

Return type:

CustomModelVersionConversion or None

Raises:
classmethod list(custom_model_id, custom_model_version_id)

Returns a list of custom model version conversions for a custom model version.

Added in version v2.27.

Parameters:
  • custom_model_id (str) – The ID of the custom model.

  • custom_model_version_id (str) – The ID of the custom model version.

Returns:

Retrieved conversions for a given custom model version.

Return type:

List[CustomModelVersionConversion]

Raises:
class datarobot.CustomModelVersionDependencyBuild

Metadata about a DataRobot custom model version’s dependency build.

Added in version v2.22.

Variables:
  • 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.

classmethod get_build_info(custom_model_id, custom_model_version_id)

Retrieve information about a custom model version’s dependency build

Added in version v2.22.

Parameters:
  • custom_model_id (str) – The ID of the custom model.

  • custom_model_version_id (str) – The ID of the custom model version.

Returns:

The dependency build information.

Return type:

CustomModelVersionDependencyBuild

classmethod start_build(custom_model_id, custom_model_version_id, max_wait=600)

Starts the dependency build for a custom model version.

Added in version v2.22.

Parameters:
  • 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]) – The maximum time to wait for a build completion. If set to None - method will return without waiting.

Return type:

Optional[CustomModelVersionDependencyBuild]

get_log()

Returns the log of a custom model version dependency build.

Added in version v2.22.

Raises:
Return type:

str

cancel()

Cancels a custom model version dependency build that is in progress.

Added in version v2.22.

Raises:
Return type:

None

refresh()

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

Added in version v2.22.

Raises:
Return type:

None

class datarobot.ExecutionEnvironment

An execution environment entity.

Added in version v2.21.

Variables:
  • 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.

classmethod create(name, description=None, programming_language=None, required_metadata_keys=None, is_public=None, use_cases=None)

Creates an execution environment.

Added in version v2.21.

Parameters:
  • name (str) – The execution environment name.

  • description (Optional[str]) – The execution environment description.

  • programming_language (Optional[str]) – The programming language of the environment to be created. Can be “python”, “r”, “java” or “other”. Default value - “other”.

  • required_metadata_keys (List[RequiredMetadataKey]) – The definition of metadata keys that custom models using this environment must define.

  • is_public (bool, optional) – The public accessibility of environment.

  • use_cases (List[str], optional) – A list of use-cases this environment may be used for.

Returns:

The created execution environment.

Return type:

ExecutionEnvironment

Raises:
classmethod list(search_for=None, is_own=None, use_cases=None, is_public=None, offset=0, limit=0)

Returns a list of execution environments available to the user.

Added in version v2.21.

Parameters:
  • 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:

A list of execution environments.

Return type:

List[ExecutionEnvironment]

Raises:
classmethod get(execution_environment_id)

Returns the execution environment by its ID.

Added in version v2.21.

Parameters:

execution_environment_id (str) – The ID of the execution environment to retrieve.

Returns:

The retrieved execution environment.

Return type:

ExecutionEnvironment

Raises:
delete()

Deletes the execution environment.

Added in version v2.21.

Raises:
Return type:

None

update(name=None, description=None, required_metadata_keys=None, is_public=None, use_cases=None)

Updates the execution environment properties.

Added in version v2.21.

Parameters:
  • name (Optional[str]) – The new execution environment name.

  • description (Optional[str]) – The new execution environment description.

  • required_metadata_keys (List[RequiredMetadataKey]) – The definition of metadata keys that custom models using this environment must define.

  • is_public (bool, optional) – The public accessibility of environment.

  • use_cases (List[str], optional) – A list of use-cases this environment may be used for.

Raises:
Return type:

None

refresh()

Updates the execution environment with the latest data from server.

Added in version v2.21.

Raises:
Return type:

None

get_access_list()

Retrieve access control settings of this environment.

Added in version v2.36.

Return type:

list of SharingAccess

share(access_list)

Update the access control settings of this execution environment.

Added in version v2.36.

Parameters:

access_list (list of SharingAccess) – A list of SharingAccess to update.

Raises:
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)
class datarobot.ExecutionEnvironmentVersion

A version of a DataRobot execution environment.

Added in version v2.21.

Variables:
  • 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. When set to None if there is not one provided.

classmethod create(execution_environment_id, docker_context_path=None, docker_image_uri=None, label=None, description=None, max_wait=600)

Creates an execution environment version.

Added in version v2.21.

Parameters:
  • 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]) – The execution environment version description.

  • max_wait (Optional[int]) – The max time to wait for a final build status (“success” or “failed”). If set to None, the method will return without waiting.

Returns:

The created execution environment version.

Return type:

ExecutionEnvironmentVersion

Raises:
classmethod upload(execution_environment_id, docker_image_path, docker_context_path, label=None, description=None, max_wait=600)

Upload a pre-built Docker image tarball to create an execution environment version.

Added in version v3.18.

Parameters:
  • execution_environment_id (str) – The ID of the execution environment.

  • docker_image_path (str) – The path to a Docker image tarball file.

  • docker_context_path (str) – The path to a Docker context archive or folder.

  • label (Optional[str]) – A human-readable string to label the version.

  • description (Optional[str]) – The execution environment version description.

  • max_wait (Optional[int]) – The max time to wait for a final build status (“success” or “failed”). If set to None, then the method will return without waiting.

Returns:

The created execution environment version.

Return type:

ExecutionEnvironmentVersion

Raises:
classmethod list(execution_environment_id, build_status=None)

Returns a list of execution environment versions available to the user.

Added in version v2.21.

Parameters:
  • execution_environment_id (str) – The ID of the execution environment.

  • build_status (Optional[str]) – The build status of the execution environment version to filter by. See datarobot.enums.EXECUTION_ENVIRONMENT_VERSION_BUILD_STATUS for valid options.

Returns:

A list of execution environment versions.

Return type:

List[ExecutionEnvironmentVersion]

Raises:
classmethod get(execution_environment_id, version_id)

Returns the execution environment version by ID.

Added in version v2.21.

Parameters:
  • execution_environment_id (str) – The ID of the execution environment.

  • version_id (str) – The ID of the execution environment version to retrieve.

Returns:

The retrieved execution environment version.

Return type:

ExecutionEnvironmentVersion

Raises:
download(file_path)

Downloads the execution environment version.

Added in version v2.21.

Parameters:

file_path (str) – The path to create a file with execution environment version content.

Returns:

The retrieved execution environment version.

Return type:

ExecutionEnvironmentVersion

Raises:
get_build_log()

Returns the execution environment version build log and error.

Added in version v2.21.

Returns:

The retrieved execution environment version build log and error. If there is no build error, None is returned.

Return type:

Tuple[str, str]

Raises:
refresh()

Updates the execution environment version with the latest data from server.

Added in version v2.21.

Raises:
Return type:

None

class datarobot.models.custom_model_version.HoldoutData

Holdout data assigned to a DataRobot custom model version.

Added in version v3.2.

Variables:
  • 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.

class datarobot.models.custom_model_version.TrainingData

Training data assigned to a DataRobot custom model version.

Added in version v3.2.

Variables:
  • 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.

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:
  • 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()

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]

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:
  • 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.