diff --git a/backend/auto_labeling/tests/test_views.py b/backend/auto_labeling/tests/test_views.py index f1281bb4..cd5d176a 100644 --- a/backend/auto_labeling/tests/test_views.py +++ b/backend/auto_labeling/tests/test_views.py @@ -150,7 +150,7 @@ class TestConfigCreation(CRUDMixin): self.assertEqual(len(response.data), 1) -class TestAutomatedCategoryLabeling(CRUDMixin): +class TestAutomatedLabeling(CRUDMixin): def setUp(self): self.project = prepare_project(task=DOCUMENT_CLASSIFICATION, single_class_classification=False) @@ -162,7 +162,8 @@ class TestAutomatedCategoryLabeling(CRUDMixin): 'CategoryType', project=self.project.item, text='NEG' ) self.loc = mommy.make('SpanType', project=self.project.item, text='LOC') - self.url = reverse(viewname='automated_labeling', args=[self.project.item.id, self.example.id]) + self.url = reverse(viewname='auto_labeling', args=[self.project.item.id]) + self.url += f'?example={self.example.id}' @patch('auto_labeling.views.execute_pipeline', return_value=Categories([{'label': 'POS'}])) def test_category_labeling(self, mock): @@ -226,7 +227,8 @@ class TestAutomatedSpanLabeling(CRUDMixin): self.project = prepare_project(task=SEQUENCE_LABELING) self.example = make_doc(self.project.item) self.loc = mommy.make('SpanType', project=self.project.item, text='LOC') - self.url = reverse(viewname='automated_labeling', args=[self.project.item.id, self.example.id]) + self.url = reverse(viewname='auto_labeling', args=[self.project.item.id]) + self.url += f'?example={self.example.id}' @patch( 'auto_labeling.views.execute_pipeline', @@ -247,7 +249,8 @@ class TestAutomatedTextLabeling(CRUDMixin): def setUp(self): self.project = prepare_project(task=SEQ2SEQ) self.example = make_doc(self.project.item) - self.url = reverse(viewname='automated_labeling', args=[self.project.item.id, self.example.id]) + self.url = reverse(viewname='auto_labeling', args=[self.project.item.id]) + self.url += f'?example={self.example.id}' @patch( 'auto_labeling.views.execute_pipeline', diff --git a/backend/auto_labeling/urls.py b/backend/auto_labeling/urls.py index c9a64f2e..404a0c44 100644 --- a/backend/auto_labeling/urls.py +++ b/backend/auto_labeling/urls.py @@ -6,43 +6,43 @@ from .views import (ConfigDetail, AutomatedLabeling, urlpatterns = [ path( - route='auto-labeling-templates', + route='auto-labeling/templates', view=TemplateListAPI.as_view(), name='auto_labeling_templates' ), path( - route='auto-labeling-templates/', + route='auto-labeling/templates/', view=TemplateDetailAPI.as_view(), name='auto_labeling_template' ), path( - route='auto-labeling-configs', + route='auto-labeling/configs', view=ConfigList.as_view(), name='auto_labeling_configs' ), path( - route='auto-labeling-configs/', + route='auto-labeling/configs/', view=ConfigDetail.as_view(), name='auto_labeling_config' ), path( - route='auto-labeling-parameter-testing', + route='auto-labeling/request-testing', view=RestAPIRequestTesting.as_view(), name='auto_labeling_parameter_testing' ), path( - route='auto-labeling-template-testing', + route='auto-labeling/label-extractor-testing', view=LabelExtractorTesting.as_view(), name='auto_labeling_template_test' ), path( - route='auto-labeling-mapping-testing', + route='auto-labeling/label-mapper-testing', view=LabelMapperTesting.as_view(), name='auto_labeling_mapping_test' ), path( - route='examples//auto-labeling', + route='auto-labeling', view=AutomatedLabeling.as_view(), - name='automated_labeling' + name='auto_labeling' ), ] diff --git a/backend/auto_labeling/views.py b/backend/auto_labeling/views.py index 8dbd83b9..1331a885 100644 --- a/backend/auto_labeling/views.py +++ b/backend/auto_labeling/views.py @@ -148,7 +148,7 @@ class AutomatedLabeling(generics.CreateAPIView): def create(self, request, *args, **kwargs): project = get_object_or_404(Project, pk=self.kwargs['project_id']) - example = get_object_or_404(Example, pk=self.kwargs['example_id']) + example = project.examples.get(pk=self.request.query_params['example']) configs = AutoLabelingConfig.objects.filter(project=project) # Todo: make async calls or celery tasks to reduce waiting time. for config in configs: diff --git a/frontend/domain/models/tasks/annotationRepository.ts b/frontend/domain/models/tasks/annotationRepository.ts index f603b63b..0f396577 100644 --- a/frontend/domain/models/tasks/annotationRepository.ts +++ b/frontend/domain/models/tasks/annotationRepository.ts @@ -31,7 +31,7 @@ export abstract class AnnotationRepository { } public async autoLabel(projectId: string, docId: number): Promise { - const url = `/projects/${projectId}/examples/${docId}/auto-labeling` + const url = `/projects/${projectId}/auto-labeling?example=${docId}` await this.request.post(url, {}) } diff --git a/frontend/repositories/autoLabeling/config/apiConfigRepository.ts b/frontend/repositories/autoLabeling/config/apiConfigRepository.ts index 89bb9c90..1342addc 100644 --- a/frontend/repositories/autoLabeling/config/apiConfigRepository.ts +++ b/frontend/repositories/autoLabeling/config/apiConfigRepository.ts @@ -17,7 +17,7 @@ export class APIConfigRepository implements ConfigRepository { ) {} async list(projectId: string): Promise { - const url = `/projects/${projectId}/auto-labeling-configs` + const url = `/projects/${projectId}/auto-labeling/configs` const response = await this.request.get(url) const responseItems: ConfigItemResponse[] = response.data return ConfigItemList.valueOf( @@ -26,14 +26,14 @@ export class APIConfigRepository implements ConfigRepository { } async create(projectId: string, item: ConfigItem): Promise { - const url = `/projects/${projectId}/auto-labeling-configs` + const url = `/projects/${projectId}/auto-labeling/configs` const response = await this.request.post(url, item.toAPI()) const responseItem: ConfigItemResponse = response.data return ConfigItem.valueOf(responseItem) } async update(projectId: string, item: ConfigItem): Promise { - const url = `/projects/${projectId}/auto-labeling-configs/${item.id}` + const url = `/projects/${projectId}/auto-labeling/configs/${item.id}` const response = await this.request.put(url, { id: item.id, model_name: item.modelName, @@ -46,12 +46,12 @@ export class APIConfigRepository implements ConfigRepository { } async delete(projectId: string, itemId: number): Promise { - const url = `/projects/${projectId}/auto-labeling-configs/${itemId}` + const url = `/projects/${projectId}/auto-labeling/configs/${itemId}` await this.request.delete(url) } async testParameters(projectId: string, item: ConfigItem, text: string) { - const url = `/projects/${projectId}/auto-labeling-parameter-testing` + const url = `/projects/${projectId}/auto-labeling/request-testing` const response = await this.request.post(url, {...item.toAPI(), text}) const responseItem: ConfigTestResponse = response.data return responseItem @@ -59,14 +59,14 @@ export class APIConfigRepository implements ConfigRepository { async testTemplate(projectId: string, response: any, item: ConfigItem): Promise { console.log(projectId) - const url = `/projects/${projectId}/auto-labeling-template-testing` + const url = `/projects/${projectId}/auto-labeling/label-extractor-testing` const _response = await this.request.post(url, { response, ...item.toAPI() }) const responseItem: ConfigTestResponse = _response.data return responseItem } async testMapping(projectId: string, item: ConfigItem, response: any): Promise { - const url = `/projects/${projectId}/auto-labeling-mapping-testing` + const url = `/projects/${projectId}/auto-labeling/label-mapper-testing` const _response = await this.request.post(url, {...item.toAPI(), response}) const responseItem: ConfigTestResponse = _response.data return responseItem diff --git a/frontend/repositories/autoLabeling/template/apiTemplateRepository.ts b/frontend/repositories/autoLabeling/template/apiTemplateRepository.ts index f49f1974..15b3c84a 100644 --- a/frontend/repositories/autoLabeling/template/apiTemplateRepository.ts +++ b/frontend/repositories/autoLabeling/template/apiTemplateRepository.ts @@ -8,14 +8,14 @@ export class APITemplateRepository implements TemplateRepository { ) {} async list(projectId: string, taskName: string): Promise { - const url = `/projects/${projectId}/auto-labeling-templates?task_name=${taskName}` + const url = `/projects/${projectId}/auto-labeling/templates?task_name=${taskName}` const response = await this.request.get(url) const responseItems: string[] = response.data return responseItems } async find(projectId: string, optionName: string): Promise { - const url = `/projects/${projectId}/auto-labeling-templates/${optionName}` + const url = `/projects/${projectId}/auto-labeling/templates/${optionName}` const response = await this.request.get(url) const responseItem: ConfigResponse = response.data return ConfigTemplateItem.valueOf(responseItem)