Custom Models
- class datarobot.models.custom_model_version.CustomModelFileItem(id, file_name, file_path, file_source, created_at=None)
A file item attached to a DataRobot custom model version.
Added in version v2.21.
- Attributes:
- 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: str, optional
ISO-8601 formatted timestamp of when the version was created.
- class datarobot.CustomInferenceModel(**kwargs)
A custom inference model.
Added in version v2.21.
- Attributes:
- 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, optional
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: str
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: str, optional
The ID of a dataset assigned to the custom model.
- training_dataset_version_id: str, optional
The ID of a dataset version assigned to the custom model.
- training_data_file_name: str, optional
The name of assigned training data file.
- training_data_partition_column: str, optional
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: int, optional
The maximum memory that might be allocated by the custom-model. If exceeded, the custom-model will be killed by k8s.
- replicas: int, optional
A fixed number of replicas that will be deployed in the cluster
- is_training_data_for_versions_permanently_enabled: bool, optional
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)
List custom inference models available to the user. :rtype:
List
[CustomInferenceModel
]Added in version v2.21.
- Parameters:
- is_deployed: bool, optional
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: str, optional
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: str, optional
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:
- List[CustomInferenceModel]
A list of custom inference models.
- Raises:
- datarobot.errors.ClientError
If the server responded with 4xx status
- datarobot.errors.ServerError
If the server responded with 5xx status
- classmethod get(custom_model_id)
Get custom inference model by id. :rtype:
CustomInferenceModel
Added in version v2.21.
- Parameters:
- custom_model_id: str
The ID of the custom inference model.
- Returns:
- CustomInferenceModel
Retrieved custom inference model.
- Raises:
- 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(file_path)
Download the latest custom inference model version. :rtype:
None
Added in version v2.21.
- Parameters:
- file_path: str
Path to create a file with custom model version content.
- Raises:
- datarobot.errors.ClientError
If the server responded with 4xx status.
- datarobot.errors.ServerError
If the server responded with 5xx status.
- 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. :rtype:
CustomInferenceModel
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: str, optional
Target feature name. It is optional(ignored if provided) for datarobot.TARGET_TYPE.UNSTRUCTURED target type.
- language: str, optional
Programming language of the custom learning model.
- description: str, optional
Description of the custom learning model.
- positive_class_label: str, optional
Custom inference model positive class label for binary classification.
- negative_class_label: str, optional
Custom inference model negative class label for binary classification.
- prediction_threshold: float, optional
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: str, optional
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: int, optional
The maximum memory that might be allocated by the custom-model. If exceeded, the custom-model will be killed by k8s.
- replicas: int, optional
A fixed number of replicas that will be deployed in the cluster.
- is_training_data_for_versions_permanently_enabled: bool, optional
Permanently enable training data assignment on the version level for the current model, instead of training data assignment on the model level.
- Returns:
- CustomInferenceModel
Created a custom inference model.
- Raises:
- datarobot.errors.ClientError
If the server responded with 4xx status.
- datarobot.errors.ServerError
If the server responded with 5xx status.
- classmethod copy_custom_model(custom_model_id)
Create a custom inference model by copying existing one. :rtype:
CustomInferenceModel
Added in version v2.21.
- Parameters:
- custom_model_id: str
The ID of the custom inference model to copy.
- Returns:
- CustomInferenceModel
Created a custom inference model.
- Raises:
- datarobot.errors.ClientError
If the server responded with 4xx status.
- datarobot.errors.ServerError
If the server responded with 5xx status.
- 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)
Update custom inference model properties. :rtype:
None
Added in version v2.21.
- Parameters:
- name: str, optional
New custom inference model name.
- language: str, optional
New custom inference model programming language.
- description: str, optional
New custom inference model description.
- target_name: str, optional
New custom inference model target name.
- positive_class_label: str, optional
New custom inference model positive class label.
- negative_class_label: str, optional
New custom inference model negative class label.
- prediction_threshold: float, optional
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: str, optional
Path to file containing newline separated class labels for multiclass classification. Cannot be used with class_labels
- is_training_data_for_versions_permanently_enabled: bool, optional
Permanently enable training data assignment on the version level for the current model, instead of training data assignment on the model level.
- Raises:
- datarobot.errors.ClientError
If the server responded with 4xx status.
- datarobot.errors.ServerError
If the server responded with 5xx status.
- refresh()
Update custom inference model with the latest data from server. :rtype:
None
Added in version v2.21.
- Raises:
- datarobot.errors.ClientError
If the server responded with 4xx status.
- datarobot.errors.ServerError
If the server responded with 5xx status.
- delete()
Delete custom inference model. :rtype:
None
Added in version v2.21.
- Raises:
- datarobot.errors.ClientError
If the server responded with 4xx status.
- datarobot.errors.ServerError
If the server responded with 5xx status.
- assign_training_data(dataset_id, partition_column=None, max_wait=600)
Assign training data to the custom inference model. :rtype:
None
Added in version v2.21.
- Parameters:
- dataset_id: str
The ID of the training dataset to be assigned.
- partition_column: str, optional
The name of a partition column in the training dataset.
- max_wait: int, optional
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:
- datarobot.errors.ClientError
If the server responded with 4xx status
- datarobot.errors.ServerError
If the server responded with 5xx status
- class datarobot.CustomModelTest(**kwargs)
An custom model test.
Added in version v2.21.
- Attributes:
- 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: str, optional
id of a dataset used for testing
- dataset_version_id: str, optional
id of a dataset version used for testing
- completed_at: str, optional
ISO-8601 formatted timestamp of when the test has completed
- created_at: str, optional
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: int, optional
The maximum memory that might be allocated by the custom-model. If exceeded, the custom-model will be killed by k8s
- replicas: int, optional
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)
Create and start a custom model test.
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: str, optional
The id of the testing dataset for non-unstructured custom models. Ignored and not required for unstructured models.
- max_wait: int, optional
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: int, optional
The maximum memory that might be allocated by the custom-model. If exceeded, the custom-model will be killed by k8s
- replicas: int, optional
A fixed number of replicas that will be deployed in the cluster
- Returns:
- CustomModelTest
created custom model test
- Raises:
- datarobot.errors.ClientError
if the server responded with 4xx status
- datarobot.errors.ServerError
if the server responded with 5xx status
- classmethod list(custom_model_id)
List custom model tests.
Added in version v2.21.
- Parameters:
- custom_model_id: str
the id of the custom model
- Returns:
- List[CustomModelTest]
a list of custom model tests
- Raises:
- datarobot.errors.ClientError
if the server responded with 4xx status
- datarobot.errors.ServerError
if the server responded with 5xx status
- classmethod get(custom_model_test_id)
Get custom model test by id.
Added in version v2.21.
- Parameters:
- custom_model_test_id: str
the id of the custom model test
- Returns:
- CustomModelTest
retrieved custom model test
- Raises:
- datarobot.errors.ClientError
if the server responded with 4xx status.
- datarobot.errors.ServerError
if the server responded with 5xx status.
- get_log()
Get log of a custom model test.
Added in version v2.21.
- Raises:
- datarobot.errors.ClientError
if the server responded with 4xx status
- datarobot.errors.ServerError
if the server responded with 5xx status
- get_log_tail()
Get log tail of a custom model test.
Added in version v2.21.
- Raises:
- datarobot.errors.ClientError
if the server responded with 4xx status
- datarobot.errors.ServerError
if the server responded with 5xx status
- cancel()
Cancel custom model test that is in progress.
Added in version v2.21.
- Raises:
- datarobot.errors.ClientError
if the server responded with 4xx status
- datarobot.errors.ServerError
if the server responded with 5xx status
- refresh()
Update custom model test with the latest data from server.
Added in version v2.21.
- Raises:
- datarobot.errors.ClientError
if the server responded with 4xx status
- datarobot.errors.ServerError
if the server responded with 5xx status
- class datarobot.CustomModelVersion(**kwargs)
A version of a DataRobot custom model.
Added in version v2.21.
- Attributes:
- 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: str, optional
A short human readable string to label the version.
- description: str, optional
The custom model version description.
- created_at: str, optional
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: int, optional
The maximum memory that might be allocated by the custom-model. If exceeded, the custom-model will be killed by k8s.
- replicas: int, optional
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.
- 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:
- datadict
The directly translated dict of JSON from the server. No casing fixes have taken place
- keep_attrsiterable
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:
- 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. :rtype:
CustomModelVersion
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: bool, optional
The flag defining if a custom model version will be a minor or a major version. Default to True
- folder_path: str, optional
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: list, optional
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: int, optional
The maximum memory that might be allocated by the custom-model. If exceeded, the custom-model will be killed by k8s.
- replicas: int, optional
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: str, optional
The ID of the training dataset to assign to the custom model.
- partition_column: str, optional
Name of a partition column in a training dataset assigned to the custom model. Can only be assigned for structured models.
- holdout_dataset_id: str, optional
The ID of the holdout dataset to assign to the custom model. Can only be assigned for unstructured models.
- keep_training_holdout_data: bool, optional
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: int, optional
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:
- CustomModelVersion
Created custom model version.
- Raises:
- 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"])
- 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)
Create a custom model version containing files from a previous version. :rtype:
CustomModelVersion
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: bool, optional
The flag defining if a custom model version will be a minor or a major version. Defaults to True.
- folder_path: str, optional
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: list, optional
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: list, optional
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: int, optional
The maximum memory that might be allocated by the custom-model. If exceeded, the custom-model will be killed by k8s
- replicas: int, optional
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: str, optional
The ID of the training dataset to assign to the custom model.
- partition_column: str, optional
Name of a partition column in a training dataset assigned to the custom model. Can only be assigned for structured models.
- holdout_dataset_id: str, optional
The ID of the holdout dataset to assign to the custom model. Can only be assigned for unstructured models.
- keep_training_holdout_data: bool, optional
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: int, optional
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.
- Returns:
- CustomModelVersion
created custom model version
- Raises:
- 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"])
- classmethod list(custom_model_id)
List custom model versions. :rtype:
List
[CustomModelVersion
]Added in version v2.21.
- Parameters:
- custom_model_id: str
The ID of the custom model.
- Returns:
- List[CustomModelVersion]
A list of custom model versions.
- Raises:
- datarobot.errors.ClientError
If the server responded with 4xx status.
- datarobot.errors.ServerError
If the server responded with 5xx status.
- classmethod get(custom_model_id, custom_model_version_id)
Get custom model version by id. :rtype:
CustomModelVersion
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:
- CustomModelVersion
Retrieved custom model version.
- Raises:
- datarobot.errors.ClientError
If the server responded with 4xx status.
- datarobot.errors.ServerError
If the server responded with 5xx status.
- download(file_path)
Download custom model version. :rtype:
None
Added in version v2.21.
- Parameters:
- file_path: str
Path to create a file with custom model version content.
- Raises:
- datarobot.errors.ClientError
If the server responded with 4xx status.
- datarobot.errors.ServerError
If the server responded with 5xx status.
- update(description=None, required_metadata_values=None)
Update custom model version properties. :rtype:
None
Added in version v2.21.
- Parameters:
- description: str, optional
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:
- datarobot.errors.ClientError
If the server responded with 4xx status.
- datarobot.errors.ServerError
If the server responded with 5xx status.
- refresh()
Update custom model version with the latest data from server. :rtype:
None
Added in version v2.21.
- Raises:
- datarobot.errors.ClientError
If the server responded with 4xx status.
- datarobot.errors.ServerError
If the server responded with 5xx status.
- get_feature_impact(with_metadata=False)
Get custom model feature impact. :rtype:
List
[Dict
[str
,Any
]]Added in version v2.23.
- Parameters:
- with_metadatabool
The flag indicating if the result should include the metadata as well.
- Returns:
- feature_impactslist of dict
The feature impact data. Each item is a dict with the keys ‘featureName’, ‘impactNormalized’, and ‘impactUnnormalized’, and ‘redundantWith’.
- Raises:
- datarobot.errors.ClientError
If the server responded with 4xx status.
- datarobot.errors.ServerError
If the server responded with 5xx status.
- calculate_feature_impact(max_wait=600)
Calculate custom model feature impact. :rtype:
None
Added in version v2.23.
- Parameters:
- max_wait: int, optional
Max time to wait for feature impact calculation. If set to None - method will return without waiting. Defaults to 10 min
- Raises:
- datarobot.errors.ClientError
if the server responded with 4xx status
- datarobot.errors.ServerError
if the server responded with 5xx status
- class datarobot.models.execution_environment.RequiredMetadataKey(**kwargs)
Definition of a metadata key that custom models using this environment must define
Added in version v2.25.
- Attributes:
- 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(**kwargs)
A conversion of a DataRobot custom model version.
Added in version v2.27.
- Attributes:
- 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.
- 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_idstr
The associated custom model ID.
- custom_model_version_idstr
The associated custom model version ID.
- main_program_item_idstr
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_idstr
The ID of the newly created conversion entity.
- Raises:
- datarobot.errors.ClientError
If the server responded with 4xx status.
- datarobot.errors.ServerError
If the server responded with 5xx status.
- Return type:
str
- classmethod stop_conversion(custom_model_id, custom_model_version_id, conversion_id)
Stop a conversion that is in progress.
- Parameters:
- custom_model_idstr
The ID of the associated custom model.
- custom_model_version_idstr
The ID of the associated custom model version.
- conversion_id
The ID of a conversion that is in-progress.
- Raises:
- datarobot.errors.ClientError
If the server responded with 4xx status.
- datarobot.errors.ServerError
If the server responded with 5xx status.
- Return type:
Response
- classmethod get(custom_model_id, custom_model_version_id, conversion_id)
Get custom model version conversion by id. :rtype:
CustomModelVersionConversion
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:
- CustomModelVersionConversion
Retrieved custom model version conversion.
- Raises:
- datarobot.errors.ClientError
If the server responded with 4xx status.
- datarobot.errors.ServerError
If the server responded with 5xx status.
- classmethod get_latest(custom_model_id, custom_model_version_id)
Get latest custom model version conversion for a given custom model version. :rtype:
Optional
[CustomModelVersionConversion
]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:
- CustomModelVersionConversion or None
Retrieved latest conversion for a given custom model version.
- Raises:
- datarobot.errors.ClientError
If the server responded with 4xx status.
- datarobot.errors.ServerError
If the server responded with 5xx status.
- classmethod list(custom_model_id, custom_model_version_id)
Get custom model version conversions list per custom model version. :rtype:
List
[CustomModelVersionConversion
]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:
- List[CustomModelVersionConversion]
Retrieved conversions for a given custom model version.
- Raises:
- datarobot.errors.ClientError
If the server responded with 4xx status.
- datarobot.errors.ServerError
If the server responded with 5xx status.
- class datarobot.CustomModelVersionDependencyBuild(**kwargs)
Metadata about a DataRobot custom model version’s dependency build
Added in version v2.22.
- Attributes:
- 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: str, optional
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 :rtype:
CustomModelVersionDependencyBuild
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:
- CustomModelVersionDependencyBuild
The dependency build information.
- classmethod start_build(custom_model_id, custom_model_version_id, max_wait=600)
Start the dependency build for a custom model version dependency build :rtype:
Optional
[CustomModelVersionDependencyBuild
]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: int, optional
Max time to wait for a build completion. If set to None - method will return without waiting.
- get_log()
Get log of a custom model version dependency build. :rtype:
str
Added in version v2.22.
- Raises:
- datarobot.errors.ClientError
If the server responded with 4xx status.
- datarobot.errors.ServerError
If the server responded with 5xx status.
- cancel()
Cancel custom model version dependency build that is in progress. :rtype:
None
Added in version v2.22.
- Raises:
- datarobot.errors.ClientError
If the server responded with 4xx status.
- datarobot.errors.ServerError
If the server responded with 5xx status.
- refresh()
Update custom model version dependency build with the latest data from server. :rtype:
None
Added in version v2.22.
- Raises:
- datarobot.errors.ClientError
If the server responded with 4xx status.
- datarobot.errors.ServerError
If the server responded with 5xx status.
- class datarobot.ExecutionEnvironment(**kwargs)
An execution environment entity.
Added in version v2.21.
- Attributes:
- id: str
the id of the execution environment
- name: str
the name of the execution environment
- description: str, optional
the description of the execution environment
- programming_language: str, optional
the programming language of the execution environment. Can be “python”, “r”, “java” or “other”
- is_public: bool, optional
public accessibility of environment, visible only for admin user
- created_at: str, optional
ISO-8601 formatted timestamp of when the execution environment version was created
- latest_version: ExecutionEnvironmentVersion, optional
the latest version of the execution environment
- classmethod create(name, description=None, programming_language=None, required_metadata_keys=None)
Create an execution environment.
Added in version v2.21.
- Parameters:
- name: str
execution environment name
- description: str, optional
execution environment description
- programming_language: str, optional
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
- Returns:
- ExecutionEnvironment
created execution environment
- Raises:
- datarobot.errors.ClientError
if the server responded with 4xx status
- datarobot.errors.ServerError
if the server responded with 5xx status
- classmethod list(search_for=None)
List execution environments available to the user.
Added in version v2.21.
- Parameters:
- search_for: str, optional
the string for filtering execution environment - only execution environments that contain the string in name or description will be returned.
- Returns:
- List[ExecutionEnvironment]
a list of execution environments.
- Raises:
- datarobot.errors.ClientError
if the server responded with 4xx status
- datarobot.errors.ServerError
if the server responded with 5xx status
- classmethod get(execution_environment_id)
Get execution environment by it’s id.
Added in version v2.21.
- Parameters:
- execution_environment_id: str
ID of the execution environment to retrieve
- Returns:
- ExecutionEnvironment
retrieved execution environment
- Raises:
- datarobot.errors.ClientError
if the server responded with 4xx status
- datarobot.errors.ServerError
if the server responded with 5xx status
- delete()
Delete execution environment.
Added in version v2.21.
- Raises:
- datarobot.errors.ClientError
if the server responded with 4xx status
- datarobot.errors.ServerError
if the server responded with 5xx status
- update(name=None, description=None, required_metadata_keys=None)
Update execution environment properties.
Added in version v2.21.
- Parameters:
- name: str, optional
new execution environment name
- description: str, optional
new execution environment description
- required_metadata_keys: List[RequiredMetadataKey]
Definition of a metadata keys that custom models using this environment must define
- Raises:
- datarobot.errors.ClientError
if the server responded with 4xx status
- datarobot.errors.ServerError
if the server responded with 5xx status
- refresh()
Update execution environment with the latest data from server.
Added in version v2.21.
- Raises:
- datarobot.errors.ClientError
if the server responded with 4xx status
- datarobot.errors.ServerError
if the server responded with 5xx status
- class datarobot.ExecutionEnvironmentVersion(**kwargs)
A version of a DataRobot execution environment.
Added in version v2.21.
- Attributes:
- 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
- label: str, optional
the label of the execution environment version
- description: str, optional
the description of the execution environment version
- created_at: str, optional
ISO-8601 formatted timestamp of when the execution environment version was created
- docker_context_size: int, optional
The size of the uploaded Docker context in bytes if available or None if not
- docker_image_size: int, optional
The size of the built Docker image in bytes if available or None if not
- classmethod create(execution_environment_id, docker_context_path, label=None, description=None, max_wait=600)
Create an execution environment version.
Added in version v2.21.
- Parameters:
- execution_environment_id: str
the id of the execution environment
- docker_context_path: str
the path to a docker context archive or folder
- label: str, optional
short human readable string to label the version
- description: str, optional
execution environment version description
- max_wait: int, optional
max time to wait for a final build status (“success” or “failed”). If set to None - method will return without waiting.
- Returns:
- ExecutionEnvironmentVersion
created execution environment version
- Raises:
- 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
- classmethod list(execution_environment_id, build_status=None)
List 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: str, optional
build status of the execution environment version to filter by. See datarobot.enums.EXECUTION_ENVIRONMENT_VERSION_BUILD_STATUS for valid options
- Returns:
- List[ExecutionEnvironmentVersion]
a list of execution environment versions.
- Raises:
- datarobot.errors.ClientError
if the server responded with 4xx status
- datarobot.errors.ServerError
if the server responded with 5xx status
- classmethod get(execution_environment_id, version_id)
Get 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:
- ExecutionEnvironmentVersion
retrieved execution environment version
- Raises:
- datarobot.errors.ClientError
if the server responded with 4xx status.
- datarobot.errors.ServerError
if the server responded with 5xx status.
- download(file_path)
Download execution environment version.
Added in version v2.21.
- Parameters:
- file_path: str
path to create a file with execution environment version content
- Returns:
- ExecutionEnvironmentVersion
retrieved execution environment version
- Raises:
- datarobot.errors.ClientError
if the server responded with 4xx status.
- datarobot.errors.ServerError
if the server responded with 5xx status.
- get_build_log()
Get execution environment version build log and error.
Added in version v2.21.
- Returns:
- Tuple[str, str]
retrieved execution environment version build log and error. If there is no build error - None is returned.
- Raises:
- datarobot.errors.ClientError
if the server responded with 4xx status.
- datarobot.errors.ServerError
if the server responded with 5xx status.
- refresh()
Update execution environment version with the latest data from server.
Added in version v2.21.
- Raises:
- datarobot.errors.ClientError
if the server responded with 4xx status
- datarobot.errors.ServerError
if the server responded with 5xx status
- class datarobot.models.custom_model_version.HoldoutData(dataset_id=None, dataset_version_id=None, dataset_name=None, partition_column=None)
Holdout data assigned to a DataRobot custom model version.
Added in version v3.2.
- Attributes:
- 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(dataset_id=None, dataset_version_id=None, dataset_name=None, assignment_in_progress=None, assignment_error=None)
Training data assigned to a DataRobot custom model version.
Added in version v3.2.
- Attributes:
- 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(**kwargs)
- Definition of a runtime parameter used for the custom model version, it includes
the override value if provided.
Added in version v3.4.0.
- Attributes:
- 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.
- class datarobot.models.custom_model_version.RuntimeParameterValue(**kwargs)
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.
- Attributes:
- 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.