The Taskframe Class: Creating & Retrieving a Taskframe - Taskframe/taskframe-python GitHub Wiki

This pages shows how to perform basic creation, update, retrieval operations on Taskframes.

Quick Summary

from taskframe import Taskframe

# list all Taskframes
tfs = Taskframe.list()

# retrieve a specific Taskframe:
tf = Taskframe.retrieve(id="XXXXXX") # by the platform generated id

# create a Taskframe:
tf = Taskframe.create(taskframe_id="XXXXXX", input_data="xxxxxx")

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

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

List

List all Taskframes. The list is paginated. This is a class method.

Signature:

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

Parameters:

  • offset
  • limit

Return:

List of Taskframe instances.

Example:

tfs = Taskframe.list()

Retrieve

Get a specific existing Taskframe. This is a class method.

Signature:

@classmethod
def retrieve(cls, id):

Parameters:

  • id

Returns:

Taskframe instance.

Example:

tf = Taskframe.retrieve("XXXX")

Create

Create a taskframe. This is a class method.

Signature:

@classmethod
def create(
    cls,
    data_type=None,
    task_type=None,
    json_schema=None,
    json_schema_url="",
    ui_schema=None,
    ui_schema_url="",
    instructions="",
    name="",
    review=True,
    redundancy=1,
    callback_url="",
    **kwargs,
):

Parameters:

  • data_type: Type of input data. Possible values : image, text, audio, html, iframe.
  • task_type: Type of predefined tasks (depending on the data_type):
    • classification: you may pass additional parameters:
      • classes: list of class options (single choice)
      • tags: list of tag options (multi choices)
    • text: for transcription, text entry, sequence-to-sequence, etc. The annotator will have to fill a free text area.
    • bounding_box, polygon, point: for image annotations. Extra parameters:
      • classes: list of region-level class options (single choice)
      • tags: list of region-level class options (multi choices)
      • global_classes: list of image-level class options (single choice)
      • global_tags: list of image-level tags options (multi choices)
    • ner: Named Entity Recognition (for text data). Extra parameters:
      • classes: list of class options (single choice)
    • audio_annotation: Regions annotations (for audio data). Extra parameters:
      • classes: list of class options (single choice)
    • file_upload: the annotator will have to upload a file(s) (experimental support for small files only). Extra parameters:
      • multiple: Boolean, whether multiple files are allowed
      • files_accepted: list of file extensions allowed, e.g. [".jpg", ".png"]. for all image formats simple pass ["image"]
    • custom: Custom task based on a JSON Schema, Extra parameters:
      • json_schema: a valid JSON Schema
    • name: the name that will appear in the platform list views (optional)
    • instructions: Free HTML section that will appear at the bottom of the worker interface. Allows safe HTML tags (p, img, etc.)
    • id: if you have already created your Taskframe you can simply create a Taskframe instance with the id, then call methods described below to fetch results, etc.
    • redundancy: Number of distinct workers who will perform each task
    • review: If True, each task will have to be verified by a reviewer
    • callback_url: A webhook callback url. As soon as a task is finished, the result will be posted to this URL.

Returns:

Taskframe instance.

Example:

tf = Taskframe.create(data_type="image", task_type="classification", classes=["cat", "dog"])

Update

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

Signature:

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

Parameters:

  • json_schema:
  • json_schema_url:
  • ui_schema:
  • ui_schema_url:
  • instructions:
  • name:
  • review:
  • redundancy:
  • callback_url:

Note that you can't update the data_type or task_type once the Taskframe is created.

Returns:

Taskframe instance.

Example:

tf = Taskframe.update(id="XXXXXX", name="XXXXXX")

Submit

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

Signature:

def submit(self):

Parameters: None

Returns: None

Example:

tf = Taskframe(data_type="image", task_type="classification", classes=["cat", "dog"])
tf.submit()