Skip to content

Commit ef3080c

Browse files
committed
Fix friday-999, friday-984
1 parent b2bacd0 commit ef3080c

File tree

17 files changed

+69
-75
lines changed

17 files changed

+69
-75
lines changed

pytest.ini

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[pytest]
2-
minversion = 3.0
2+
minversion = 3.7
33
log_cli=true
44
python_files = test_*.py
55
addopts = -n auto --dist=loadscope

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,12 +12,6 @@
1212
from typing import Union
1313

1414
import boto3
15-
from pydantic import StrictBool
16-
from pydantic import conlist
17-
from pydantic import parse_obj_as
18-
from pydantic.error_wrappers import ValidationError
19-
from tqdm import tqdm
20-
2115
import lib.core as constances
2216
from lib.app.annotation_helpers import add_annotation_bbox_to_json
2317
from lib.app.annotation_helpers import add_annotation_comment_to_json
@@ -58,7 +52,12 @@
5852
from lib.core.types import PriorityScore
5953
from lib.core.types import Project
6054
from lib.infrastructure.controller import Controller
55+
from pydantic import conlist
56+
from pydantic import parse_obj_as
57+
from pydantic import StrictBool
58+
from pydantic.error_wrappers import ValidationError
6159
from superannotate.logger import get_default_logger
60+
from tqdm import tqdm
6261

6362
logger = get_default_logger()
6463

@@ -397,10 +396,10 @@ def rename_project(project: NotEmptyStr, new_name: NotEmptyStr):
397396
)
398397
if response.errors:
399398
raise AppException(response.errors)
400-
return ProjectSerializer(response.data).serialize()
401399
logger.info(
402-
"Successfully renamed project %s to %s.", project, response.data["name"]
400+
"Successfully renamed project %s to %s.", project, response.data.name
403401
)
402+
return ProjectSerializer(response.data).serialize()
404403

405404

406405
@Trackable
@@ -3135,7 +3134,7 @@ def attach_items(
31353134
unique_attachments = parse_obj_as(List[AttachmentEntity], unique_attachments)
31363135
uploaded, fails, duplicated = [], [], []
31373136
if unique_attachments:
3138-
logger.info(f"Attaching {len(unique_attachments)} file(s) to project {project}.")
3137+
logger.info(f"Attaching {len(unique_attachments)} file(s) to project {project}.")
31393138
response = Controller.get_default().attach_items(
31403139
project_name=project_name,
31413140
folder_name=folder_name,

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -175,7 +175,7 @@ class AnnotationStatuses(StrictStr):
175175
def validate(cls, value: Union[str]) -> Union[str]:
176176
if value.lower() not in AnnotationStatus.values():
177177
raise TypeError(
178-
f"Available annotation_statuses are {', '.join(AnnotationStatus.titles())}. "
178+
f"Available an``notation_statuses are {', '.join(AnnotationStatus.titles())}. "
179179
)
180180
return value
181181

src/superannotate/lib/app/serializers.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,9 +4,8 @@
44
from typing import Set
55
from typing import Union
66

7-
from pydantic import BaseModel
8-
97
import superannotate.lib.core as constance
8+
from pydantic import BaseModel
109
from superannotate.lib.core.entities import BaseEntity
1110
from superannotate.lib.core.entities import ImageEntity
1211
from superannotate.lib.core.entities import ProjectEntity

src/superannotate/lib/core/conditions.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,17 @@
1212
CONDITION_LE = "<="
1313

1414

15+
class EmptyCondition:
16+
def __or__(self, other):
17+
return other
18+
19+
def __and__(self, other):
20+
return other
21+
22+
def build_query(self):
23+
return ""
24+
25+
1526
class Condition:
1627
def __init__(self, key: str, value: Any, condition_type: str):
1728
self._key = key
@@ -21,16 +32,6 @@ def __init__(self, key: str, value: Any, condition_type: str):
2132

2233
@staticmethod
2334
def get_empty_condition():
24-
class EmptyCondition:
25-
def __or__(self, other):
26-
return other
27-
28-
def __and__(self, other):
29-
return other
30-
31-
def build_query(self):
32-
return ""
33-
3435
return EmptyCondition()
3536

3637
def __str__(self):
@@ -46,10 +47,12 @@ def __or__(self, other):
4647
def __and__(self, other):
4748
if isinstance(other, tuple) or isinstance(other, list):
4849
for elem in other:
50+
if isinstance(other, EmptyCondition):
51+
continue
4952
if not isinstance(other, Condition):
5053
raise Exception("Support the only Condition types")
51-
return self.__and__(elem)
52-
elif not isinstance(other, Condition):
54+
return self.__and__(elem)
55+
elif not isinstance(other, (Condition, EmptyCondition)):
5356
raise Exception("Support the only Condition types")
5457
QueryCondition = namedtuple("QueryCondition", ("condition", "query"))
5558
self._condition_set.append(QueryCondition(CONDITION_AND, other.build_query()))

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
from lib.core.entities.base import AttachmentEntity
2-
from lib.core.entities.base import ProjectEntity
32
from lib.core.entities.base import BaseEntity as TmpBaseEntity
3+
from lib.core.entities.base import ProjectEntity
44
from lib.core.entities.base import SettingEntity
55
from lib.core.entities.integrations import IntegrationEntity
66
from lib.core.entities.items import DocumentEntity
@@ -14,7 +14,6 @@
1414
from lib.core.entities.project_entities import ImageEntity
1515
from lib.core.entities.project_entities import ImageInfoEntity
1616
from lib.core.entities.project_entities import MLModelEntity
17-
# from lib.core.entities.project_entities import ProjectEntity
1817
from lib.core.entities.project_entities import S3FileEntity
1918
from lib.core.entities.project_entities import TeamEntity
2019
from lib.core.entities.project_entities import UserEntity
@@ -26,6 +25,7 @@
2625
from superannotate_schemas.schemas.internal.video import (
2726
VideoAnnotation as VideoExportAnnotation,
2827
)
28+
# from lib.core.entities.project_entities import ProjectEntity
2929

3030
__all__ = [
3131
# base

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
import uuid
22
from datetime import datetime
3-
from typing import Optional
4-
from typing import List
53
from typing import Any
4+
from typing import List
5+
from typing import Optional
66
from typing import Union
77

88
from lib.core.enums import AnnotationStatus

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ class TmpImageEntity(Entity):
3131
segmentation_status: Optional[SegmentationStatus] = Field(
3232
SegmentationStatus.NOT_STARTED
3333
)
34-
approval_status: Optional[bool] = Field(None)
34+
approval_status: Optional[int] = Field(None)
3535

3636
class Config:
3737
extra = Extra.ignore

src/superannotate/lib/core/types.py

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,15 @@
11
from typing import Optional
2-
from typing import Union
32

43
from pydantic import BaseModel
54
from pydantic import constr
65
from pydantic import Extra
7-
from pydantic import StrictStr
8-
from pydantic.error_wrappers import ErrorWrapper
9-
from pydantic.error_wrappers import ValidationError
106
from superannotate_schemas.schemas.classes import AttributeGroup as AttributeGroupSchema
117

128
NotEmptyStr = constr(strict=True, min_length=1)
139

1410
AttributeGroup = AttributeGroupSchema
1511

1612

17-
class AnnotationType(StrictStr):
18-
@classmethod
19-
def validate(cls, value: str) -> Union[str]:
20-
if value not in ANNOTATION_TYPES.keys():
21-
raise ValidationError(
22-
[ErrorWrapper(TypeError(f"invalid value {value}"), "type")], cls
23-
)
24-
return value
25-
26-
2713
class Project(BaseModel):
2814
name: NotEmptyStr
2915

src/superannotate/lib/core/usecases/items.py

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
from lib.core.entities import ProjectEntity
1212
from lib.core.entities import TmpBaseEntity
1313
from lib.core.entities import TmpImageEntity
14-
from lib.core.entities import VideoEntity
1514
from lib.core.exceptions import AppException
1615
from lib.core.exceptions import AppValidationException
1716
from lib.core.exceptions import BackendError
@@ -54,7 +53,8 @@ def serialize_entity(entity: Entity, project: ProjectEntity):
5453
tmp_entity.segmentation_status = None
5554
return TmpImageEntity(**tmp_entity.dict(by_alias=True))
5655
elif project.type == constances.ProjectType.VIDEO.value:
57-
return VideoEntity(**entity.dict(by_alias=True))
56+
return
57+
5858
elif project.type == constances.ProjectType.DOCUMENT.value:
5959
return DocumentEntity(**entity.dict(by_alias=True))
6060
return entity
@@ -245,6 +245,7 @@ def execute(self) -> Response:
245245
if self.is_valid():
246246
duplications = []
247247
attached = []
248+
self.reporter.start_progress(self.attachments_count, "Attaching URLs")
248249
for i in range(0, self.attachments_count, self.CHUNK_SIZE):
249250
attachments = self._attachments[i: i + self.CHUNK_SIZE] # noqa: E203
250251
response = self._backend_service.get_bulk_images(
@@ -276,6 +277,8 @@ def execute(self) -> Response:
276277
self._response.errors = AppException(backend_response["error"])
277278
else:
278279
attached.extend(backend_response)
280+
self.reporter.update_progress(len(attachments))
281+
self.reporter.finish_progress()
279282
self._response.data = attached, duplications
280283
return self._response
281284

@@ -363,7 +366,7 @@ def execute(self):
363366
include_annotations=self._include_annotations,
364367
)
365368
if not poll_id:
366-
skipped_images.append(chunk_to_copy)
369+
skipped_items.extend(chunk_to_copy)
367370
continue
368371
try:
369372
self._backend_service.await_progress(
@@ -467,4 +470,3 @@ def execute(self):
467470

468471
self._response.data = list(set(items) - set(moved_images))
469472
return self._response
470-

0 commit comments

Comments
 (0)