Browse Source

Update auto-labeling-pipeline

pull/1413/head
Hironsan 3 years ago
parent
commit
caf1ad222f
3 changed files with 12 additions and 20 deletions
  1. 18
      Pipfile.lock
  2. 5
      backend/api/tests/api/test_auto_labeling.py
  3. 9
      backend/api/views/auto_labeling.py

18
Pipfile.lock

@ -42,11 +42,11 @@
},
"auto-labeling-pipeline": {
"hashes": [
"sha256:39d7603c39455d68f4f89a7811c40b70ce8f54e514be419b36eba5710d411921",
"sha256:e28125d195eac7f01612a079eaf9ebdd5bdc71827b2cf7fca0c74004c6dcf84e"
"sha256:6bf6eb6761f8043cf385469db46cca995ea5cfd2c46cf31c4af3979935509a81",
"sha256:8b5fce9f5174b24b0baab28ecba9357f77631c648e99bcfa98f8212d2ccdb5e7"
],
"index": "pypi",
"version": "==0.1.18"
"version": "==0.1.19"
},
"billiard": {
"hashes": [
@ -57,19 +57,19 @@
},
"boto3": {
"hashes": [
"sha256:e9cf20918ed1b78f1aabbc57e02a126e835ccf7abe86d90646fc54a43ef7dc06",
"sha256:ee1e64191de95e08e296b21cb262f38c8dc866cd7d33f86f753c6a74a0f95297"
"sha256:64899ae291f6a0bcbef0cfad9c5e45e1f4bf3a4cbc89e1b9a817349600deec9b",
"sha256:e55cbe77a79ef125c17900be38e1cada6d6dab1cc7356f10b24ac07f0a7d0445"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'",
"version": "==1.17.92"
"version": "==1.17.93"
},
"botocore": {
"hashes": [
"sha256:5adb6679e3bf7b5ea0ca3363118a0111d087dce18a94fc7a5a542fcc5cba0ddc",
"sha256:950ff7d4985427f8dfbb90aa1a8b48da98506d25319f1af1fe20341be3365633"
"sha256:47b8cea6213490866f34fb31ab30f04c2d7cf188c7ab9714556f0e8f7926ebc4",
"sha256:aae0f08627ef411a9579ae2a588a15f0859b2b40cecd5cde6055f0354712dd6f"
],
"markers": "python_version >= '2.7' and python_version not in '3.0, 3.1, 3.2, 3.3, 3.4, 3.5'",
"version": "==1.20.92"
"version": "==1.20.93"
},
"celery": {
"hashes": [

5
backend/api/tests/api/test_auto_labeling.py

@ -7,7 +7,6 @@ from rest_framework import status
from rest_framework.reverse import reverse
from ...models import DOCUMENT_CLASSIFICATION, IMAGE_CLASSIFICATION
from ...views.auto_labeling import load_data_as_b64
from .utils import (CRUDMixin, make_auto_labeling_config, make_doc, make_image,
prepare_project)
@ -40,7 +39,7 @@ class TestConfigParameter(CRUDMixin):
@patch('api.views.auto_labeling.AutoLabelingConfigParameterTest.send_request', return_value={})
def test_called_with_image(self, mock):
self.data['text'] = load_data_as_b64(data_dir / 'images/1500x500.jpeg')
self.data['text'] = str(data_dir / 'images/1500x500.jpeg')
self.assert_create(self.project.users[0], status.HTTP_200_OK)
_, kwargs = mock.call_args
self.assertEqual(kwargs['example'], self.data['text'])
@ -139,5 +138,5 @@ class TestAutoLabelingImage(CRUDMixin):
def test_text_task(self, mock):
self.assert_create(self.project.users[0], status.HTTP_201_CREATED)
_, kwargs = mock.call_args
expected = load_data_as_b64(str(self.example.filename))
expected = str(self.example.filename)
self.assertEqual(kwargs['text'], expected)

9
backend/api/views/auto_labeling.py

@ -1,4 +1,3 @@
import base64
import json
import botocore.exceptions
@ -25,12 +24,6 @@ from ..serializers import (AutoLabelingConfigSerializer,
get_annotation_serializer)
def load_data_as_b64(filepath):
with open(filepath, 'rb') as f:
byte_str = base64.b64encode(f.read())
return byte_str.decode('utf-8')
class AutoLabelingTemplateListAPI(APIView):
permission_classes = [IsAuthenticated & IsProjectAdmin]
@ -228,7 +221,7 @@ class AutoLabelingAnnotation(generics.CreateAPIView):
if project.is_task_of('text'):
return example.text
else:
return load_data_as_b64(str(example.filename))
return str(example.filename)
def extract(self):
project = get_object_or_404(Project, pk=self.kwargs['project_id'])

Loading…
Cancel
Save