SDK Cheat Sheet
  • 29 Feb 2024
  • Dark
  • PDF

SDK Cheat Sheet

  • Dark
  • PDF

Article summary


• Create a project: project = dl.projects.create(project_name='my-new-project')

• Print projects list: dl.projects.list().print()

• Open project on the web: project.open_in_web()

• Get projects list:  dl.projects.list()

• Get a project by name:  project = dl.projects.get(project_name='my-project')

• Get a project by ID:  project = dl.projects.get(project_id='my-project-id')

• Add project users ID:  project.add_member(email='', role=dl.MEMBER_ROLE_DEVELOPER)

• List project users ID:  members_list = project.list_members(role=dl.MemberRole.ANNOTATOR)

• Remove project users ID: project.remove_member(email='')

More about projects SDK on Project.


• Create a dataset: dataset = project.datasets.create(dataset_name='my-dataset-name')

• Print dataset: dataset.print()

• Open datasets on the web:  dataset.open_in_web()

• Get a projects datasets list: datasets = project.datasets.list()

• Get the datasets by name:  dataset = project.datasets.get(dataset_name='my-dataset-name')

• Get the datasets by ID:  dataset = project.datasets.get(dataset_id='my-dataset-id')

More about datasets SDK on Datasets.


• Upload items:  dataset.items.upload(local_path="/path/to/image.jpg")

• Upload items to a specific folder:  dataset.items.upload(local_path="/path/to/image.jpg",remote_path="/path/to/dataset/folder")

• Download items:"/where/to/save")

• Download items from a specific folder:"/where/to/save",remote_path="/from/where/to/download")

• Open item on the web:  item.open_in_web()

• Clone Items:  item.clone(dst_dataset_id='your-dataset-id-number', with_annotations=True, with_metadata=True, with_task_annotations_status=False)

• Get-item-by-ID:  item = dataset.items.get (item_id = 'my_item_Id')

More about Items SDK is available in the Items section.



item.metadata [ 'user' ] = dict ()
item.metadata [ 'user'][ 'MyKey' ] = 'MyValue'

Recipe And Ontology

• Add a label:  dataset.add_label(label_name='person', color=(34, 6, 231), attributes=['big', 'small'])

• Delete labels:  dataset.delete_labels(label_names=['myLabel1', 'Mylabel2'])

• Copy datasets ontology to a new dataset:  new_dataset = project.datasets.create(dataset_name='new_dataset_with_ontology',ontology_ids=dataset.ontology_ids)

• Create a new recipe:  recipe ='My Recipe', labels=labels))

• Update recipe changes:  recipe.update()

• Delete recipe (For deleted datasets):'my_recipe_id').delete())

• Get the recipe by ID:  recipe ='my_recipe_id')

• Get ontology by ID:  ontology= recipe.ontologies.get(ontology_id='my_ontology_id')

• Get child label:  childLabel = ontology.labels[x].children[y].children[z]

• Change the annotation label to a different label:

annotation.label = "label2"

For more information, read the SDK-Docs for Recipe and Ontology entities.


• Upload annotations: annotations =   item.annotations.upload(annotations=local_annotation_path) 

• Update annotation changes:     annotation = annotation.update() 

• Create annotation builder:   builder = item.annotations.builder()   

• Add box annotation with label person:

builder.add(annotation_definition=dl.Box(top=10,left=10,bottom=100, right=100,label='labelName')) 

• Add annotations of type segmentation:  builder.add(annotation_definition=dl.Segmentation(geo=mask,label='label1'))    

• Add polyline annotation with label person:  builder.add(annotation_definition=dl.Polyline(geo=[[80, 40],[100, 120],[110, 130]], label='person'))    

 • Create a mask for semantic segmentation:

mask = np.zeros(shape=(item.height, item.width), dtype=np.uint8)
mask[50:100, 200:250] = 

For more information, read the SDK-Docs about the Annotation entity.


To understand more about Datatloop's Filters go to Sort & Filters.
• Initiate Filter:  filter = dl.Filters()
• Filter only files:  filter.add(field='type', values='file')   
• Filter only annotated items:  filter.add(field='annotated', values=True)   
• Filter items by name that includes 'dog':  filter.add(field='name', values='dog')  
• Filter items by name or directory that includes 'dog':  >filter.add(field='filename', values='dog')
• Filter specific directory:  filter.add(field='dir', values='/myDirectory')
• Filter directory items with all subdirectories:  filter.add('dir', '/myDirectory/*', method='or')  
• Update filtered items (bulk update):  pages = dataset.items.update(filters=filter, update_values=update_values  )
• Delete filtered items (bulk delete):  dataset.items.delete(filters=filter)
• Get-filtered-items-list:  list = dataset.items.list( filters = filter )
• Filter all items with the annotation type - Box:

filters.resource = 'items'
filters.add(field='type', values='file')
filters.add_join(field='type', values='box')
list = dataset.items.list(filters=filters)

For more information, read the SDK docs for the Filter entity details or the Sort-and-Filter tutorial.

Task and Assignments

To learn more about Dataloop's tasks and assignments, see Tasks & Assignments. 

Some tasks & assignments commands might require importing the `datetime`. 

import datetime


• Delete a task:  task.delete()
• Single status update:

#This example shows how to set a single item to status COMPLETED
item = dataset.items.get (item_id=<itemId>);
task = dataset.tasks.get (task_name=<"task_name">);
# Status can be set to COMPLETED/APPROVE/DISCARD or other statuses that were created as actions on a task by the task creator

• Create a task:

task = dataset.tasks.create(
task_name= 'task_name', 
due_date = datetime.datetime(day= 1, month= 1, year= 2029).timestamp(),
assignee_ids =[ '', ''])

• Create QA task:

due_date=datetime.datetime(day= 1, month= 1, year= 2029).timestamp(),
assignee_ids=[ '', '']

• Add items to the task:

filters = dl.Filters( field= 'dir', values= '/my/folder/directory')
filters=filters, assignee_ids=[ '', ''])

• Get task:  project.tasks.get(task_id= 'my-Task-Id') 
• Get task items:  items_list= task.get_items() 
• Get tasks list:  task_list = project.tasks.list() 


• Remove items from assignments:  assignment. remove_items( filters= filter)  
• Redistribute assignments:  assignment.redistribute(dl.Workload([dl.WorkloadUnit(assignee_id="", load=50), dl.WorkloadUnit(assignee_id="", load=50)]))   
• Reassign assignment:  assignment.reassign(assignee_ids[''])
• Get assignment:  task.assignments.get(assignment_id= 'my_assignment_Id')
• Get assignment items:  items_list= assignment.get_items()
• Get the assignment list of a task:  task.assignments.list()  
• Get an assignments list of a project:  project.assignments.list() 

For more information, read the SDK Docs for details of the Tasks and Assignment repositories.


 • Create a modality:

item1 = dataset.items.get(item_id='my_item_Id')
item2 = dataset.items.get(item_id='my_2_item_Id')
item1.modalities.create(name='my modality', modality_type=dl.ModalityTypeEnum.OVERLAY,

• Create a similarity:

target_item = dataset.items.get(filepath='/remote/path/target_item.png')
ref_item1 = dataset.items.get(filepath='/remote/path/product1.jpeg')
ref_item2 = dataset.items.get(filepath='/remote/path/product2.jpeg')
ref_item3 = dataset.items.get(filepath='/remote/path/product3.jpeg')
similarity = dl.Similarity(name='my-product-similarity',, items=[ref_item1, ref_item2, ref_item3])
dataset.items.upload(local_path=similarity, remote_path='/products_similarities')

• Create a multi-view:

item = dataset.items.get(filepath='/remote/path/original_item.png')
item2 = dataset.items.get(filepath='/remote/path/second_item.png')
multiview = dl.MultiView(name='my-items-multiview', items=[item, item2])
dataset.items.upload(local_path=multiview, remote_path='/remote/path'


To learn more about Dataloop's FaaS, see FaaS (Function as a Service).


To learn more about Dataloop's packages, see the package.

• Delete packages:  package.delete()
• Push packages:  project.packages.push(src_path='/path_to_my_edited code',
• Package versions:

# to see the versions 
# to see the latest version

• Deploy package:  package.deploy()
• Get package:  package = dl.packages.get(package_id='my_package_Id')
• Get packages list:  pack_list = dl.packages.list()
• Open package on the web:  package.open_in_web()


To learn more about Dataloop's services, see the service.

• Delete service:  service.delete()
• Open service on the web:  service.open_in_web()
• Pause and resume service:

# to pause the service
# to resume the service

• Create a bot:  bot = project.bots.create('bot_name')
• Get services:  service ="my_service_name")
• Get services list:


To learn more about Dataloop's triggers, see the trigger.

• Delete triggers:  trigger.delete()
• Trigger for Items Uploaded to Directory /Input:

filters = dl.Filters(field='dir', values='/input')
trigger = service.triggers.create(function_name='run', resource=dl.TriggerResource.ITEM,
name='items-created-trigger', filters=filters)

• Get triggers:  service = dl.triggers.get(trigger_name="my_trigger_name")
• Get triggers lists:  dl.triggers.list().print()
• Trigger for Items Uploaded to Directory /Input

filters = dl.Filters(field='dir', values='/input')
trigger = service.triggers.create(function_name='run', resource=dl.TriggerResource.ITEM,
name='items-created-trigger', filters=filters)