Task

class deepint.core.Task(organization_id: str, workspace_id: str, credentials: Credentials, info: TaskInfo)

A Deep Intelligence task.

Note: This class should not be instanced directly, and it’s recommended to use the deepint.core.task.Task.build or deepint.core.task.Task.from_url methods.

organization_id

the organziation where task is located.

workspace_id

workspace where task is located.

info

deepint.core.task.TaskInfo to operate with task’s information.

credentials

credentials to authenticate with Deep Intelligence API and be allowed to perform operations over the task. If not provided, the credentials are generated with the deepint.auth.credentials.Credentials.build.

classmethod build(organization_id: str, workspace_id: str, task_id: str, credentials: Optional[Credentials] = None) Task

Builds a task.

Note: when task is created, the task’s information is retrieved from API.

Parameters:
  • organization_id – organization where task is located.

  • workspace_id – workspace where task is located.

  • task_id – task’s id.

  • credentials – credentials to authenticate with Deep Intelligence API and be allowed to perform operations over the task. If not provided, the credentials are generated with the deepint.auth.credentials.Credentials.build.

Returns:

the task build with the given parameters and credentials.

delete()

Deletes the task.

fetch_result(force_reload=False) Dict[str, str]

Retrieves the result of the task.

Parameters:

force_reload – if set to True the task information is reloaded, then the result is fetched.

Returns:

the result generated by the task in deepint.net

classmethod from_url(url: str, organization_id: Optional[str] = None, credentials: Optional[Credentials] = None) Task

Builds a task from it’s API or web associated URL.

The url must contain the workspace’s id and the task’s id as in the following examples:

Example

Note: when task is created, the task’s information and features are retrieved from API.

Also it is remmarkable that if the API URL is providen, the organization_id must be provided in the optional parameter, otherwise this ID won’t be found on the URL and the Organization will not be created, raising a value error.

Parameters:
  • url – the task’s API or web associated URL.

  • organization_id – the id of the organziation. Must be providen if the API URL is used.

  • credentials – credentials to authenticate with Deep Intelligence API and be allowed to perform operations over the task. If not provided, the credentials are generated with the deepint.auth.credentials.Credentials.build.

Returns:

the task build with the URL and credentials.

is_errored(force_reload=False) bool

Checks if the task has failed.

Parameters:

force_reload – if set to True the task information is reloaded, then the status is checked.

Returns:

True if task has entered in error state or False in other case.

load()

Loads the task’s information.

If the task’s information is already loaded, is replace by the new one after retrieval.

resolve(raise_on_error=True, poll_interval: int = 3)

Waits for the task to be finished

Parameters:
  • raise_on_error – if set to True and the task enters in an errored status, a deepint.error.errors.DeepintTaskError is raised. In other case, if the task enters in an errored state, the wait for task process will stop and the error will not be raised.

  • poll_interval – Number of seconds between task status checks (it consists in a query to API). If not provided the default value is 3.

to_dict() Dict[str, Any]

Builds a dictionary containing the information stored in current object.

Returns:

dictionary contining the information stored in the current object.

class deepint.core.TaskStatus(value)

Available task status in the system.

classmethod all() List[str]

Returns all available task status serialized to str.

Returns:

all available task status

classmethod from_string(_str: str) TaskStatus

Builds the deepint.core.task.TaskStatus from a str.

Parameters:

_str – name of the task status.

Returns:

the task status converted to deepint.core.task.TaskStatus.

class deepint.core.task.TaskInfo(task_id: str, user_id: str, user_name: str, created: datetime, status: TaskStatus, duration: int, name: str, description: str, progress: int, subtask: str, result: str, result_type: str, error_code: str, error_description: str)

Stores the information of a Deep Intelligence task.

task_id

task’s id in format uuid4.

name

task’s name.

description

task’s description.

user_id

id of the user who created the task

user_name

user who created the task

created

task creation date

status

task status. (pending = Pending to be handled, running = Executing, success = Ended successfully, failed = Ended with an error)

duration

duration of the task (in milliseconds)

progress

progress of the current sub-task

subtask

name of the current sub-task

result

id of the resulting object of the task

result_type

type of the resulting object of the task (source or model).

error_code

error code (if the task failed)

error_description

error message (if the task failed)

static from_dict(obj: Any) TaskInfo

Builds a TaskInfo with a dictionary.

Parameters:

objobject or dict containing the a serialized TaskInfo.

Returns:

TaskInfo containing the information stored in the given dictionary.

to_dict() Dict[str, Any]

Builds a dictionary containing the information stored in current object.

Returns:

dictionary containing the information stored in the current object.