label_studio/data_manager/actions/basic.py
def delete_tasks_annotations(project, queryset, **kwargs):
    """ Delete all annotations by tasks ids

    :param project: project instance
    :param queryset: filtered tasks db queryset
    """
    task_ids = queryset.values_list('id', flat=True)
    annotations = Annotation.objects.filter(task__id__in=task_ids)
    count = annotations.count()

    # take only tasks where annotations were deleted
    real_task_ids = set(list(annotations.values_list('task__id', flat=True)))
    annotations_ids = list(annotations.values('id'))
    annotations.delete()
    emit_webhooks_for_instance(project.organization, project, WebhookAction.ANNOTATIONS_DELETED, annotations_ids)
    start_job_async_or_sync(bulk_update_stats_project_tasks, queryset.filter(is_labeled=True))

    request = kwargs['request']
    Task.objects.filter(id__in=real_task_ids).update(updated_at=datetime.now(), updated_by=request.user)
    return {'processed_items': count,
            'detail': 'Deleted ' + str(count) + ' annotations'}
 Delete all annotations by tasks ids

    :param project: project instance
    :param queryset: filtered tasks db queryset
    
Delete all annotations by tasks ids
Delete all annotations by tasks ids
def delete_tasks_annotations(project, queryset, **kwargs):
    task_ids = queryset.values_list('id', flat=True)
    annotations = Annotation.objects.filter(task__id__in=task_ids)
    count = annotations.count()
    real_task_ids = set(list(annotations.values_list('task__id', flat=True)))
    annotations_ids = list(annotations.values('id'))
    annotations.delete()
    emit_webhooks_for_instance(project.organization, project, WebhookAction.ANNOTATIONS_DELETED, annotations_ids)
    start_job_async_or_sync(bulk_update_stats_project_tasks, queryset.filter(is_labeled=True))
    request = kwargs['request']
    Task.objects.filter(id__in=real_task_ids).update(updated_at=datetime.now(), updated_by=request.user)
    return {'processed_items': count,
            'detail': 'Deleted ' + str(count) + ' annotations'}
def delete_tasks_annotations ( project , queryset , ** kwargs ) : task_ids = queryset . values_list ( 'id' , flat = True ) annotations = Annotation . objects . filter ( task__id__in = task_ids ) count = annotations . count ( ) real_task_ids = set ( list ( annotations . values_list ( 'task__id' , flat = True ) ) ) annotations_ids = list ( annotations . values ( 'id' ) ) annotations . delete ( ) emit_webhooks_for_instance ( project . organization , project , WebhookAction . ANNOTATIONS_DELETED , annotations_ids ) start_job_async_or_sync ( bulk_update_stats_project_tasks , queryset . filter ( is_labeled = True ) ) request = kwargs [ 'request' ] Task . objects . filter ( id__in = real_task_ids ) . update ( updated_at = datetime . now ( ) , updated_by = request . user ) return { 'processed_items' : count , 'detail' : 'Deleted ' + str ( count ) + ' annotations' }
Delete all annotations by tasks ids
Delete all annotations by tasks ids
""" Delete all annotations by tasks ids

    :param project: project instance
    :param queryset: filtered tasks db queryset
    """ # take only tasks where annotations were deleted
project
None
queryset
filtered tasks db queryset
filtered tasks db queryset