1. Create 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. Creating a Task with Assignments¶
There are a couple of ways to create a task with assignments.
1.1.1. 1. By Folder Directory¶
This example will create a task for items that match a filter. The items will be divided equally between annotator’s assignments:
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>')
filters = dl.Filters(field='<dir>', values='</my/folder/directory>') # filter by directory
task = dataset.tasks.create(
task_name='<task_name>',
due_date=datetime.datetime(day=1, month=1, year=2029).timestamp(),
assignee_ids=['<annotator1@dataloop.ai>', '<annotator2@dataloop.ai>'],
# The items will be divided equally between assignments
filters=filters # filter by folder directory or use other filters
)
1.1.2. 2. By Filters¶
This example will create a task for items that match a filter. The items will be divided equally between the annotator’s assignments:
These examples are for creating a task from items without annotations.
You can also create tasks based on different filters, learn all about filters here.
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>')
# filter items without annotations
filters = dl.Filters(field='<annotated>', values=False)
task = dataset.tasks.create(
task_name='<task_name>',
due_date=datetime.datetime(day=1, month=1, year=2029).timestamp(),
assignee_ids=['<annotator1@dataloop.ai>', '<annotator2@dataloop.ai>'],
# The items will be divided equally between assignments
filters=filters # filter items without annotations or use other filters
)
1.1.3. 3. List of Items¶
Create a task from a list of items. The items will be divided equally between annotator’s assignments:
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>')
items = dataset.items.list()
items_list = [item for item in items.all()]
task = dataset.tasks.create(
task_name='<task_name>',
due_date=datetime.datetime(day=1, month=1, year=2029).timestamp(),
assignee_ids=['<annotator1@dataloop.ai>', '<annotator2@dataloop.ai>'],
# The items will be divided equally between assignments
items=items_list
)
1.1.4. 4. Full Dataset¶
Create a task from all of the items in the dataset. The items will be divided equally between annotator’s assignments:
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 = dataset.tasks.create(
task_name='<task_name>',
due_date=datetime.datetime(day=1, month=1, year=2029).timestamp(),
assignee_ids=['<annotator1@dataloop.ai>', '<annotator2@dataloop.ai>']
# The items will be divided equally between assignments
)
1.2. Add items to an existing task¶
Adding items to an existing task will create new assignments (for new assignee/s).
1.2.1. 1. By Filters¶
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>')
filters = dl.Filters(field='<metadata.system.refs>', values=[]) # filter on unassigned items
task.add_items(
filters=filters, # filter by folder directory or use other filters
assignee_ids=['<annotator1@dataloop.ai>', '<annotator2@dataloop.ai>'])
1.2.2. 2. Single Item¶
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>')
item = dataset.items.get(item_id='<my-item-id>')
task.add_items(
items=[item],
assignee_ids=['<annotator1@dataloop.ai>', '<annotator2@dataloop.ai>'])
1.2.3. 3. List of Items¶
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>')
items = dataset.items.list()
items_list = [item for item in items.all()]
task.add_items(
items=items_list,
assignee_ids=['<annotator1@dataloop.ai>', '<annotator2@dataloop.ai>']
)