Custom Tasks

class datarobot.CustomTask(id, target_type, latest_version, created_at, updated_at, name, description, language, created_by, calibrate_predictions=None)

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.

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

CustomTask

classmethod list(order_by=None, search_for=None)

List custom tasks available to the user. :rtype: List[CustomTask]

Added in version v2.26.

Parameters:
search_for: str, optional

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: str, optional

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:
List[CustomTask]

a list of custom tasks.

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. :rtype: CustomTask

Added in version v2.26.

Parameters:
custom_task_id: str

id of the custom task

Returns:
CustomTask

retrieved custom task

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. :rtype: CustomTask

Added in version v2.26.

Parameters:
custom_task_id: str

id of the custom task to copy

Returns:
CustomTask
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. :rtype: CustomTask

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: str, optional

programming language of the custom task. Can be “python”, “r”, “java” or “other”

description: str, optional

description of the custom task

calibrate_predictions: bool, optional

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

Returns:
CustomTask
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, **kwargs)

Update custom task properties. :rtype: None

Added in version v2.26.

Parameters:
name: str, optional

new custom task name

language: str, optional

new custom task programming language

description: str, optional

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.

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. :rtype: None

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.

get_access_list()

Retrieve access control settings of this custom task. :rtype: List[SharingAccess]

Added in version v2.27.

Returns:
list of SharingAccess
share(access_list)

Update the access control settings of this custom task. :rtype: None

Added in version v2.27.

Parameters:
access_listlist of SharingAccess

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

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(id, file_name, file_path, file_source, created_at=None)

A file item attached to a DataRobot custom task version.

Added in version v2.26.

Attributes:
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(value, names=None, *, module=None, qualname=None, type=None, start=1, boundary=None)

The way to set and view a CustomTaskVersions outbound network policy.

class datarobot.CustomTaskVersion(id, custom_task_id, version_major, version_minor, label, created_at, is_frozen, items, outbound_network_policy, description=None, base_environment_id=None, maximum_memory=None, base_environment_version_id=None, dependencies=None, required_metadata_values=None, arguments=None)

A version of a DataRobot custom task.

Added in version v2.26.

Attributes:
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: str, optional

custom task version description

base_environment_id: str, optional

id of the environment to use with the task

base_environment_version_id: str, optional

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

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

created custom task version

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

created custom task 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_task_id)

List custom task versions.

Added in version v2.26.

Parameters:
custom_task_id: str

the id of the custom task

Returns:
List[CustomTaskVersion]

a list of custom task 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_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:
CustomTaskVersion

retrieved custom task 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 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 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:
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:
CustomTaskVersionDependencyBuild

DTO of custom task version dependency build.

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

DTO of custom task version dependency build.

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

DTO of custom task version dependency build.

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