Skip to main content

Retrieving All Projects for a Client

You can retrieve all projects associated with a specific client ID using the SDK’s project listing functionality:
Important: The list_projects() method only retrieves projects created after April 15th, 2025.

Example Usage:

Retrieve All Projects
This method is useful when you need to:
  • List all projects for a client
  • Find specific project IDs
  • Check project statuses and configurations
  • Get an overview of client’s work
  • Access project properties programmatically
This returns a list of LabellerrProject objects, each with access to properties like project_id, data_type, attached_datasets, created_by, and more.

Retrieving All Datasets

You can retrieve both linked and unlinked datasets associated with a client using the SDK’s dataset listing capabilities:

Example Usage:

Retrieve All Datasets
Pagination Support:
  • Returns a generator that yields individual datasets
  • Use page_size=-1 to automatically paginate through all datasets (recommended)
  • Use specific page_size to limit results (e.g., page_size=20)
  • Use last_dataset_id for manual pagination across multiple requests
  • Generator approach is memory-efficient for large numbers of datasets
Available Scope Options:
  • DataSetScope.client - Datasets with client-level permissions
  • DataSetScope.project - Datasets with project-level permissions
This method is useful when you need to:
  • Get a comprehensive list of all datasets in your workspace
  • Filter datasets by specific data types (image, video, audio, document, text)
  • Organize datasets by scope (client-level or project-level permissions)
  • Efficiently iterate through large numbers of datasets with pagination
  • Memory-efficient processing of datasets using generators

Advanced Pagination Examples

Retrieving Files from a Dataset

You can fetch all files from a specific dataset using the fetch_files() method:

Example Usage:

Fetch Files from Dataset
This method is useful when you need to:
  • Get a list of all files in a dataset
  • Check file statuses before creating a project
  • Verify dataset contents
  • Build custom file processing workflows

Working with Projects and Datasets

Get Project Information

Get Project Details

Attach Datasets to a Project

Attach Datasets

Detach Datasets from a Project

Detach Datasets
Important: When detaching datasets from a project, the method no longer requires client_id and project_id parameters as these are automatically derived from the project instance.

Bulk Assign Files

You can bulk assign multiple files to a new status in a project, optionally assigning them to a specific user.
Important Requirement: The user being assigned to (specified in assign_to parameter) must already be added to the project. If the user is not present in the project, the bulk assign operation will fail.

Example Usage:

Bulk Assign Files

Acceptable Status Values

When to Use Bulk Assign

Bulk assign is essential for automating annotation workflows:

Common Use Cases

Example Scenario: Imagine you have 500 images that need annotation. After annotators finish, you want to send them all to review status. Without bulk assign, you’d click 500 times. With bulk_assign_files(), it’s one API call:

Error Handling

The Labellerr SDK uses a custom exception class, LabellerrError, to indicate issues during API interactions. Always wrap your function calls in try-except blocks to gracefully handle errors.

Example:

Error Handling Example

API Reference

Function Signatures

Example:
Examples:
Returns:List of file dictionaries with metadata including:
  • file_id: str
  • file_name: str
  • status: str
  • file_type: str
  • file_size: int
Methods:
  • attach_dataset_to_project(dataset_id=None, dataset_ids=None)
  • detach_dataset_from_project(dataset_id=None, dataset_ids=None)
  • bulk_assign_files(file_ids, new_status, assign_to=None)
  • upload_preannotations(annotation_format, annotation_file, conf_bucket=None, _async=False)
  • create_export(export_config)
  • list_exports() - Get all exports (completed and in-progress) for the project
  • check_export_status(report_ids) - Check status of specific exports

Best Practices

Use Auto-Pagination

Set page_size=-1 for list_datasets() to automatically handle all pages without manual intervention

Leverage Generators

Process datasets as they’re retrieved instead of loading all into memory at once

Filter by Scope

Use DataSetScope.client for workspace-level datasets or DataSetScope.project for project-specific ones

Error Handling

Always wrap API calls in try-except blocks to catch LabellerrError exceptions

The Labellerr SDK is a fast and reliable solution for managing annotation workflows. Want to try it end-to-end? Refer to this Google Colab Cookbook for a ready-to-run tutorial. For more related cookbooks and examples, please visit our repository: Labellerr Hands-On Learning