Browse Source

Change AutoLabelingAnnotation API url

pull/1413/head
Hironsan 3 years ago
parent
commit
720f0d4f00
2 changed files with 4 additions and 4 deletions
  1. 2
      backend/api/urls.py
  2. 6
      backend/api/views/auto_labeling.py

2
backend/api/urls.py

@ -175,7 +175,7 @@ urlpatterns_project = [
name='auto_labeling_config_test'
),
path(
route='docs/<int:doc_id>/auto-labeling',
route='examples/<int:example_id>/auto-labeling',
view=views.AutoLabelingAnnotation.as_view(),
name='auto_labeling_annotation'
),

6
backend/api/views/auto_labeling.py

@ -203,7 +203,7 @@ class AutoLabelingAnnotation(generics.CreateAPIView):
def get_queryset(self):
project = get_object_or_404(Project, pk=self.kwargs['project_id'])
model = project.get_annotation_class()
queryset = model.objects.filter(example=self.kwargs['doc_id'])
queryset = model.objects.filter(example=self.kwargs['example_id'])
if not project.collaborative_annotation:
queryset = queryset.filter(user=self.request.user)
return queryset
@ -224,7 +224,7 @@ class AutoLabelingAnnotation(generics.CreateAPIView):
serializer.save(user=self.request.user)
def get_example(self, project):
example = get_object_or_404(Example, pk=self.kwargs['doc_id'])
example = get_object_or_404(Example, pk=self.kwargs['example_id'])
if project.is_task_of('text'):
return example.text
else:
@ -248,7 +248,7 @@ class AutoLabelingAnnotation(generics.CreateAPIView):
def transform(self, labels):
project = get_object_or_404(Project, pk=self.kwargs['project_id'])
for label in labels:
label['example'] = self.kwargs['doc_id']
label['example'] = self.kwargs['example_id']
if 'label' in label:
label['label'] = project.labels.get(text=label.pop('label')).id
return labels

Loading…
Cancel
Save