Browse Source

Remove unused FullPipelineTesting API

pull/1650/head
Hironsan 3 years ago
parent
commit
a710d4e7b1
5 changed files with 2 additions and 69 deletions
  1. 7
      backend/auto_labeling/urls.py
  2. 36
      backend/auto_labeling/views.py
  3. 2
      frontend/domain/models/autoLabeling/configRepository.ts
  4. 7
      frontend/repositories/autoLabeling/config/apiConfigRepository.ts
  5. 19
      frontend/services/application/autoLabeling/configApplicationService.ts

7
backend/auto_labeling/urls.py

@ -1,6 +1,6 @@
from django.urls import path
from .views import (ConfigDetail, FullPipelineTesting, AutomatedLabeling,
from .views import (ConfigDetail, AutomatedLabeling,
LabelMapperTesting, TemplateListAPI,
TemplateDetailAPI, ConfigList, RestAPIRequestTesting, LabelExtractorTesting)
@ -25,11 +25,6 @@ urlpatterns = [
view=ConfigDetail.as_view(),
name='auto_labeling_config'
),
path(
route='auto-labeling-config-testing',
view=FullPipelineTesting.as_view(),
name='auto_labeling_config_test'
),
path(
route='auto-labeling-parameter-testing',
view=RestAPIRequestTesting.as_view(),

36
backend/auto_labeling/views.py

@ -61,41 +61,6 @@ class ConfigDetail(generics.RetrieveUpdateDestroyAPIView):
permission_classes = [IsAuthenticated & IsProjectAdmin]
class FullPipelineTesting(APIView):
permission_classes = [IsAuthenticated & IsProjectAdmin]
def post(self, *args, **kwargs):
try:
output = self.pass_config_validation()
output = self.pass_pipeline_call(output)
if not output:
raise SampleDataException()
return Response(
data={'valid': True, 'labels': output},
status=status.HTTP_200_OK
)
except requests.exceptions.ConnectionError:
raise URLConnectionError()
except botocore.exceptions.ClientError:
raise AWSTokenError()
except ValidationError as e:
raise e
except Exception as e:
raise e
def pass_config_validation(self):
config = self.request.data['config']
serializer = AutoLabelingConfigSerializer(data=config)
serializer.is_valid(raise_exception=True)
return serializer
def pass_pipeline_call(self, serializer):
test_input = self.request.data['input']
config = AutoLabelingConfig(**serializer.data)
labels = execute_pipeline(test_input, config=config)
return labels.labels
class RestAPIRequestTesting(APIView):
permission_classes = [IsAuthenticated & IsProjectAdmin]
@ -186,6 +151,7 @@ class AutomatedLabeling(generics.CreateAPIView):
project = get_object_or_404(Project, pk=self.kwargs['project_id'])
example = get_object_or_404(Example, pk=self.kwargs['example_id'])
configs = AutoLabelingConfig.objects.filter(project=project)
# Todo: make async calls or celery tasks to reduce waiting time.
for config in configs:
labels = execute_pipeline(example.data, config=config)
labels.save(project, example, self.request.user)

2
frontend/domain/models/autoLabeling/configRepository.ts

@ -14,8 +14,6 @@ export interface ConfigRepository {
update(projectId: string, item: ConfigItem): Promise<ConfigItem>
testConfig(projectId: string, item: ConfigItem, text: string): Promise<ConfigTestResponse>
testParameters(projectId: string, item: ConfigItem, text: string): Promise<ConfigTestResponse>
testTemplate(projectId: string, response: any, item: ConfigItem): Promise<ConfigTestResponse>

7
frontend/repositories/autoLabeling/config/apiConfigRepository.ts

@ -50,13 +50,6 @@ export class APIConfigRepository implements ConfigRepository {
await this.request.delete(url)
}
async testConfig(projectId: string, item: ConfigItem, text: string): Promise<ConfigTestResponse> {
const url = `/projects/${projectId}/auto-labeling-config-testing`
const response = await this.request.post(url, {config: {...item.toAPI()}, input: text})
const responseItem: ConfigTestResponse = response.data
return responseItem
}
async testParameters(projectId: string, item: ConfigItem, text: string) {
const url = `/projects/${projectId}/auto-labeling-parameter-testing`
const response = await this.request.post(url, {...item.toAPI(), text})

19
frontend/services/application/autoLabeling/configApplicationService.ts

@ -18,25 +18,6 @@ export class ConfigApplicationService {
return this.configRepository.delete(projectId, itemId)
}
public testConfig(projectId: string, item: ConfigItem, text: string): Promise<ConfigTestResponse> {
return this.configRepository.testConfig(projectId, item, text)
.then((value) => {
return value
})
.catch((error) => {
const data = error.response.data
if ('non_field_errors' in data) {
throw new Error(data.non_field_errors)
} else if ('template' in data) {
throw new Error('The template need to be filled.')
} else if ('detail' in data) {
throw new Error(data.detail)
} else {
throw new Error(data)
}
})
}
public testParameters(projectId: string, item: ConfigItem, text: string) {
return this.configRepository.testParameters(projectId, item, text)
.then((value) => {

Loading…
Cancel
Save