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 task

  • name (str) – name of the custom task

  • language (str) – programming language of the custom task. Can be “python”, “r”, “java” or “other”

  • description (str) – description of the custom task

  • target_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 or None) – 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 CustomTask

  • created_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 created

  • calibrate_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 place

  • keep_attrs (iterable) – List, set or tuple of the dotted namespace notations for attributes to keep within the object structure even if their values are None

Return type:

CustomTask

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 returned

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

CustomTask

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

CustomTask

Raises:
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 task

  • target_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 task

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

CustomTask

update(name=None, language=None, description=None, **kwargs)

Update custom task properties.

Added in version v2.26.

Parameters:
  • name (Optional[str]) – new custom task name

  • language (Optional[str]) – new custom task programming language

  • description (Optional[str]) – new custom task description

Raises:
Return type:

None

refresh()

Update custom task with the latest data from server. :rtype: None

Added in version v2.26.

Raises:
delete()

Delete custom task. :rtype: None

Added in version v2.26.

Raises:
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:
Return type:

None

get_access_list()

Retrieve access control settings of this custom task.

Added in version v2.27.

Return type:

list of SharingAccess

share(access_list)

Update the access control settings of this custom task.

Added in version v2.27.

Parameters:

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

Raises:
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 item

  • file_name (str) – name of the file item

  • file_path (str) – path of the file item

  • file_source (str) – source of the file item

  • created_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 version

  • custom_task_id (str) – id of the custom task

  • version_minor (int) – a minor version number of custom task version

  • version_major (int) – a major version number of custom task version

  • label (str) – short human readable string to label the version

  • created_at (str) – ISO-8601 formatted timestamp of when the version was created

  • is_frozen (bool) – a flag if the custom task version is frozen

  • items (List[CustomTaskFileItem]) – a list of file items attached to the custom task version

  • description (Optional[str]) – custom task version description

  • base_environment_id (Optional[str]) – id of the environment to use with the task

  • base_environment_version_id (Optional[str]) – id of the environment version to use with the task

  • dependencies (List[CustomDependency]) – the parsed dependencies of the custom task version if the version has a valid requirements.txt file

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

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

  • keep_attrs (iterable) – List, set or tuple of the dotted namespace notations for attributes to keep within the object structure even if their values are None

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 task

  • base_environment_id (str) – the id of the base environment to use with the custom task version

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

CustomTaskVersion

Raises:
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 task

  • base_environment_id (str) – the id of the base environment to use with the custom task version

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

CustomTaskVersion

Raises:
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:
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 task

  • custom_task_version_id (str) – the id of the custom task version to retrieve

Returns:

retrieved custom task version

Return type:

CustomTaskVersion

Raises:
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:
update(description=None, required_metadata_values=None)

Update custom task version properties.

Added in version v2.26.

Parameters:
  • description (str) – new custom task version description

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

Raises:
refresh()

Update custom task version with the latest data from server.

Added in version v2.26.

Raises:
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:
cancel_dependency_build()

Cancel custom task version dependency build that is in progress. .. versionadded:: v2.27

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