How to cancel export?

How can I cancel all the export tasks that are being run?
There is a “export” button, but I haven’t found a button to cancel it.

Thanks

1 Like

Hello @jonghoon.park,

You can do it via the SDK, please see our docs here - Export overview

You can also do it via the UI by clicking on the red square. Please note that the export task has to be ‘in progress’ for that.

Let me know if it helps!

Best,
Tarishi
Labelbox Support

Thanks, but is there a way to cancel all export tasks in queue via the web UI?
I have 100k+ images with annotations in queue for export by an accident.
Thanks

For project you can also access the exports → https://app.labelbox.com/projects/{project_ID}/notifications/jobs

Thanks, is there a way to bulk cancel all export tasks (all different task ids) within a project at once, rather than canceling the tasks individually?
The current process of waiting for in-progress tasks (because only a batch of tasks get in-progress at a time) and manually canceling each one doesn’t make sense when there are thousands of tasks to cancel.

For any bulk operation, use the SDK.


import labelbox as lb
from typing import List

def cancel_tasks(api_key: str, task_ids: List[str]) -> dict:
    """
    Cancel multiple Labelbox tasks and return their status
    
    Args:
        api_key: Labelbox API key
        task_ids: List of task IDs to cancel
        
    Returns:
        Dictionary with task IDs as keys and their cancellation status as values
    """
    
    client = lb.Client(api_key=api_key)
    
    results = {}
    
    for task_id in task_ids:
        try:
            export_task = client.get_task_by_id(task_id)
            
            success = client.cancel_task(export_task.uid)
            
            # Verify the task was cancelled
            if success:
                cancelled_task = client.get_task_by_id(export_task.uid)
                status = cancelled_task.status
                results[task_id] = {
                    'success': success,
                    'status': status
                }
            else:
                results[task_id] = {
                    'success': False,
                    'error': 'Failed to cancel task'
                }
                
        except Exception as e:
            results[task_id] = {
                'success': False,
                'error': str(e)
            }
    
    return results

if __name__ == "__main__":
    api_key = "your_api_key_here"
    task_ids = [
        "task_id_1",
        "task_id_2",
        "task_id_3"
    ]
    
    results = cancel_tasks(api_key, task_ids)
    
    for task_id, result in results.items():
        print(f"\nTask ID: {task_id}")
        if result['success']:
            print(f"Status: {result['status']}")
        else:
            print(f"Error: {result['error']}") 

Thank you for the suggested method!

Regarding the task cancellation code - This seems like iterating one task at a time to cancel.
However, is there a way to query and cancel multiple tasks in bulk?
The current implementation cancels tasks one-by-one using client.cancel_task(uid), which is slow since we can only call this function once the task is in-progress, and only a small batch enters in-progress state at a time (from my observation).
I’m looking for a way to:

  1. Query all tasks (both in-progress and pending)
  2. Cancel them in a single bulk operation rather than iterating through tasks individually.

Thanks!