Custom tasks
- class datarobot.CustomTask
A custom task. This can be in a partial state or a complete state. When the latest_version is None, the empty task has been initialized with some metadata. It is not yet use-able for actual training. Once the first CustomTaskVersion has been created, you can put the CustomTask in UserBlueprints to train Models in Projects
Added in version v2.26.
- Variables:
id (
str
) – id of the custom taskname (
str
) – name of the custom tasklanguage (
str
) – programming language of the custom task. Can be “python”, “r”, “java” or “other”description (
str
) – description of the custom tasktarget_type (
datarobot.enums.CUSTOM_TASK_TARGET_TYPE
) –the target type of the custom task. One of:
datarobot.enums.CUSTOM_TASK_TARGET_TYPE.BINARY
datarobot.enums.CUSTOM_TASK_TARGET_TYPE.REGRESSION
datarobot.enums.CUSTOM_TASK_TARGET_TYPE.MULTICLASS
datarobot.enums.CUSTOM_TASK_TARGET_TYPE.ANOMALY
datarobot.enums.CUSTOM_TASK_TARGET_TYPE.TRANSFORM
latest_version (
datarobot.CustomTaskVersion
orNone
) – latest version of the custom task if the task has a latest version. If the latest version is None, the custom task is not ready for use in user blueprints. You must create its first CustomTaskVersion before you can use the CustomTaskcreated_by (
str
) – The username of the user who created the custom task.updated_at (
str
) – An ISO-8601 formatted timestamp of when the custom task was updated.created_at (
str
) – ISO-8601 formatted timestamp of when the custom task was createdcalibrate_predictions (
bool
) – whether anomaly predictions should be calibrated to be between 0 and 1 by DR. only applies to custom estimators with target type datarobot.enums.CUSTOM_TASK_TARGET_TYPE.ANOMALY
- 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. No casing fixes have taken placekeep_attrs (
iterable
) – List, set or tuple of the dotted namespace notations for attributes to keep within the object structure even if their values are None
- Return type:
- classmethod list(order_by=None, search_for=None)
List custom tasks available to the user.
Added in version v2.26.
- Parameters:
search_for (
Optional[str]
) – string for filtering custom tasks - only tasks that contain the string in name or description will be returned. If not specified, all custom task will be returnedorder_by (
Optional[str]
) – property to sort custom tasks 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 tasks being returned in order of creation time descending
- Returns:
a list of custom tasks.
- Return type:
List[CustomTask]
- Raises:
datarobot.errors.ClientError – if the server responded with 4xx status
datarobot.errors.ServerError – if the server responded with 5xx status
- classmethod get(custom_task_id)
Get custom task by id.
Added in version v2.26.
- Parameters:
custom_task_id (
str
) – id of the custom task- Returns:
retrieved custom task
- Return type:
- Raises:
datarobot.errors.ClientError – if the server responded with 4xx status.
datarobot.errors.ServerError – if the server responded with 5xx status.
- classmethod copy(custom_task_id)
Create a custom task by copying existing one.
Added in version v2.26.
- Parameters:
custom_task_id (
str
) – id of the custom task to copy- Return type:
- 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, language=None, description=None, calibrate_predictions=None, **kwargs)
Creates only the metadata for a custom task. This task will not be use-able until you have created a CustomTaskVersion attached to this task.
Added in version v2.26.
- Parameters:
name (
str
) – name of the custom tasktarget_type (
datarobot.enums.CUSTOM_TASK_TARGET_TYPE
) –the target typed based on the following values. Anything else will raise an error
datarobot.enums.CUSTOM_TASK_TARGET_TYPE.BINARY
datarobot.enums.CUSTOM_TASK_TARGET_TYPE.REGRESSION
datarobot.enums.CUSTOM_TASK_TARGET_TYPE.MULTICLASS
datarobot.enums.CUSTOM_TASK_TARGET_TYPE.ANOMALY
datarobot.enums.CUSTOM_TASK_TARGET_TYPE.TRANSFORM
language (
Optional[str]
) – programming language of the custom task. Can be “python”, “r”, “java” or “other”description (
Optional[str]
) – description of the custom taskcalibrate_predictions (
Optional[bool]
) – whether anomaly predictions should be calibrated to be between 0 and 1 by DR. if None, uses default value from DR app (True). only applies to custom estimators with target type datarobot.enums.CUSTOM_TASK_TARGET_TYPE.ANOMALY
- Raises:
datarobot.errors.ClientError – if the server responded with 4xx status.
datarobot.errors.ServerError – if the server responded with 5xx status.
- Return type:
- update(name=None, language=None, description=None, **kwargs)
Update custom task properties.
Added in version v2.26.
- Parameters:
name (
Optional[str]
) – new custom task namelanguage (
Optional[str]
) – new custom task programming languagedescription (
Optional[str]
) – new custom task description
- Raises:
datarobot.errors.ClientError – if the server responded with 4xx status.
datarobot.errors.ServerError – if the server responded with 5xx status.
- Return type:
None
- refresh()
Update custom task with the latest data from server. :rtype:
None
Added in version v2.26.
- Raises:
datarobot.errors.ClientError – if the server responded with 4xx status
datarobot.errors.ServerError – if the server responded with 5xx status
- delete()
Delete custom task. :rtype:
None
Added in version v2.26.
- Raises:
datarobot.errors.ClientError – if the server responded with 4xx status
datarobot.errors.ServerError – if the server responded with 5xx status
- download_latest_version(file_path)
Download the latest custom task version.
Added in version v2.26.
- Parameters:
file_path (
str
) – the full path of the target zip file- Raises:
datarobot.errors.ClientError – if the server responded with 4xx status.
datarobot.errors.ServerError – if the server responded with 5xx status.
- Return type:
None
- get_access_list()
Retrieve access control settings of this custom task.
Added in version v2.27.
- Return type:
Update the access control settings of this custom task.
Added in version v2.27.
- Parameters:
access_list (
list
ofSharingAccess
) – A list of SharingAccess to update.- Raises:
datarobot.errors.ClientError – if the server responded with 4xx status
datarobot.errors.ServerError – if the server responded with 5xx status
- Return type:
None
Examples
Transfer access to the custom task 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.CustomTask.get('custom-task-id').share(access_list)
- class datarobot.models.custom_task_version.CustomTaskFileItem
A file item attached to a DataRobot custom task version.
Added in version v2.26.
- Variables:
id (
str
) – id of the file itemfile_name (
str
) – name of the file itemfile_path (
str
) – path of the file itemfile_source (
str
) – source of the file itemcreated_at (
str
) – ISO-8601 formatted timestamp of when the version was created
- class datarobot.enums.CustomTaskOutboundNetworkPolicy
The way to set and view a CustomTaskVersions outbound network policy.
- class datarobot.CustomTaskVersion
A version of a DataRobot custom task.
Added in version v2.26.
- Variables:
id (
str
) – id of the custom task versioncustom_task_id (
str
) – id of the custom taskversion_minor (
int
) – a minor version number of custom task versionversion_major (
int
) – a major version number of custom task versionlabel (
str
) – short human readable string to label the versioncreated_at (
str
) – ISO-8601 formatted timestamp of when the version was createdis_frozen (
bool
) – a flag if the custom task version is frozenitems (
List[CustomTaskFileItem]
) – a list of file items attached to the custom task versiondescription (
Optional[str]
) – custom task version descriptionbase_environment_id (
Optional[str]
) – id of the environment to use with the taskbase_environment_version_id (
Optional[str]
) – id of the environment version to use with the taskdependencies (
List[CustomDependency]
) – the parsed dependencies of the custom task version if the version has a valid requirements.txt filerequired_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.arguments (
List[UserBlueprintTaskArgument]
) – A list of custom task version arguments.outbound_network_policy (
CustomTaskOutboundNetworkPolicy
)
- 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. No casing fixes have taken placekeep_attrs (
iterable
) – List, set or tuple of the dotted namespace notations for attributes to keep within the object structure even if their values are None
- classmethod create_clean(custom_task_id, base_environment_id, maximum_memory=None, is_major_update=True, folder_path=None, required_metadata_values=None, outbound_network_policy=None)
Create a custom task version without files from previous versions.
Added in version v2.26.
- Parameters:
custom_task_id (
str
) – the id of the custom taskbase_environment_id (
str
) – the id of the base environment to use with the custom task versionmaximum_memory (
Optional[int]
) – A number in bytes about how much memory custom tasks’ inference containers can run with.is_major_update (
bool
) – If the current version is 2.3, True would set the new version at 3.0. False would set the new version at 2.4. 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.required_metadata_values (
Optional[List[RequiredMetadataValue]]
) – Additional parameters required by the execution environment. The required keys are defined by the fieldNames in the base environment’s requiredMetadataKeys.outbound_network_policy (
Optional[CustomTaskOutboundNetworkPolicy]
) – You must enable custom task network access permissions to pass any value other than None! Specifies if you custom task version is able to make network calls. None will set the value to DataRobot’s default.
- Returns:
created custom task version
- Return type:
- Raises:
datarobot.errors.ClientError – if the server responded with 4xx status
datarobot.errors.ServerError – if the server responded with 5xx status
- classmethod create_from_previous(custom_task_id, base_environment_id, maximum_memory=None, is_major_update=True, folder_path=None, files_to_delete=None, required_metadata_values=None, outbound_network_policy=None)
Create a custom task version containing files from a previous version.
Added in version v2.26.
- Parameters:
custom_task_id (
str
) – the id of the custom taskbase_environment_id (
str
) – the id of the base environment to use with the custom task versionmaximum_memory (
Optional[int]
) – A number in bytes about how much memory custom tasks’ inference containers can run with.is_major_update (
bool
) – If the current version is 2.3, True would set the new version at 3.0. False would set the new version at 2.4. 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_to_delete (
Optional[List[str]]
) – the list of a file items ids to be deleted Example: [“5ea95f7a4024030aba48e4f9”, “5ea6b5da402403181895cc51”]required_metadata_values (
Optional[List[RequiredMetadataValue]]
) – Additional parameters required by the execution environment. The required keys are defined by the fieldNames in the base environment’s requiredMetadataKeys.outbound_network_policy (
Optional[CustomTaskOutboundNetworkPolicy]
) – You must enable custom task network access permissions to pass any value other than None! Specifies if you custom task version is able to make network calls. None will get the value from the previous version if you have the proper permissions or use DataRobot’s default.
- Returns:
created custom task version
- Return type:
- Raises:
datarobot.errors.ClientError – if the server responded with 4xx status
datarobot.errors.ServerError – if the server responded with 5xx status
- classmethod list(custom_task_id)
List custom task versions.
Added in version v2.26.
- Parameters:
custom_task_id (
str
) – the id of the custom task- Returns:
a list of custom task versions
- Return type:
List[CustomTaskVersion]
- Raises:
datarobot.errors.ClientError – if the server responded with 4xx status
datarobot.errors.ServerError – if the server responded with 5xx status
- classmethod get(custom_task_id, custom_task_version_id)
Get custom task version by id.
Added in version v2.26.
- Parameters:
custom_task_id (
str
) – the id of the custom taskcustom_task_version_id (
str
) – the id of the custom task version to retrieve
- Returns:
retrieved custom task version
- Return type:
- 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 task version.
Added in version v2.26.
- Parameters:
file_path (
str
) – path to create a file with custom task 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 task version properties.
Added in version v2.26.
- Parameters:
description (
str
) – new custom task version descriptionrequired_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.
- Raises:
datarobot.errors.ClientError – if the server responded with 4xx status.
datarobot.errors.ServerError – if the server responded with 5xx status.
- refresh()
Update custom task version with the latest data from server.
Added in version v2.26.
- Raises:
datarobot.errors.ClientError – if the server responded with 4xx status
datarobot.errors.ServerError – if the server responded with 5xx status
- start_dependency_build()
Start the dependency build for a custom task version and return build status. .. versionadded:: v2.27
- Returns:
DTO of custom task version dependency build.
- Return type:
CustomTaskVersionDependencyBuild
- start_dependency_build_and_wait(max_wait)
Start the dependency build for a custom task version and wait while pulling status. .. versionadded:: v2.27
- Parameters:
max_wait (
int
) – max time to wait for a build completion- Returns:
DTO of custom task version dependency build.
- Return type:
CustomTaskVersionDependencyBuild
- Raises:
datarobot.errors.ClientError – if the server responded with 4xx status
datarobot.errors.ServerError – if the server responded with 5xx status
datarobot.errors.AsyncTimeoutError – Raised if the dependency build is not finished after max_wait.
- cancel_dependency_build()
Cancel custom task version dependency build that is in progress. .. versionadded:: v2.27
- Raises:
datarobot.errors.ClientError – if the server responded with 4xx status
datarobot.errors.ServerError – if the server responded with 5xx status
- get_dependency_build()
Retrieve information about a custom task version’s dependency build. .. versionadded:: v2.27
- Returns:
DTO of custom task version dependency build.
- Return type:
CustomTaskVersionDependencyBuild
- download_dependency_build_log(file_directory='.')
Get log of a custom task version dependency build. .. versionadded:: v2.27
- Parameters:
file_directory (
str (optional
, default is"."
)
) – Directory path where downloaded file is to save.- Raises:
datarobot.errors.ClientError – if the server responded with 4xx status
datarobot.errors.ServerError – if the server responded with 5xx status