Browse Source

Update catalog

pull/1310/head
Hironsan 3 years ago
parent
commit
af2f408991
5 changed files with 13 additions and 10 deletions
  1. 2
      app/api/views/__init__.py
  2. 6
      app/api/views/upload/catalog.py
  3. 2
      app/api/views/upload/dataset.py
  4. 4
      app/api/views/upload/factory.py
  5. 9
      app/api/views/upload/view.py

2
app/api/views/__init__.py

@ -9,5 +9,5 @@ from .project import *
from .role import *
from .statistics import *
from .task import *
from .user import *
from .upload import *
from .user import *

6
app/api/views/upload/catalog.py

@ -2,8 +2,10 @@ from collections import defaultdict
from typing import Dict, List, Type
from pydantic import BaseModel
from typing_extensions import Literal
from ...models import DOCUMENT_CLASSIFICATION, SEQ2SEQ, SEQUENCE_LABELING
from ...models import DOCUMENT_CLASSIFICATION, SEQUENCE_LABELING, SEQ2SEQ
CSV = 'CSV'
FastText = 'fastText'
JSON = 'JSON'
@ -18,7 +20,7 @@ class OptionColumn(BaseModel):
class OptionDelimiter(OptionColumn):
delimiter: str = ','
delimiter: Literal[',', '\t', ';', '|', ' '] = ','
class OptionNone(BaseModel):

2
app/api/views/upload/dataset.py

@ -118,7 +118,7 @@ class CsvDataset(Dataset):
column_data = self.kwargs.get('column_data', 'text')
if column_data not in header:
message = f'{column_data} does not exist in the header: {header}'
message = f'Column `{column_data}` does not exist in the header: {header}'
raise FileParseException(filename, 1, message)
for line_num, row in enumerate(reader, start=2):

4
app/api/views/upload/factory.py

@ -1,5 +1,5 @@
from . import data, dataset, label, catalog
from ...models import DOCUMENT_CLASSIFICATION, SEQUENCE_LABELING, SEQ2SEQ
from ...models import DOCUMENT_CLASSIFICATION, SEQ2SEQ, SEQUENCE_LABELING
from . import catalog, data, dataset, label
def get_data_class(project_type: str):

9
app/api/views/upload/view.py

@ -6,10 +6,10 @@ from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView
from .catalog import Options
from ...models import Project
from ...permissions import IsProjectAdmin
from ...tasks import injest_data
from .catalog import Options
class DatasetCatalog(APIView):
@ -27,8 +27,8 @@ class UploadAPI(APIView):
def post(self, request, *args, **kwargs):
project_id = self.kwargs['project_id']
upload_ids = request.data['uploadIds']
format = request.data['format']
upload_ids = request.data.pop('uploadIds')
format = request.data.pop('format')
tus = [TemporaryUpload.objects.get(upload_id=upload_id) for upload_id in upload_ids]
sus = [store_upload(tu.upload_id, destination_file_path=tu.upload_name) for tu in tus]
@ -37,6 +37,7 @@ class UploadAPI(APIView):
user_id=request.user.id,
project_id=project_id,
filenames=filenames,
format=format
format=format,
**request.data
)
return Response({'task_id': task.task_id})
Loading…
Cancel
Save