Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions label_studio/projects/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -438,6 +438,7 @@ def perform_create(self, serializer):
project = get_object_with_check_and_log(self.request, Project, pk=self.kwargs['pk'])
instance = serializer.save(project=project)
emit_webhooks_for_instance(self.request.user.active_organization, project, WebhookAction.TASKS_CREATED, [instance])
return instance


class TemplateListAPI(generics.ListAPIView):
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
# Generated by Django 3.2.14 on 2022-11-25 15:03

from django.db import migrations, models


class Migration(migrations.Migration):

dependencies = [
('projects', '0017_project_pinned_at'),
]

operations = [
migrations.AlterField(
model_name='project',
name='control_weights',
field=models.JSONField(default=dict, help_text="Dict of weights for each control tag in metric calculation. Each control tag (e.g. label or choice) will have it's own key in control weight dict with weight for each label and overall weight.For example, if bounding box annotation with control tag named my_bbox should be included with 0.33 weight in agreement calculation, and the first label Car should be twice more important than Airplaine, then you have to need the specify: {'my_bbox': {'type': 'RectangleLabels', 'labels': {'Car': 1.0, 'Airplaine': 0.5}, 'overall': 0.33}", null=True, verbose_name='control weights'),
),
]
17 changes: 17 additions & 0 deletions label_studio/tasks/migrations/0031_alter_task_options.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
# Generated by Django 3.2.14 on 2022-11-25 15:03

from django.db import migrations


class Migration(migrations.Migration):

dependencies = [
('tasks', '0030_auto_20221102_1118'),
]

operations = [
migrations.AlterModelOptions(
name='task',
options={},
),
]
7 changes: 7 additions & 0 deletions label_studio/tasks/mixins.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,13 @@ def _get_is_labeled_value(self):
n = self.completed_annotations.count()
return n >= self.overlap

def update_is_labeled(self, *args, **kwargs):
self.is_labeled = self._get_is_labeled_value()

@classmethod
def post_process_bulk_update_stats(cls, tasks):
pass


class AnnotationMixin(models.Model):
class Meta:
Expand Down
6 changes: 2 additions & 4 deletions label_studio/tasks/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -284,9 +284,6 @@ def completed_annotations(self):
else:
return self.annotations.filter(Q_finished_annotations)

def update_is_labeled(self):
self.is_labeled = self._get_is_labeled_value()

def increase_project_summary_counters(self):
if hasattr(self.project, 'summary'):
summary = self.project.summary
Expand Down Expand Up @@ -760,7 +757,7 @@ def update_task_stats(task, stats=('is_labeled',), save=True):
"""
logger.debug(f'Update stats {stats} for task {task}')
if 'is_labeled' in stats:
task.update_is_labeled()
task.update_is_labeled(save=save)
if save:
task.save()

Expand All @@ -781,6 +778,7 @@ def bulk_update_stats_project_tasks(tasks):
update_task_stats(task, save=False)
# start update query batches
bulk_update(tasks, update_fields=['is_labeled'], batch_size=settings.BATCH_SIZE)
Task.post_process_bulk_update_stats(tasks)

Q_finished_annotations = Q(was_cancelled=False) & Q(result__isnull=False)
Q_task_finished_annotations = Q(annotations__was_cancelled=False) & \
Expand Down
5 changes: 5 additions & 0 deletions label_studio/tasks/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -390,12 +390,17 @@ def create(self, validated_data):
self.project.save()

self.post_process_annotations(user, self.db_annotations, 'imported')
self.post_process_tasks(self.project.id, [t.id for t in self.db_tasks])
return db_tasks

@staticmethod
def post_process_annotations(user, db_annotations, action):
pass

@staticmethod
def post_process_tasks(user, db_tasks):
pass

@staticmethod
def add_annotation_fields(body, user, action):
return body
Expand Down