Browse Source

Rename APIs related auto labeling

pull/1650/head
Hironsan 2 years ago
parent
commit
f6f637601c
3 changed files with 24 additions and 24 deletions
  1. 6
      backend/auto_labeling/tests/test_views.py
  2. 24
      backend/auto_labeling/urls.py
  3. 18
      backend/auto_labeling/views.py

6
backend/auto_labeling/tests/test_views.py

@ -25,20 +25,20 @@ class TestConfigParameter(CRUDMixin):
}
self.url = reverse(viewname='auto_labeling_parameter_testing', args=[self.project.item.id])
@patch('auto_labeling.views.AutoLabelingConfigParameterTest.send_request', return_value={})
@patch('auto_labeling.views.RestAPIRequestTesting.send_request', return_value={})
def test_called_with_proper_model(self, mock):
self.assert_create(self.project.users[0], status.HTTP_200_OK)
_, kwargs = mock.call_args
expected = RequestModelFactory.create(self.data['model_name'], self.data['model_attrs'])
self.assertEqual(kwargs['model'], expected)
@patch('auto_labeling.views.AutoLabelingConfigParameterTest.send_request', return_value={})
@patch('auto_labeling.views.RestAPIRequestTesting.send_request', return_value={})
def test_called_with_text(self, mock):
self.assert_create(self.project.users[0], status.HTTP_200_OK)
_, kwargs = mock.call_args
self.assertEqual(kwargs['example'], self.data['text'])
@patch('auto_labeling.views.AutoLabelingConfigParameterTest.send_request', return_value={})
@patch('auto_labeling.views.RestAPIRequestTesting.send_request', return_value={})
def test_called_with_image(self, mock):
self.data['text'] = str(data_dir / 'images/1500x500.jpeg')
self.assert_create(self.project.users[0], status.HTTP_200_OK)

24
backend/auto_labeling/urls.py

@ -1,53 +1,53 @@
from django.urls import path
from .views import (AutoLabelingConfigDetail, AutoLabelingConfigTest, AutoLabelingAnnotation, AutoLabelingMappingTest,
AutoLabelingTemplateListAPI, AutoLabelingTemplateDetailAPI, AutoLabelingConfigList,
AutoLabelingConfigParameterTest, AutoLabelingTemplateTest)
from .views import (ConfigDetail, FullPipelineTesting, AutomatedDataLabeling, LabelMapperTesting,
TemplateListAPI, TemplateDetailAPI, ConfigList,
RestAPIRequestTesting, LabelExtractorTesting)
urlpatterns = [
path(
route='auto-labeling-templates',
view=AutoLabelingTemplateListAPI.as_view(),
view=TemplateListAPI.as_view(),
name='auto_labeling_templates'
),
path(
route='auto-labeling-templates/<str:option_name>',
view=AutoLabelingTemplateDetailAPI.as_view(),
view=TemplateDetailAPI.as_view(),
name='auto_labeling_template'
),
path(
route='auto-labeling-configs',
view=AutoLabelingConfigList.as_view(),
view=ConfigList.as_view(),
name='auto_labeling_configs'
),
path(
route='auto-labeling-configs/<int:config_id>',
view=AutoLabelingConfigDetail.as_view(),
view=ConfigDetail.as_view(),
name='auto_labeling_config'
),
path(
route='auto-labeling-config-testing',
view=AutoLabelingConfigTest.as_view(),
view=FullPipelineTesting.as_view(),
name='auto_labeling_config_test'
),
path(
route='examples/<int:example_id>/auto-labeling',
view=AutoLabelingAnnotation.as_view(),
view=AutomatedDataLabeling.as_view(),
name='auto_labeling_annotation'
),
path(
route='auto-labeling-parameter-testing',
view=AutoLabelingConfigParameterTest.as_view(),
view=RestAPIRequestTesting.as_view(),
name='auto_labeling_parameter_testing'
),
path(
route='auto-labeling-template-testing',
view=AutoLabelingTemplateTest.as_view(),
view=LabelExtractorTesting.as_view(),
name='auto_labeling_template_test'
),
path(
route='auto-labeling-mapping-testing',
view=AutoLabelingMappingTest.as_view(),
view=LabelMapperTesting.as_view(),
name='auto_labeling_mapping_test'
)
]

18
backend/auto_labeling/views.py

@ -25,7 +25,7 @@ from .models import AutoLabelingConfig
from .serializers import (AutoLabelingConfigSerializer, get_annotation_serializer)
class AutoLabelingTemplateListAPI(APIView):
class TemplateListAPI(APIView):
permission_classes = [IsAuthenticated & IsProjectAdmin]
def get(self, request, *args, **kwargs):
@ -35,7 +35,7 @@ class AutoLabelingTemplateListAPI(APIView):
return Response(option_names, status=status.HTTP_200_OK)
class AutoLabelingTemplateDetailAPI(APIView):
class TemplateDetailAPI(APIView):
permission_classes = [IsAuthenticated & IsProjectAdmin]
def get(self, request, *args, **kwargs):
@ -43,7 +43,7 @@ class AutoLabelingTemplateDetailAPI(APIView):
return Response(option.to_dict(), status=status.HTTP_200_OK)
class AutoLabelingConfigList(generics.ListCreateAPIView):
class ConfigList(generics.ListCreateAPIView):
serializer_class = AutoLabelingConfigSerializer
pagination_class = None
permission_classes = [IsAuthenticated & IsProjectAdmin]
@ -55,14 +55,14 @@ class AutoLabelingConfigList(generics.ListCreateAPIView):
serializer.save(project_id=self.kwargs['project_id'])
class AutoLabelingConfigDetail(generics.RetrieveUpdateDestroyAPIView):
class ConfigDetail(generics.RetrieveUpdateDestroyAPIView):
queryset = AutoLabelingConfig.objects.all()
serializer_class = AutoLabelingConfigSerializer
lookup_url_kwarg = 'config_id'
permission_classes = [IsAuthenticated & IsProjectAdmin]
class AutoLabelingConfigTest(APIView):
class FullPipelineTesting(APIView):
permission_classes = [IsAuthenticated & IsProjectAdmin]
def post(self, *args, **kwargs):
@ -103,7 +103,7 @@ class AutoLabelingConfigTest(APIView):
)
class AutoLabelingConfigParameterTest(APIView):
class RestAPIRequestTesting(APIView):
permission_classes = [IsAuthenticated & IsProjectAdmin]
@property
@ -151,7 +151,7 @@ class AutoLabelingConfigParameterTest(APIView):
return Response(response, status=status.HTTP_200_OK)
class AutoLabelingTemplateTest(APIView):
class LabelExtractorTesting(APIView):
permission_classes = [IsAuthenticated & IsProjectAdmin]
def post(self, *args, **kwargs):
@ -172,7 +172,7 @@ class AutoLabelingTemplateTest(APIView):
return Response(labels.dict(), status=status.HTTP_200_OK)
class AutoLabelingMappingTest(APIView):
class LabelMapperTesting(APIView):
permission_classes = [IsAuthenticated & IsProjectAdmin]
def post(self, *args, **kwargs):
@ -186,7 +186,7 @@ class AutoLabelingMappingTest(APIView):
return Response(labels.dict(), status=status.HTTP_200_OK)
class AutoLabelingAnnotation(generics.CreateAPIView):
class AutomatedDataLabeling(generics.CreateAPIView):
pagination_class = None
permission_classes = [IsAuthenticated & IsInProjectOrAdmin]
swagger_schema = None

Loading…
Cancel
Save