Skip to content

Commit 3e139a9

Browse files
authored
Merge pull request #501 from superannotateai/develop
Develop
2 parents d429d4f + 973a4bc commit 3e139a9

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+1174
-2995
lines changed

requirements_dev.txt

Lines changed: 0 additions & 2 deletions
This file was deleted.

requirements_prod.txt

Lines changed: 0 additions & 1 deletion
This file was deleted.

setup.py

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -12,24 +12,16 @@ def get_version():
1212

1313
sdk_version = get_version()
1414

15-
16-
requirements_path = "requirements_{}.txt".format('dev' if 'dev' in sdk_version else 'prod')
17-
1815
requirements = []
1916

2017
with open("requirements.txt") as f:
2118
requirements.extend(f.read().splitlines())
2219

23-
with open(requirements_path) as f:
24-
requirements.extend(f.read().splitlines())
25-
26-
2720
with open('README.md') as f:
2821
readme = f.read()
2922

3023
readme = "\n".join(readme.split('\n')[2:])
3124

32-
3325
setup(
3426
name='superannotate',
3527
version=sdk_version,

src/superannotate/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import os
22
import sys
33

4-
__version__ = "4.4.3"
4+
__version__ = "4.4.4b1"
55

66
sys.path.append(os.path.split(os.path.realpath(__file__))[0])
77

src/superannotate/lib/app/interface/cli_interface.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,9 +195,7 @@ def _upload_annotations(
195195
output_dir=temp_dir,
196196
dataset_format=format,
197197
dataset_name=dataset_name,
198-
project_type=constances.ProjectType.get_name(
199-
project["project"].type
200-
),
198+
project_type=project.type.name,
201199
task=task,
202200
)
203201
annotations_path = temp_dir

src/superannotate/lib/app/interface/sdk_interface.py

Lines changed: 38 additions & 48 deletions
Original file line numberDiff line numberDiff line change
@@ -162,13 +162,7 @@ def search_projects(
162162
if return_metadata:
163163
return [
164164
ProjectSerializer(project).serialize(
165-
exclude={
166-
"annotation_classes",
167-
"workflows",
168-
"settings",
169-
"contributors",
170-
"classes",
171-
}
165+
exclude={"settings", "workflows", "contributors", "classes"}
172166
)
173167
for project in result
174168
]
@@ -434,16 +428,14 @@ def copy_image(
434428
destination_project
435429
).data
436430

437-
if destination_project_metadata["project"].type in [
431+
if destination_project_metadata.type.value in [
438432
constants.ProjectType.VIDEO.value,
439433
constants.ProjectType.DOCUMENT.value,
440-
] or source_project_metadata["project"].type in [
434+
] or source_project_metadata.type.value in [
441435
constants.ProjectType.VIDEO.value,
442436
constants.ProjectType.DOCUMENT.value,
443437
]:
444-
raise AppException(
445-
LIMITED_FUNCTIONS[source_project_metadata["project"].type]
446-
)
438+
raise AppException(LIMITED_FUNCTIONS[source_project_metadata.type])
447439

448440
response = self.controller.copy_image(
449441
from_project_name=source_project_name,
@@ -517,17 +509,11 @@ def get_project_metadata(
517509
include_workflow,
518510
include_contributors,
519511
include_complete_image_count,
520-
).data
521-
522-
metadata = ProjectSerializer(response["project"]).serialize()
512+
)
513+
if response.errors:
514+
raise AppException(response.errors)
523515

524-
for elem in "classes", "workflows", "contributors":
525-
if response.get(elem):
526-
metadata[elem] = [
527-
BaseSerializer(attribute).serialize()
528-
for attribute in response[elem]
529-
]
530-
return metadata
516+
return ProjectSerializer(response.data).serialize()
531517

532518
def get_project_settings(self, project: Union[NotEmptyStr, dict]):
533519
"""Gets project's settings.
@@ -543,7 +529,8 @@ def get_project_settings(self, project: Union[NotEmptyStr, dict]):
543529
project_name, folder_name = extract_project_folder(project)
544530
settings = self.controller.get_project_settings(project_name=project_name)
545531
settings = [
546-
SettingsSerializer(attribute).serialize() for attribute in settings.data
532+
SettingsSerializer(attribute.dict()).serialize()
533+
for attribute in settings.data
547534
]
548535
return settings
549536

@@ -584,7 +571,10 @@ def search_annotation_classes(
584571
)
585572
if response.errors:
586573
raise AppException(response.errors)
587-
return [BaseSerializer(i).serialize(exclude_unset=True) for i in response.data]
574+
return [
575+
i.dict(exclude={"attribute_groups": {"__all__": {"is_multiselect"}}})
576+
for i in response.data
577+
]
588578

589579
def set_project_default_image_quality_in_editor(
590580
self,
@@ -1516,11 +1506,11 @@ def upload_preannotations_from_folder_to_project(
15161506
project_name, folder_name = extract_project_folder(project)
15171507
project_folder_name = project_name + (f"/{folder_name}" if folder_name else "")
15181508
project = self.controller.get_project_metadata(project_name).data
1519-
if project["project"].type in [
1520-
constants.ProjectType.VIDEO.value,
1521-
constants.ProjectType.DOCUMENT.value,
1509+
if project.type in [
1510+
constants.ProjectType.VIDEO,
1511+
constants.ProjectType.DOCUMENT,
15221512
]:
1523-
raise AppException(LIMITED_FUNCTIONS[project["project"].type])
1513+
raise AppException(LIMITED_FUNCTIONS[project.type])
15241514
if recursive_subfolders:
15251515
logger.info(
15261516
"When using recursive subfolder parsing same name annotations in different "
@@ -1579,11 +1569,11 @@ def upload_image_annotations(
15791569
project_name, folder_name = extract_project_folder(project)
15801570

15811571
project = self.controller.get_project_metadata(project_name).data
1582-
if project["project"].type in [
1583-
constants.ProjectType.VIDEO.value,
1584-
constants.ProjectType.DOCUMENT.value,
1572+
if project.type in [
1573+
constants.ProjectType.VIDEO,
1574+
constants.ProjectType.DOCUMENT,
15851575
]:
1586-
raise AppException(LIMITED_FUNCTIONS[project["project"].type])
1576+
raise AppException(LIMITED_FUNCTIONS[project.type])
15871577

15881578
if not mask:
15891579
if not isinstance(annotation_json, dict):
@@ -1665,11 +1655,11 @@ def benchmark(
16651655
project_name = project["name"]
16661656

16671657
project = self.controller.get_project_metadata(project_name).data
1668-
if project["project"].type in [
1669-
constants.ProjectType.VIDEO.value,
1670-
constants.ProjectType.DOCUMENT.value,
1658+
if project.type in [
1659+
constants.ProjectType.VIDEO,
1660+
constants.ProjectType.DOCUMENT,
16711661
]:
1672-
raise AppException(LIMITED_FUNCTIONS[project["project"].type])
1662+
raise AppException(LIMITED_FUNCTIONS[project.type])
16731663

16741664
if not export_root:
16751665
with tempfile.TemporaryDirectory() as temp_dir:
@@ -1817,11 +1807,11 @@ def add_annotation_bbox_to_image(
18171807
"""
18181808
project_name, folder_name = extract_project_folder(project)
18191809
project = self.controller.get_project_metadata(project_name).data
1820-
if project["project"].type in [
1821-
constants.ProjectType.VIDEO.value,
1822-
constants.ProjectType.DOCUMENT.value,
1810+
if project.type in [
1811+
constants.ProjectType.VIDEO,
1812+
constants.ProjectType.DOCUMENT,
18231813
]:
1824-
raise AppException(LIMITED_FUNCTIONS[project["project"].type])
1814+
raise AppException(LIMITED_FUNCTIONS[project.type])
18251815
response = self.controller.get_annotations(
18261816
project_name=project_name,
18271817
folder_name=folder_name,
@@ -1875,11 +1865,11 @@ def add_annotation_point_to_image(
18751865
"""
18761866
project_name, folder_name = extract_project_folder(project)
18771867
project = self.controller.get_project_metadata(project_name).data
1878-
if project["project"].type in [
1879-
constants.ProjectType.VIDEO.value,
1880-
constants.ProjectType.DOCUMENT.value,
1868+
if project.type in [
1869+
constants.ProjectType.VIDEO,
1870+
constants.ProjectType.DOCUMENT,
18811871
]:
1882-
raise AppException(LIMITED_FUNCTIONS[project["project"].type])
1872+
raise AppException(LIMITED_FUNCTIONS[project.type])
18831873
response = self.controller.get_annotations(
18841874
project_name=project_name,
18851875
folder_name=folder_name,
@@ -1931,11 +1921,11 @@ def add_annotation_comment_to_image(
19311921
"""
19321922
project_name, folder_name = extract_project_folder(project)
19331923
project = self.controller.get_project_metadata(project_name).data
1934-
if project["project"].type in [
1935-
constants.ProjectType.VIDEO.value,
1936-
constants.ProjectType.DOCUMENT.value,
1924+
if project.type in [
1925+
constants.ProjectType.VIDEO,
1926+
constants.ProjectType.DOCUMENT,
19371927
]:
1938-
raise AppException(LIMITED_FUNCTIONS[project["project"].type])
1928+
raise AppException(LIMITED_FUNCTIONS[project.type])
19391929
response = self.controller.get_annotations(
19401930
project_name=project_name,
19411931
folder_name=folder_name,

src/superannotate/lib/app/interface/types.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@
55
from typing import Union
66

77
from lib.core.enums import AnnotationStatus
8+
from lib.core.enums import BaseTitledEnum
89
from lib.core.enums import ClassTypeEnum
910
from lib.core.enums import ProjectStatus
1011
from lib.core.enums import ProjectType
@@ -32,7 +33,11 @@ class EnumMemberError(PydanticTypeError):
3233
code = "enum"
3334

3435
def __str__(self) -> str:
35-
permitted = ", ".join(str(v.name) for v in self.enum_values) # type: ignore
36+
enum_values = list(self.enum_values) # noqa
37+
if isinstance(enum_values[0], BaseTitledEnum):
38+
permitted = ", ".join(str(v.name) for v in enum_values) # type: ignore
39+
else:
40+
permitted = ", ".join(f"'{str(v.value)}'" for v in enum_values) # type: ignore
3641
return f"Available values are: {permitted}"
3742

3843

src/superannotate/lib/app/serializers.py

Lines changed: 21 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -113,28 +113,33 @@ def serialize(self):
113113

114114

115115
class ProjectSerializer(BaseSerializer):
116-
DEFAULT_EXCLUDE_SET = {"sync_status", "unverified_users"}
117-
118116
def serialize(
119117
self,
120118
fields: List[str] = None,
121119
by_alias: bool = False,
122120
flat: bool = False,
123121
exclude: Set[str] = None,
124122
):
125-
to_exclude = self.DEFAULT_EXCLUDE_SET
123+
124+
to_exclude = {
125+
"sync_status": True,
126+
"unverified_users": True,
127+
"classes": {
128+
"__all__": {"attribute_groups": {"__all__": {"is_multiselect"}}}
129+
},
130+
}
126131
if exclude:
127-
to_exclude = exclude.union(self.DEFAULT_EXCLUDE_SET)
132+
for field in exclude:
133+
to_exclude[field] = True
134+
128135
data = super().serialize(fields, by_alias, flat, to_exclude)
129136
if data.get("settings"):
130137
data["settings"] = [
131138
SettingsSerializer(setting).serialize() for setting in data["settings"]
132139
]
133-
data["type"] = constance.ProjectType.get_name(data["type"])
134-
if data.get("status"):
135-
data["status"] = constance.ProjectStatus.get_name(data["status"])
136-
else:
140+
if not data.get("status"):
137141
data["status"] = "Undefined"
142+
138143
if data.get("upload_state"):
139144
data["upload_state"] = constance.UploadState(data["upload_state"]).name
140145
if data.get("users"):
@@ -152,18 +157,14 @@ def serialize(self):
152157
return data
153158

154159

155-
class SettingsSerializer(BaseSerializer):
156-
def serialize(
157-
self,
158-
fields: List[str] = None,
159-
by_alias: bool = True,
160-
flat: bool = False,
161-
exclude=None,
162-
):
163-
data = super().serialize(fields, by_alias, flat, exclude)
164-
if data["attribute"] == "ImageQuality":
165-
data["value"] = constance.ImageQuality.get_name(data["value"])
166-
return data
160+
class SettingsSerializer:
161+
def __init__(self, data: dict):
162+
self.data = data
163+
164+
def serialize(self):
165+
if self.data["attribute"] == "ImageQuality":
166+
self.data["value"] = constance.ImageQuality.get_name(self.data["value"])
167+
return self.data
167168

168169

169170
class EntitySerializer:

src/superannotate/lib/core/__init__.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -79,8 +79,8 @@
7979
)
8080

8181
LIMITED_FUNCTIONS = {
82-
ProjectType.VIDEO.value: DEPRECATED_VIDEO_PROJECTS_MESSAGE,
83-
ProjectType.DOCUMENT.value: DEPRECATED_DOCUMENT_PROJECTS_MESSAGE,
82+
ProjectType.VIDEO: DEPRECATED_VIDEO_PROJECTS_MESSAGE,
83+
ProjectType.DOCUMENT: DEPRECATED_DOCUMENT_PROJECTS_MESSAGE,
8484
}
8585

8686
METADATA_DEPRICATED_FOR_PIXEL = (

src/superannotate/lib/core/entities/__init__.py

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
1-
from lib.core.entities.base import AttachmentEntity
21
from lib.core.entities.base import BaseItemEntity
3-
from lib.core.entities.base import ProjectEntity
4-
from lib.core.entities.base import SettingEntity
52
from lib.core.entities.base import SubSetEntity
63
from lib.core.entities.classes import AnnotationClassEntity
74
from lib.core.entities.integrations import IntegrationEntity
85
from lib.core.entities.items import DocumentEntity
96
from lib.core.entities.items import TmpImageEntity
107
from lib.core.entities.items import VideoEntity
8+
from lib.core.entities.project import AttachmentEntity
9+
from lib.core.entities.project import ProjectEntity
10+
from lib.core.entities.project import SettingEntity
1111
from lib.core.entities.project_entities import BaseEntity
1212
from lib.core.entities.project_entities import ConfigEntity
1313
from lib.core.entities.project_entities import FolderEntity
@@ -18,15 +18,7 @@
1818
from lib.core.entities.project_entities import TeamEntity
1919
from lib.core.entities.project_entities import UserEntity
2020
from lib.core.entities.project_entities import WorkflowEntity
21-
from superannotate_schemas.schemas.internal.document import DocumentAnnotation
22-
from superannotate_schemas.schemas.internal.pixel import PixelAnnotation
23-
from superannotate_schemas.schemas.internal.vector import VectorAnnotation
24-
from superannotate_schemas.schemas.internal.video import VideoAnnotation
25-
from superannotate_schemas.schemas.internal.video import (
26-
VideoAnnotation as VideoExportAnnotation,
27-
)
2821

29-
# from lib.core.entities.project_entities import ProjectEntity
3022

3123
__all__ = [
3224
# base
@@ -53,10 +45,4 @@
5345
"TeamEntity",
5446
"MLModelEntity",
5547
"IntegrationEntity",
56-
# annotations
57-
"DocumentAnnotation",
58-
"VideoAnnotation",
59-
"VectorAnnotation",
60-
"PixelAnnotation",
61-
"VideoExportAnnotation",
6248
]

0 commit comments

Comments
 (0)