1. Redistributing and Reassigning a Task

To reach the tasks and assignments repositories go to tasks and assignments.

To reach the tasks and assignments entities go to tasks and assignments.

1.1. Get Task and Assignments

1.1.1. Get Task

1.1.1.1. Get by ID

task = dl.tasks.get(task_id='<my-task-id>')

1.1.1.2. Get by name – in a project

project = dl.projects.get(project_name='<project_name>')
task = project.tasks.get(task_name='<my-task-name>')

1.1.1.3. Get by name – in a dataset

dataset = project.datasets.get(dataset_name='<dataset_name>')
task = project.tasks.get(task_name='<my-task-name>')

1.1.1.4. Get list – in a project

dataset = project.datasets.get(dataset_name='<dataset_name>')
task = project.tasks.get(task_name='<my-task-name>')

1.1.1.5. Get list – in a dataset

tasks = project.tasks.list()

1.1.1.6. Get Task Items

tasks = dataset.tasks.list()

1.1.2. Get Assignments

1.1.2.1. Get by ID

assignment = dl.assignments.get(assignment_id='<my-assignment-id>')

1.1.2.2. Get by name – in a project

project = dl.projects.get(project_name='<project_name>')
assignment = project.assignments.get(assignment_name='<my-assignment-name>')

1.1.2.3. Get by name – in a dataset

dataset = project.datasets.get(dataset_name='<dataset_name>')
assignment = dataset.assignments.get(assignment_name='<my-assignment-name>')

1.1.2.4. Get by name – in a task

task = project.tasks.get(task_name='<my-task-name>')
assignment = task.assignments.get(assignment_name='<my-assignment-name>')

1.1.2.5. Get list – in a project

assignments = project.assignments.list()

1.1.2.6. Get list – in a dataset

assignments = dataset.assignments.list()

1.1.2.7. Get list – in a task

assignments = task.assignments.list()

1.1.2.8. Get Assignment Items

assignment_items = assignment.get_items()

1.1.3. Redistribute and Reassign the Assignment

1.1.3.1. prep

import dtlpy as dl
import datetime
if dl.token_expired():
    dl.login()
project = dl.projects.get(project_name='<project_name>')
dataset = project.datasets.get(dataset_name='<dataset_name>')
task = dl.tasks.get(task_id='<my-task-id>')
assignment = task.assignments.get(assignment_name='<my-assignment-name>')

1.1.3.2. Redistribute

# load is the workload percentage for each annotator
assignment.redistribute(dl.Workload([dl.WorkloadUnit(assignee_id='<annotator1@dataloop.ai>', load=50),
                                     dl.WorkloadUnit(assignee_id='<annotator2@dataloop.ai>', load=50)]))

1.1.3.3. Reassign

assignment.reassign(assignee_ids['<annotator1@dataloop.ai>'])

1.1.4. Delete Task and Assignments

1.1.4.1. Delete Task

Note
In case you delete a task, it will delete all its assignments as well.
task.delete()