label_studio/projects/functions/next_task.py
def _try_breadth_first(tasks, user):
    """Try to find tasks with maximum amount of annotations, since we are trying to label tasks as fast as possible
    """

    tasks = tasks.annotate(annotations_count=Count('annotations'))
    max_annotations_count = tasks.aggregate(Max('annotations_count'))['annotations_count__max']
    if max_annotations_count == 0:
        # there is no any labeled tasks found
        return

    # find any task with maximal amount of created annotations
    not_solved_tasks_labeling_started = tasks.annotate(
        reach_max_annotations_count=Case(
            When(annotations_count=max_annotations_count, then=Value(True)),
            default=Value(False),
            output_field=BooleanField(),
        )
    )
    not_solved_tasks_labeling_with_max_annotations = not_solved_tasks_labeling_started.filter(
        reach_max_annotations_count=True
    )
    if not_solved_tasks_labeling_with_max_annotations.exists():
        # try to complete tasks that are already in progress
        return _get_random_unlocked(not_solved_tasks_labeling_with_max_annotations, user)
Try to find tasks with maximum amount of annotations, since we are trying to label tasks as fast as possible
    
Try to find tasks with maximum amount of annotations, since we are trying to label tasks as fast as possible
Try to find tasks with maximum amount of annotations since we are trying to label tasks as fast as possible
def _try_breadth_first(tasks, user):
    tasks = tasks.annotate(annotations_count=Count('annotations'))
    max_annotations_count = tasks.aggregate(Max('annotations_count'))['annotations_count__max']
    if max_annotations_count == 0:
        return
    not_solved_tasks_labeling_started = tasks.annotate(
        reach_max_annotations_count=Case(
            When(annotations_count=max_annotations_count, then=Value(True)),
            default=Value(False),
            output_field=BooleanField(),
        )
    )
    not_solved_tasks_labeling_with_max_annotations = not_solved_tasks_labeling_started.filter(
        reach_max_annotations_count=True
    )
    if not_solved_tasks_labeling_with_max_annotations.exists():
        return _get_random_unlocked(not_solved_tasks_labeling_with_max_annotations, user)
def _try_breadth_first ( tasks , user ) : tasks = tasks . annotate ( annotations_count = Count ( 'annotations' ) ) max_annotations_count = tasks . aggregate ( Max ( 'annotations_count' ) ) [ 'annotations_count__max' ] if max_annotations_count == 0 : return not_solved_tasks_labeling_started = tasks . annotate ( reach_max_annotations_count = Case ( When ( annotations_count = max_annotations_count , then = Value ( True ) ) , default = Value ( False ) , output_field = BooleanField ( ) , ) ) not_solved_tasks_labeling_with_max_annotations = not_solved_tasks_labeling_started . filter ( reach_max_annotations_count = True ) if not_solved_tasks_labeling_with_max_annotations . exists ( ) : return _get_random_unlocked ( not_solved_tasks_labeling_with_max_annotations , user )
Try to find tasks with maximum amount of annotations, since we are trying to label tasks as fast as possible
Try to find tasks with maximum amount of annotations since we are trying to label tasks as fast as possible
"""Try to find tasks with maximum amount of annotations, since we are trying to label tasks as fast as possible
    """ # there is no any labeled tasks found # find any task with maximal amount of created annotations # try to complete tasks that are already in progress
tasks
user