Skip to content

Commit

Permalink
fix: LSDV-5289: Remove subquery from is_labeled update (#4474)
Browse files Browse the repository at this point in the history
  • Loading branch information
triklozoid authored Jul 5, 2023
1 parent 07ee41d commit 312a582
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions label_studio/projects/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -412,24 +412,24 @@ def _rearrange_overlap_cohort(self):
logger.info(f"Required tasks {must_tasks} and left required tasks {left_must_tasks}")
if left_must_tasks > 0:
# if there are unfinished tasks update tasks with count(annotations) >= overlap
ids = tasks_with_max_annotations.values_list('id', flat=True)
ids = list(tasks_with_max_annotations.values_list('id', flat=True))
all_project_tasks.filter(id__in=ids).update(overlap=max_annotations, is_labeled=True)
# order other tasks by count(annotations)
tasks_with_min_annotations = tasks_with_min_annotations.annotate(
anno=Count('annotations')
).order_by('-anno').distinct()
# assign overlap depending on annotation count
# assign max_annotations and update is_labeled
ids = tasks_with_min_annotations[:left_must_tasks].values_list('id', flat=True)
ids = list(tasks_with_min_annotations[:left_must_tasks].values_list('id', flat=True))
all_project_tasks.filter(id__in=ids).update(overlap=max_annotations)
# assign 1 to left
ids = tasks_with_min_annotations[left_must_tasks:].values_list('id', flat=True)
ids = list(tasks_with_min_annotations[left_must_tasks:].values_list('id', flat=True))
min_tasks_to_update = all_project_tasks.filter(id__in=ids)
min_tasks_to_update.update(overlap=1)
else:
ids = tasks_with_max_annotations.values_list('id', flat=True)
ids = list(tasks_with_max_annotations.values_list('id', flat=True))
all_project_tasks.filter(id__in=ids).update(overlap=max_annotations)
ids = tasks_with_min_annotations.values_list('id', flat=True)
ids = list(tasks_with_min_annotations.values_list('id', flat=True))
all_project_tasks.filter(id__in=ids).update(overlap=1)
# update is labeled after tasks rearrange overlap
bulk_update_stats_project_tasks(all_project_tasks, project=self)
Expand Down

0 comments on commit 312a582

Please sign in to comment.