Low Level Classes: Task - Taskframe/taskframe-python GitHub Wiki

A low-level class representing an individual Task of a given Taskframe

Quick Summary

from taskframe import Task

# list all Tasks on a Taskframe:
tasks = Task.list(taskframe_id="XXXXXX")

# retrieve a specific Task:
task = Task.retrieve(id="XXXXXX") # by the platform generated id
task = Task.retrieve(custom_id="XXXXXX") # by your own custom_id

# create a Task:
task = Task.create(taskframe_id="XXXXXX", input_data="xxxxxx")

# update a Task:
task = Task.update(id="XXXXXX", input_data="xxxxx", initial_label="xxxxx", custom_id="xxxxx")

# submit local changes of a Task instance (ie. create or update):
task = Task(taskframe_id="XXXXXX", input_data="xxxxx")
task.submit()

# dispose the Task (for example in case of invalid input data):
task.dispose()

List

List all Tasks of a given Taskframe. The list is paginated. This is a class method.

Signature:

@classmethod
def list(cls, taskframe_id=None, offset=0, limit=25):

Parameters:

  • taskframe_id
  • offset
  • limit

Return:

List of Task instances.

Example:

tasks = Task.list(taskframe_id="XXXXXX")

Retrieve

Get a specific existing Task. Tasks may be retrieved by passing either the platform auto-generated id, or your own custom_id that should have been passed on creation. This is a class method.

Signature:

@classmethod
def retrieve(cls, id=None, custom_id=None):

Parameters:

  • id
  • custom_id

Returns:

Task instance.

Example:

task = Task.retrieve(id="XXXX")
task = Task.retrieve(custom_id="XXXX")

Create

Create a task by passing either an input_url, input_data or input_file parameter. This is a class method.

Signature:

@classmethod
def create(
    cls,
    custom_id=None,
    taskframe_id=None,
    input_url=None,
    input_data=None,
    input_file=None,
    initial_label=None,
):

Parameters:

  • taskframe_id (required)
  • custom_id: optionnal custom identifier for the task.
  • input_url:
  • input_data:
  • input_file: path to local file.
  • initial_label: data that will be used to initialize the annotation form

Note: exactly one of the following parameters should be passed: input_url, input_data, input_file.

Returns:

Task instance.

Example:

task = Task.create(taskframe_id="XXXXXX", input_data="xxxx")

Update

Update an existing task. Supports partial updates. This is a class method.

Signature:

@classmethod
def update(cls, id, **kwargs):

Parameters:

  • id (required)
  • custom_id: optionnal custom identifier for the task.
  • input_url:
  • input_data:
  • input_file: path to local file.
  • initial_label: data that will be used to initialize the annotation form

Returns:

Task instance.

Example:

task = Task.update(id="XXXXXX", initial_label="XXXXXX")

Submit

Given a Task instance, creates or update the instance on the API. This is an instance method.

Signature:

def submit(self):

Parameters: None

Returns: None

Example:

task = Task(taskframe_id="XXXXXX", input_data="XXXX")
task.submit()

Dispose

Given a Task instance, marked the task as disposed, for example in case of invalid input data). This will remove it from the pending tasks list.

Signature:

def dispose(self):

Parameters: None

Returns: None

Example:

task = Task.retrieve(id="XXXX")
task.dispose()