Skip to main content

Local Export

The SDK provides functionality to export project data locally. This feature allows you to export annotations in various formats for further analysis or backup purposes. The export created will be available in the exports section of Labellerr dashboard. Here is where you can find the export in our tool.

Acceptable values:

  • statuses:
    • 'review', 'r_assigned','client_review', 'cr_assigned','accepted'
  • export_format:
    • 'json', 'coco_json', 'csv', 'png'

Example Usage:

Local Export Example
from labellerr.client import LabellerrClient
from labellerr.core.projects import LabellerrProject
from labellerr.core.exceptions import LabellerrError

# Initialize the client with your API credentials
client = LabellerrClient(
    api_key='your_api_key',
    api_secret='your_api_secret',
    client_id='your_client_id'
)

project_id = 'your_project_id'

export_config = {
    "export_name": "Weekly Export",
    "export_description": "Export of all accepted annotations",
    "export_format": "coco_json",
    "statuses": ['review', 'r_assigned','client_review', 'cr_assigned','accepted']
}

try:
    # Get project instance
    project = LabellerrProject(client=client, project_id=project_id)
    
    # Create export
    result = project.create_local_export(export_config)
    export_id = result["response"]['report_id']
    print(f"Local export created successfully. Export ID: {export_id}")
except LabellerrError as e:
    print(f"Local export creation failed: {str(e)}")
Note: The export process creates a downloadable file link of your project’s annotations based on the specified status filters. This is useful for backup purposes or when you need to process the annotations offline.

S3 Export

The SDK also provides functionality to export project data directly to AWS S3 buckets. This feature allows you to export annotations in various formats directly to your S3 storage for automated workflows, backup, or integration with other systems. The export created will be available in the exports section of Labellerr dashboard. Here is where you can find the export in our tool.

Prerequisites:

Before creating an S3 export, you need to:
  1. Create an AWS S3 connection using your AWS credentials
  2. Get the connection_id from the created connection

Example Usage:

S3 Export Example
from labellerr.client import LabellerrClient
from labellerr.core.projects import LabellerrProject
from labellerr.core.connectors import LabellerrS3Connection
from labellerr.core.schemas import AWSConnectionParams, CreateExportParams
from labellerr.core.exceptions import LabellerrError

client = LabellerrClient(
    api_key='your_api_key',
    api_secret='your_api_secret',
    client_id='your_client_id'
)

# Create S3 connection
connection = LabellerrS3Connection.create_connection(
    client=client,
    params=AWSConnectionParams(
        aws_access_key="your_aws_access_key",
        aws_secrets_key="your_aws_secret_key",
        name="S3 Export Connection",
        description="Connection for exporting annotations to S3"
    )
)

# Create S3 export
project = LabellerrProject(client=client, project_id='your_project_id')
export = project.create_export(
    CreateExportParams(
        export_name="S3 Weekly Export",
        export_description="Export of all accepted annotations to S3",
        export_format="coco_json",
        statuses=['review', 'r_assigned', 'client_review', 'cr_assigned', 'accepted'],
        export_destination="s3",
        connection_id=connection.connection_id,
        export_folder_path="bucket_name/path/to/folder/"  # trailing slash is important
    )
)

print(f"Export ID: {export.report_id}")
export.status()  # Poll until completion
Important Notes:
  • The export_folder_path should follow the pattern: bucket_name/path/to/folder/ (the trailing slash is important)
  • Make sure your AWS credentials have write permissions to the specified S3 bucket
  • You can reuse the same connection_id for multiple exports without creating a new connection each time
  • The export will be uploaded directly to your S3 bucket at the specified path

Check Export Status

This method allows users to check the export status of a previously triggered export task (both local and S3 exports). The status will indicate whether the export is still processing, completed, or failed. For local exports, if successful, the function also sends the downloadable file link URL with its expiration time and status. For S3 exports, it indicates when the export has been successfully uploaded to your S3 bucket.

Example Usage :

Check Export Status Example
from labellerr.client import LabellerrClient
from labellerr.core.projects import LabellerrProject
from labellerr.core.exceptions import LabellerrError

# Initialize the client with your API credentials
client = LabellerrClient(
    api_key='your_api_key',
    api_secret='your_api_secret',
    client_id='your_client_id'
)

# Example input
project_id = 'your_project_id'
report_ids = ['export_report_id_1', 'export_report_id_2']

try:
    # Get project instance
    project = LabellerrProject(client=client, project_id=project_id)
    
    # Check export status
    status = project.check_export_status(
        report_ids=report_ids
    )
    
    print(status)
except LabellerrError as e:
    print(f"Failed to check export status: {str(e)}")

Fetch Export Download URL

This endpoint is used to fetch the downloadable link for a previously created local export using the export’s UUID and report ID. The response includes a signed URL from which the export file can be downloaded with the time left to expire. Note: This method is only applicable for local exports. For S3 exports, the files are directly uploaded to your S3 bucket at the specified path.

Example Usage :

Fetch Download URL Example
from labellerr.client import LabellerrClient
from labellerr.core.exceptions import LabellerrError
import uuid

# Initialize the client with your API credentials
client = LabellerrClient(
    api_key='your_api_key',
    api_secret='your_api_secret',
    client_id='your_client_id'
)

project_id = 'your_project_id'
report_ids = ['export_report_id']  # make sure it is a list
request_uuid = str(uuid.uuid4())

try:
    download_url = client.fetch_download_url(
        project_id=project_id,
        uuid=request_uuid,
        export_id=report_ids[0]
    )
    print(f"Download URL: {download_url}")
except LabellerrError as e:
    print(f"Failed to fetch download URL: {str(e)}")