Links

Assigning & querying tasks

The SDK offers multiple ways to query/search through your project tasks and programmatically assign them to various users.

Search by task name

Use search_tasks to search for tasks by name and get their corresponding task_id. Often, users will have task names readily accessible, and can use search_tasks to get the corresponding task_id which may be needed in other SDK functions.
Please see a detailed reference for search_tasks here.
project = redbrick.get_project(org_id, project_id, api_key)
tasks = project.search_tasks() # fetches all tasks
specific_task = project.search_tasks(name="...") # fetches specific task by name

Assign tasks to a user

Use assign_task when you already have the task_id you want to assign to a particular user. If you don’t have the task_id, you can query all the tasks using export_tasks or query tasks assigned to a particular user/unassigned tasks using get_task_queue.
Please see a detailed reference for assign_tasks here.

Assign to a specific user

project = redbrick.get_project(org_id, project_id, api_key)
# Assign tasks in Label stage to a specific user
project.labeling.assign_tasks(task_ids=["..."], email="...")
# Assign tasks in Review stage to specific user
project.review.assign_tasks(task_ids=["..."], email="...")

Assign tasks to the current user

You can assign tasks to your API key in the following way:
project.labeling.assign_tasks(task_ids=["..."], current_user=True)

Retrieve queued tasks

Use get_task_queue when you want to retrieve the tasks assigned to a particular user, or you want to fetch all the unassigned tasks in your project. This can be useful in preparation for using assign_tasks to programmatically assigning unassigned tasks, or put_tasks to programmatically label/review tasks assigned to you.
Please see a detailed reference for get_task_queue here.

Retrieve tasks assigned to specific user

project = redbrick.get_project(org_id, project_id, api_key)
# Get tasks assigned to [email protected] in Label labeling stage
project.labeling.get_task_queue(stage_name="Label", email="[email protected]")
# Get tasks assigned to [email protected] in Review_1 review stage
project.review.get_task_queue(stage_name="Review_1", email="[email protected]")

Retrieve unassigned tasks

You can also fetch all unassigned tasks in a particular stage along with the ones that are assigned to the current API Key. This information may be useful when choosing which tasks to assign to users.
project = redbrick.get_project(org_id, project_id, api_key)
# Get unassigned tasks in Label labeling stage
project.labeling.get_task_queue(stage_name="Label", fetch_unassigned=True)
# Get unassigned tasks in Review_1 review stage
project.review.get_task_queue(stage_name="Review_1", fetch_unassigned=True)

Retrieve tasks assigned to you

Use get_tasks to fetch all tasks already assigned to the current API Key. This can be useful when re-assigning those tasks to another user (through assign_tasks) or for programmatically submitting them through put_tasks.
Please see a detailed description of get_tasks here.
Calling this function will automatically assign available tasks to your API key as per our automatic task assignment. If you want to retrieve tasks assigned to you without automatically assigning new tasks, run get_task_queue(stage_name="...").
project = redbrick.get_project(org_id, project_id, api_key)
# Get tasks assigned to your API key in Label stage
label_tasks = project.labeling.get_tasks(stage_name="Label")
# Get tasks assigned to your API key in Review_1 stage
review_tasks = project.review.get_tasks(stage_name="Review_1")