Browse Source

Apply isort

pull/1689/head
Hironsan 2 years ago
parent
commit
3200168d30
64 changed files with 213 additions and 137 deletions
  1. 7
      backend/auto_labeling/pipeline/execution.py
  2. 4
      backend/auto_labeling/pipeline/labels.py
  3. 3
      backend/auto_labeling/tests/test_views.py
  4. 10
      backend/auto_labeling/urls.py
  5. 13
      backend/auto_labeling/views.py
  6. 1
      backend/cli.py
  7. 2
      backend/data_export/celery_tasks.py
  8. 8
      backend/data_export/pipeline/catalog.py
  9. 8
      backend/data_export/pipeline/factories.py
  10. 4
      backend/data_export/pipeline/repositories.py
  11. 2
      backend/data_export/tests/test_repositories.py
  12. 4
      backend/data_export/views.py
  13. 4
      backend/data_import/celery_tasks.py
  14. 8
      backend/data_import/pipeline/catalog.py
  15. 2
      backend/data_import/pipeline/cleaners.py
  16. 2
      backend/data_import/pipeline/data.py
  17. 8
      backend/data_import/pipeline/factories.py
  18. 5
      backend/data_import/pipeline/labels.py
  19. 6
      backend/data_import/pipeline/writers.py
  20. 2
      backend/data_import/tests/test_builder.py
  21. 5
      backend/data_import/tests/test_tasks.py
  22. 2
      backend/data_import/urls.py
  23. 4
      backend/data_import/views.py
  24. 2
      backend/examples/admin.py
  25. 2
      backend/examples/models.py
  26. 2
      backend/examples/serializers.py
  27. 2
      backend/examples/tests/test_comment.py
  28. 4
      backend/examples/tests/test_document.py
  29. 2
      backend/examples/tests/test_example_state.py
  30. 4
      backend/examples/tests/test_filters.py
  31. 4
      backend/examples/tests/test_models.py
  32. 5
      backend/examples/urls.py
  33. 2
      backend/examples/views/comment.py
  34. 2
      backend/examples/views/example.py
  35. 2
      backend/examples/views/example_state.py
  36. 2
      backend/label_types/serializers.py
  37. 2
      backend/label_types/tests/test_views.py
  38. 15
      backend/label_types/urls.py
  39. 11
      backend/label_types/views.py
  40. 2
      backend/labels/managers.py
  41. 6
      backend/labels/models.py
  42. 2
      backend/labels/serializers.py
  43. 6
      backend/labels/tests/test_views.py
  44. 7
      backend/labels/tests/utils.py
  45. 15
      backend/labels/urls.py
  46. 11
      backend/labels/views.py
  47. 7
      backend/metrics/urls.py
  48. 4
      backend/metrics/views.py
  49. 10
      backend/projects/admin.py
  50. 6
      backend/projects/management/commands/create_member.py
  51. 2
      backend/projects/permissions.py
  52. 12
      backend/projects/serializers.py
  53. 4
      backend/projects/tests/test_member.py
  54. 9
      backend/projects/tests/utils.py
  55. 7
      backend/projects/urls.py
  56. 4
      backend/projects/views/member.py
  57. 3
      backend/projects/views/project.py
  58. 3
      backend/projects/views/tag.py
  59. 33
      backend/pyproject.toml
  60. 2
      backend/roles/tests/test_views.py
  61. 1
      backend/users/urls.py
  62. 4
      backend/users/views.py
  63. 6
      poetry.lock
  64. 7
      pyproject.toml

7
backend/auto_labeling/pipeline/execution.py

@ -1,6 +1,11 @@
from typing import Type
from auto_labeling_pipeline.labels import SequenceLabels, Seq2seqLabels, ClassificationLabels, Labels
from auto_labeling_pipeline.labels import (
ClassificationLabels,
Labels,
Seq2seqLabels,
SequenceLabels,
)
from auto_labeling_pipeline.mappings import MappingTemplate
from auto_labeling_pipeline.models import RequestModelFactory
from auto_labeling_pipeline.pipeline import pipeline

4
backend/auto_labeling/pipeline/labels.py

@ -4,10 +4,10 @@ from typing import List, Type
from auto_labeling_pipeline.labels import Labels
from django.contrib.auth.models import User
from projects.models import Project
from examples.models import Example
from label_types.models import CategoryType, LabelType, SpanType
from labels.models import Label, Category, Span, TextLabel
from labels.models import Category, Label, Span, TextLabel
from projects.models import Project
class LabelCollection(abc.ABC):

3
backend/auto_labeling/tests/test_views.py

@ -7,13 +7,12 @@ from model_mommy import mommy
from rest_framework import status
from rest_framework.reverse import reverse
from api.tests.utils import CRUDMixin
from auto_labeling.pipeline.labels import Categories, Spans, Texts
from examples.tests.utils import make_doc
from labels.models import Category, Span, TextLabel
from projects.models import DOCUMENT_CLASSIFICATION, SEQ2SEQ, SEQUENCE_LABELING
from projects.tests.utils import prepare_project
from projects.models import DOCUMENT_CLASSIFICATION, SEQUENCE_LABELING, SEQ2SEQ
data_dir = pathlib.Path(__file__).parent / "data"

10
backend/auto_labeling/urls.py

@ -1,14 +1,14 @@
from django.urls import path
from .views import (
ConfigDetail,
AutomatedLabeling,
LabelMapperTesting,
TemplateListAPI,
TemplateDetailAPI,
ConfigDetail,
ConfigList,
RestAPIRequestTesting,
LabelExtractorTesting,
LabelMapperTesting,
RestAPIRequestTesting,
TemplateDetailAPI,
TemplateListAPI,
)
urlpatterns = [

13
backend/auto_labeling/views.py

@ -15,12 +15,17 @@ from rest_framework.request import Request
from rest_framework.response import Response
from rest_framework.views import APIView
from projects.models import Project
from projects.permissions import IsProjectMember, IsProjectAdmin
from .pipeline.execution import execute_pipeline, get_label_collection
from .exceptions import AWSTokenError, SampleDataException, TemplateMappingError, URLConnectionError
from .exceptions import (
AWSTokenError,
SampleDataException,
TemplateMappingError,
URLConnectionError,
)
from .models import AutoLabelingConfig
from .pipeline.execution import execute_pipeline, get_label_collection
from .serializers import AutoLabelingConfigSerializer
from projects.models import Project
from projects.permissions import IsProjectAdmin, IsProjectMember
class TemplateListAPI(APIView):

1
backend/cli.py

@ -48,6 +48,7 @@ def run_on_nix(args):
def run_on_windows(args):
from waitress import serve
from config.wsgi import application
serve(application, port=args.port)

2
backend/data_export/celery_tasks.py

@ -3,9 +3,9 @@ from celery.utils.log import get_task_logger
from django.conf import settings
from django.shortcuts import get_object_or_404
from projects.models import Project
from .pipeline.factories import create_repository, create_writer
from .pipeline.services import ExportApplicationService
from projects.models import Project
logger = get_task_logger(__name__)

8
backend/data_export/pipeline/catalog.py

@ -4,15 +4,15 @@ from typing import Dict, List, Type
from pydantic import BaseModel
from typing_extensions import Literal
from . import examples
from projects.models import (
DOCUMENT_CLASSIFICATION,
SEQUENCE_LABELING,
SEQ2SEQ,
SPEECH2TEXT,
IMAGE_CLASSIFICATION,
INTENT_DETECTION_AND_SLOT_FILLING,
SEQ2SEQ,
SEQUENCE_LABELING,
SPEECH2TEXT,
)
from . import examples
class Format:

8
backend/data_export/pipeline/factories.py

@ -1,14 +1,14 @@
from typing import Type
from . import catalog, repositories, writers
from projects.models import (
DOCUMENT_CLASSIFICATION,
SEQUENCE_LABELING,
SEQ2SEQ,
SPEECH2TEXT,
IMAGE_CLASSIFICATION,
INTENT_DETECTION_AND_SLOT_FILLING,
SEQ2SEQ,
SEQUENCE_LABELING,
SPEECH2TEXT,
)
from . import catalog, repositories, writers
def create_repository(project):

4
backend/data_export/pipeline/repositories.py

@ -3,9 +3,9 @@ import itertools
from collections import defaultdict
from typing import Dict, Iterator, List, Tuple, Union
from projects.models import Project
from examples.models import Example
from .data import Record
from examples.models import Example
from projects.models import Project
SpanType = Tuple[int, int, str]

2
backend/data_export/tests/test_repositories.py

@ -2,9 +2,9 @@ import unittest
from model_mommy import mommy
from ..pipeline.repositories import IntentDetectionSlotFillingRepository
from projects.models import INTENT_DETECTION_AND_SLOT_FILLING
from projects.tests.utils import prepare_project
from ..pipeline.repositories import IntentDetectionSlotFillingRepository
class TestCSVWriter(unittest.TestCase):

4
backend/data_export/views.py

@ -6,10 +6,10 @@ from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView
from projects.models import Project
from projects.permissions import IsProjectAdmin
from .celery_tasks import export_dataset
from .pipeline.catalog import Options
from projects.models import Project
from projects.permissions import IsProjectAdmin
class DatasetCatalog(APIView):

4
backend/data_import/celery_tasks.py

@ -3,10 +3,10 @@ from django.conf import settings
from django.contrib.auth import get_user_model
from django.shortcuts import get_object_or_404
from projects.models import Project
from .pipeline.factories import create_parser, create_builder, create_cleaner
from .pipeline.factories import create_builder, create_cleaner, create_parser
from .pipeline.readers import Reader
from .pipeline.writers import BulkWriter
from projects.models import Project
@shared_task

8
backend/data_import/pipeline/catalog.py

@ -4,15 +4,15 @@ from typing import Dict, List, Type
from pydantic import BaseModel
from typing_extensions import Literal
from . import examples
from projects.models import (
DOCUMENT_CLASSIFICATION,
SEQUENCE_LABELING,
SEQ2SEQ,
SPEECH2TEXT,
IMAGE_CLASSIFICATION,
INTENT_DETECTION_AND_SLOT_FILLING,
SEQ2SEQ,
SEQUENCE_LABELING,
SPEECH2TEXT,
)
from . import examples
encodings = Literal[
"Auto",

2
backend/data_import/pipeline/cleaners.py

@ -1,7 +1,7 @@
from typing import List
from projects.models import Project
from .labels import Label, SpanLabel
from projects.models import Project
class Cleaner:

2
backend/data_import/pipeline/data.py

@ -4,8 +4,8 @@ from typing import Any, Dict
from pydantic import BaseModel, validator
from projects.models import Project
from examples.models import Example
from projects.models import Project
class BaseData(BaseModel, abc.ABC):

8
backend/data_import/pipeline/factories.py

@ -1,12 +1,12 @@
from . import builders, catalog, cleaners, data, labels, parsers, readers
from projects.models import (
DOCUMENT_CLASSIFICATION,
SEQUENCE_LABELING,
SEQ2SEQ,
SPEECH2TEXT,
IMAGE_CLASSIFICATION,
INTENT_DETECTION_AND_SLOT_FILLING,
SEQ2SEQ,
SEQUENCE_LABELING,
SPEECH2TEXT,
)
from . import builders, catalog, cleaners, data, labels, parsers, readers
def get_data_class(project_type: str):

5
backend/data_import/pipeline/labels.py

@ -3,9 +3,10 @@ from typing import Any, Dict, Optional
from pydantic import BaseModel, validator
from label_types.models import CategoryType, LabelType, SpanType
from labels.models import Category, Span
from labels.models import TextLabel as TL
from projects.models import Project
from label_types.models import LabelType, CategoryType, SpanType
from labels.models import Category, Span, TextLabel as TL
class Label(BaseModel, abc.ABC):

6
backend/data_import/pipeline/writers.py

@ -5,11 +5,11 @@ from typing import Any, Dict, List, Type
from django.conf import settings
from projects.models import Project
from examples.models import Example
from label_types.models import CategoryType, LabelType, SpanType
from .exceptions import FileParseException
from .readers import BaseReader, Record
from examples.models import Example
from label_types.models import CategoryType, LabelType, SpanType
from projects.models import Project
class Writer(abc.ABC):

2
backend/data_import/tests/test_builder.py

@ -1,5 +1,5 @@
import unittest
from typing import Optional, List
from typing import List, Optional
from data_import.pipeline import builders
from data_import.pipeline.data import TextData

5
backend/data_import/tests/test_tasks.py

@ -3,16 +3,15 @@ import pathlib
from django.test import TestCase
from data_import.celery_tasks import import_dataset
from examples.models import Example
from label_types.models import CategoryType, SpanType
from labels.models import Category, Span
from projects.models import (
DOCUMENT_CLASSIFICATION,
SEQUENCE_LABELING,
SEQ2SEQ,
IMAGE_CLASSIFICATION,
INTENT_DETECTION_AND_SLOT_FILLING,
SEQ2SEQ,
SEQUENCE_LABELING,
)
from projects.tests.utils import prepare_project

2
backend/data_import/urls.py

@ -1,6 +1,6 @@
from django.urls import include, path
from .views import DatasetImportAPI, DatasetCatalog
from .views import DatasetCatalog, DatasetImportAPI
urlpatterns = [
path("fp/", include("django_drf_filepond.urls")),

4
backend/data_import/views.py

@ -8,10 +8,10 @@ from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView
from projects.models import Project
from projects.permissions import IsProjectAdmin
from .celery_tasks import import_dataset
from .pipeline.catalog import Options
from projects.models import Project
from projects.permissions import IsProjectAdmin
class DatasetCatalog(APIView):

2
backend/examples/admin.py

@ -1,6 +1,6 @@
from django.contrib import admin
from .models import Example, Comment
from .models import Comment, Example
class ExampleAdmin(admin.ModelAdmin):

2
backend/examples/models.py

@ -3,8 +3,8 @@ import uuid
from django.contrib.auth.models import User
from django.db import models
from projects.models import Project
from .managers import ExampleManager, ExampleStateManager
from projects.models import Project
class Example(models.Model):

2
backend/examples/serializers.py

@ -1,6 +1,6 @@
from rest_framework import serializers
from .models import Example, ExampleState, Comment
from .models import Comment, Example, ExampleState
class CommentSerializer(serializers.ModelSerializer):

2
backend/examples/tests/test_comment.py

@ -1,10 +1,10 @@
from rest_framework import status
from rest_framework.reverse import reverse
from .utils import make_comment, make_doc
from api.tests.utils import CRUDMixin
from projects.tests.utils import prepare_project
from users.tests.utils import make_user
from .utils import make_comment, make_doc
class TestCommentListDocAPI(CRUDMixin):

4
backend/examples/tests/test_document.py

@ -3,11 +3,11 @@ from django.utils.http import urlencode
from rest_framework import status
from rest_framework.reverse import reverse
from .utils import make_doc, make_example_state
from api.tests.utils import CRUDMixin
from users.tests.utils import make_user
from projects.models import DOCUMENT_CLASSIFICATION
from projects.tests.utils import assign_user_to_role, prepare_project
from .utils import make_doc, make_example_state
from users.tests.utils import make_user
class TestExampleListAPI(CRUDMixin):

2
backend/examples/tests/test_example_state.py

@ -1,10 +1,10 @@
from rest_framework import status
from rest_framework.reverse import reverse
from .utils import make_doc, make_example_state
from api.tests.utils import CRUDMixin
from projects.tests.utils import prepare_project
from users.tests.utils import make_user
from .utils import make_doc, make_example_state
class TestExampleStateList(CRUDMixin):

4
backend/examples/tests/test_filters.py

@ -2,10 +2,10 @@ from unittest.mock import MagicMock
from django.test import TestCase
from examples.models import Example
from .utils import make_doc, make_example_state
from examples.filters import ExampleFilter
from examples.models import Example
from projects.tests.utils import prepare_project
from .utils import make_doc, make_example_state
class TestFilterMixin(TestCase):

4
backend/examples/tests/test_models.py

@ -1,9 +1,9 @@
from django.test import TestCase
from model_mommy import mommy
from projects.models import SEQUENCE_LABELING, IMAGE_CLASSIFICATION
from projects.tests.utils import prepare_project
from examples.models import ExampleState
from projects.models import IMAGE_CLASSIFICATION, SEQUENCE_LABELING
from projects.tests.utils import prepare_project
class TestExampleState(TestCase):

5
backend/examples/urls.py

@ -1,10 +1,9 @@
from django.urls import path
from .views.example import ExampleList, ExampleDetail
from .views.comment import CommentList, CommentDetail
from .views.comment import CommentDetail, CommentList
from .views.example import ExampleDetail, ExampleList
from .views.example_state import ExampleStateList
urlpatterns = [
path(route="examples", view=ExampleList.as_view(), name="example_list"),
path(route="examples/<int:example_id>", view=ExampleDetail.as_view(), name="example_detail"),

2
backend/examples/views/comment.py

@ -3,10 +3,10 @@ from rest_framework import filters, generics, status
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from projects.permissions import IsProjectMember
from examples.models import Comment
from examples.permissions import IsOwnComment
from examples.serializers import CommentSerializer
from projects.permissions import IsProjectMember
class CommentList(generics.ListCreateAPIView):

2
backend/examples/views/example.py

@ -7,10 +7,10 @@ from rest_framework import filters, generics, status
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from projects.models import Project
from examples.filters import ExampleFilter
from examples.models import Example
from examples.serializers import ExampleSerializer
from projects.models import Project
from projects.permissions import IsProjectAdmin, IsProjectStaffAndReadOnly

2
backend/examples/views/example_state.py

@ -2,9 +2,9 @@ from django.shortcuts import get_object_or_404
from rest_framework import generics
from rest_framework.permissions import IsAuthenticated
from projects.models import Project
from examples.models import Example, ExampleState
from examples.serializers import ExampleStateSerializer
from projects.models import Project
from projects.permissions import IsProjectMember

2
backend/label_types/serializers.py

@ -1,7 +1,7 @@
from rest_framework import serializers
from rest_framework.exceptions import ValidationError
from .models import LabelType, CategoryType, SpanType, RelationType
from .models import CategoryType, LabelType, RelationType, SpanType
class LabelSerializer(serializers.ModelSerializer):

2
backend/label_types/tests/test_views.py

@ -5,11 +5,11 @@ from rest_framework import status
from rest_framework.reverse import reverse
from rest_framework.test import APITestCase
from .utils import make_label
from api.tests.utils import CRUDMixin
from projects.models import DOCUMENT_CLASSIFICATION
from projects.tests.utils import make_project, prepare_project
from users.tests.utils import make_user
from .utils import make_label
DATA_DIR = os.path.join(os.path.dirname(__file__), "data")

15
backend/label_types/urls.py

@ -1,9 +1,16 @@
from django.urls import path
from .views import CategoryTypeList, CategoryTypeDetail, CategoryTypeUploadAPI
from .views import SpanTypeList, SpanTypeDetail, SpanTypeUploadAPI
from .views import RelationTypeList, RelationTypeDetail, RelationTypeUploadAPI
from .views import (
CategoryTypeDetail,
CategoryTypeList,
CategoryTypeUploadAPI,
RelationTypeDetail,
RelationTypeList,
RelationTypeUploadAPI,
SpanTypeDetail,
SpanTypeList,
SpanTypeUploadAPI,
)
urlpatterns = [
path(route="category-types", view=CategoryTypeList.as_view(), name="category_types"),

11
backend/label_types/views.py

@ -10,10 +10,15 @@ from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView
from projects.permissions import IsProjectAdmin, IsProjectStaffAndReadOnly
from .models import LabelType, CategoryType, SpanType, RelationType
from .exceptions import LabelValidationError
from .serializers import CategoryTypeSerializer, LabelSerializer, RelationTypesSerializer, SpanTypeSerializer
from .models import CategoryType, LabelType, RelationType, SpanType
from .serializers import (
CategoryTypeSerializer,
LabelSerializer,
RelationTypesSerializer,
SpanTypeSerializer,
)
from projects.permissions import IsProjectAdmin, IsProjectStaffAndReadOnly
def camel_to_snake(name):

2
backend/labels/managers.py

@ -1,4 +1,4 @@
from django.db.models import Manager, Count
from django.db.models import Count, Manager
class LabelManager(Manager):

6
backend/labels/models.py

@ -2,10 +2,10 @@ from django.contrib.auth.models import User
from django.core.exceptions import ValidationError
from django.db import models
from .managers import LabelManager, CategoryManager, SpanManager, TextLabelManager
from projects.models import Project
from .managers import CategoryManager, LabelManager, SpanManager, TextLabelManager
from examples.models import Example
from label_types.models import CategoryType, SpanType, RelationType
from label_types.models import CategoryType, RelationType, SpanType
from projects.models import Project
class Label(models.Model):

2
backend/labels/serializers.py

@ -1,8 +1,8 @@
from rest_framework import serializers
from .models import Category, Relation, Span, TextLabel
from examples.models import Example
from label_types.models import CategoryType, SpanType
from .models import Category, Span, TextLabel, Relation
class CategorySerializer(serializers.ModelSerializer):

6
backend/labels/tests/test_views.py

@ -1,14 +1,14 @@
from rest_framework import status
from rest_framework.reverse import reverse
from .utils import make_annotation
from api.tests.utils import CRUDMixin
from examples.tests.utils import make_doc
from labels.models import Category, Span, TextLabel
from label_types.tests.utils import make_label
from projects.models import DOCUMENT_CLASSIFICATION, SEQUENCE_LABELING, SEQ2SEQ
from labels.models import Category, Span, TextLabel
from projects.models import DOCUMENT_CLASSIFICATION, SEQ2SEQ, SEQUENCE_LABELING
from projects.tests.utils import prepare_project
from users.tests.utils import make_user
from .utils import make_annotation
class TestLabelList:

7
backend/labels/tests/utils.py

@ -1,6 +1,11 @@
from model_mommy import mommy
from projects.models import DOCUMENT_CLASSIFICATION, SEQUENCE_LABELING, SEQ2SEQ, SPEECH2TEXT
from projects.models import (
DOCUMENT_CLASSIFICATION,
SEQ2SEQ,
SEQUENCE_LABELING,
SPEECH2TEXT,
)
def make_annotation(task, doc, user, **kwargs):

15
backend/labels/urls.py

@ -1,10 +1,15 @@
from django.urls import path
from .views import CategoryListAPI, CategoryDetailAPI
from .views import SpanListAPI, SpanDetailAPI
from .views import TextLabelListAPI, TextLabelDetailAPI
from .views import RelationList, RelationDetail
from .views import (
CategoryDetailAPI,
CategoryListAPI,
RelationDetail,
RelationList,
SpanDetailAPI,
SpanListAPI,
TextLabelDetailAPI,
TextLabelListAPI,
)
urlpatterns = [
path(route="annotation_relations", view=RelationList.as_view(), name="relation_list"),

11
backend/labels/views.py

@ -7,11 +7,16 @@ from rest_framework import generics, status
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from .permissions import CanEditLabel
from .serializers import (
CategorySerializer,
RelationSerializer,
SpanSerializer,
TextLabelSerializer,
)
from labels.models import Category, Label, Relation, Span, TextLabel
from projects.models import Project
from labels.models import Category, Label, Span, TextLabel, Relation
from projects.permissions import IsProjectMember
from .permissions import CanEditLabel
from .serializers import CategorySerializer, SpanSerializer, TextLabelSerializer, RelationSerializer
class BaseListAPI(generics.ListCreateAPIView):

7
backend/metrics/urls.py

@ -1,6 +1,11 @@
from django.urls import path
from .views import ProgressAPI, MemberProgressAPI, CategoryTypeDistribution, SpanTypeDistribution
from .views import (
CategoryTypeDistribution,
MemberProgressAPI,
ProgressAPI,
SpanTypeDistribution,
)
urlpatterns = [
path(route="progress", view=ProgressAPI.as_view(), name="progress"),

4
backend/metrics/views.py

@ -6,8 +6,8 @@ from rest_framework.response import Response
from rest_framework.views import APIView
from examples.models import Example, ExampleState
from label_types.models import LabelType, CategoryType, SpanType
from labels.models import Label, Category, Span
from label_types.models import CategoryType, LabelType, SpanType
from labels.models import Category, Label, Span
from projects.models import Member
from projects.permissions import IsProjectAdmin, IsProjectStaffAndReadOnly

10
backend/projects/admin.py

@ -1,7 +1,13 @@
from django.contrib import admin
from .models import Member
from .models import Project, TextClassificationProject, SequenceLabelingProject, Seq2seqProject, Tag
from .models import (
Member,
Project,
Seq2seqProject,
SequenceLabelingProject,
Tag,
TextClassificationProject,
)
class MemberAdmin(admin.ModelAdmin):

6
backend/projects/management/commands/create_member.py

@ -1,9 +1,9 @@
from django.core.management.base import BaseCommand, CommandError
from django.contrib.auth.models import User
from django.core.management.base import BaseCommand, CommandError
from models import Project
from roles.models import Role
from ...models import Member
from roles.models import Role
class Command(BaseCommand):

2
backend/projects/permissions.py

@ -1,5 +1,5 @@
from django.conf import settings
from rest_framework.permissions import BasePermission, SAFE_METHODS
from rest_framework.permissions import SAFE_METHODS, BasePermission
from .models import Member

12
backend/projects/serializers.py

@ -2,16 +2,16 @@ from rest_framework import serializers
from rest_polymorphic.serializers import PolymorphicSerializer
from .models import (
Tag,
ImageClassificationProject,
IntentDetectionAndSlotFillingProject,
Member,
Project,
TextClassificationProject,
SequenceLabelingProject,
Seq2seqProject,
IntentDetectionAndSlotFillingProject,
SequenceLabelingProject,
Speech2textProject,
ImageClassificationProject,
Tag,
TextClassificationProject,
)
from .models import Member
class MemberSerializer(serializers.ModelSerializer):

4
backend/projects/tests/test_member.py

@ -1,9 +1,9 @@
from django.conf import settings
from django.test import TestCase
from django.core.exceptions import ValidationError
from django.test import TestCase
from model_mommy import mommy
from rest_framework import status
from rest_framework.reverse import reverse
from model_mommy import mommy
from api.tests.utils import CRUDMixin
from projects.models import Member

9
backend/projects/tests/utils.py

@ -3,14 +3,15 @@ from typing import List
from django.conf import settings
from model_mommy import mommy
from projects.models import Role, Member
from projects.models import (
DOCUMENT_CLASSIFICATION,
SEQUENCE_LABELING,
SEQ2SEQ,
SPEECH2TEXT,
IMAGE_CLASSIFICATION,
INTENT_DETECTION_AND_SLOT_FILLING,
SEQ2SEQ,
SEQUENCE_LABELING,
SPEECH2TEXT,
Member,
Role,
)
from roles.tests.utils import create_default_roles
from users.tests.utils import make_user

7
backend/projects/urls.py

@ -1,9 +1,8 @@
from django.urls import path
from .views.member import MemberList, MemberDetail
from .views.tag import TagList, TagDetail
from .views.project import ProjectList, ProjectDetail
from .views.member import MemberDetail, MemberList
from .views.project import ProjectDetail, ProjectList
from .views.tag import TagDetail, TagList
urlpatterns = [
path(route="projects", view=ProjectList.as_view(), name="project_list"),

4
backend/projects/views/member.py

@ -4,10 +4,10 @@ from rest_framework import generics, status
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from projects.permissions import IsProjectAdmin
from projects.serializers import MemberSerializer
from projects.exceptions import RoleAlreadyAssignedException, RoleConstraintException
from projects.models import Member
from projects.permissions import IsProjectAdmin
from projects.serializers import MemberSerializer
class MemberList(generics.ListCreateAPIView):

3
backend/projects/views/project.py

@ -4,9 +4,8 @@ from rest_framework import filters, generics, status
from rest_framework.permissions import IsAdminUser, IsAuthenticated
from rest_framework.response import Response
from projects.permissions import IsProjectAdmin, IsProjectStaffAndReadOnly
from projects.models import Project
from projects.permissions import IsProjectAdmin, IsProjectStaffAndReadOnly
from projects.serializers import ProjectPolymorphicSerializer

3
backend/projects/views/tag.py

@ -1,9 +1,8 @@
from rest_framework import generics
from rest_framework.permissions import IsAuthenticated
from projects.permissions import IsProjectAdmin, IsProjectStaffAndReadOnly
from projects.models import Tag
from projects.permissions import IsProjectAdmin, IsProjectStaffAndReadOnly
from projects.serializers import TagSerializer

33
backend/pyproject.toml

@ -0,0 +1,33 @@
[tool.isort]
profile = "black"
include_trailing_comma = true
multi_line_output = 3
#src_paths = ["backend/*"]
known_first_party = [
"api",
"auto_labeling",
"config",
"data_export",
"data_import",
"examples",
"label_types",
"labels",
"metrics",
"projects",
"roles",
"users"
]
known_local_folder = [
"api",
"auto_labeling",
"config",
"data_export",
"data_import",
"examples",
"label_types",
"labels",
"metrics",
"projects",
"roles",
"users"
]

2
backend/roles/tests/test_views.py

@ -1,9 +1,9 @@
from rest_framework import status
from rest_framework.reverse import reverse
from .utils import create_default_roles
from api.tests.utils import CRUDMixin
from users.tests.utils import make_user
from .utils import create_default_roles
class TestRoleAPI(CRUDMixin):

1
backend/users/urls.py

@ -2,7 +2,6 @@ from django.urls import include, path
from .views import Me, Users
urlpatterns = [
path(route="me", view=Me.as_view(), name="me"),
path(route="users", view=Users.as_view(), name="user_list"),

4
backend/users/views.py

@ -1,12 +1,12 @@
from django.contrib.auth.models import User
from django_filters.rest_framework import DjangoFilterBackend
from rest_framework import generics, filters
from rest_framework import filters, generics
from rest_framework.permissions import IsAuthenticated
from rest_framework.response import Response
from rest_framework.views import APIView
from projects.permissions import IsProjectAdmin
from .serializers import UserSerializer
from projects.permissions import IsProjectAdmin
class Me(APIView):

6
poetry.lock

@ -1307,10 +1307,14 @@ python-versions = ">=3.7"
[package.extras]
brotli = ["brotli"]
[extras]
mssql = []
postgresql = []
[metadata]
lock-version = "1.1"
python-versions = "^3.8"
content-hash = "2266cf8a3e7663746a57da39b8b1d9904080018df8af20e38abac13b06135152"
content-hash = "ba374bd631f54e82e0eaaa41cd38d6b6e71f69d3e5202a5c46575667b12f2b10"
[metadata.files]
amqp = [

7
pyproject.toml

@ -66,7 +66,7 @@ djangorestframework-xml = "^2.0.0"
model-mommy = "^2.0.0"
coverage = "^6.3.1"
flake8 = "^4.0.1"
isort = "^5.10.1"
isort = {extras = ["pyproject"], version = "^5.10.1"}
autopep8 = "^1.6.0"
mypy = "^0.931"
watchdog = "^2.1.6"
@ -90,11 +90,6 @@ line-length = 120
target-version = ['py37', 'py38']
include = '\.pyi?$'
[tool.isort]
profile = "black"
include_trailing_comma = true
multi_line_output = 3
[tool.flake8]
max-line-length = 120
max-complexity = 18

Loading…
Cancel
Save