Browse Source

Avoid save labels if there is no corresponding example

pull/1823/head
Hironsan 2 years ago
parent
commit
4fc40eb9c8
1 changed files with 4 additions and 1 deletions
  1. 5
      backend/data_import/pipeline/labels.py

5
backend/data_import/pipeline/labels.py

@ -41,8 +41,11 @@ class Labels(abc.ABC):
return {example.uuid: example for example in examples}
def save(self, user, **kwargs):
uuid_to_example = self.uuid_to_example
labels = [
label.create(user, self.uuid_to_example[label.example_uuid], self.types, **kwargs) for label in self.labels
label.create(user, uuid_to_example[label.example_uuid], self.types, **kwargs)
for label in self.labels
if label.example_uuid in uuid_to_example
]
self.label_model.objects.bulk_create(labels)

Loading…
Cancel
Save