Skip to content

Commit e8eee43

Browse files
authored
Merge pull request #389 from superannotateai/friday-merge
validate
2 parents 2edc4bc + 08da112 commit e8eee43

File tree

8 files changed

+31
-22
lines changed

8 files changed

+31
-22
lines changed

src/superannotate/lib/app/analytics/aggregators.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,13 @@
11
import copy
22
import json
3+
from dataclasses import dataclass
34
from pathlib import Path
45
from typing import List
56
from typing import Optional
67
from typing import Union
78

89
import lib.core as constances
910
import pandas as pd
10-
from dataclasses import dataclass
1111
from lib.app.exceptions import AppException
1212
from lib.core import ATTACHED_VIDEO_ANNOTATION_POSTFIX
1313
from lib.core import PIXEL_ANNOTATION_POSTFIX

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1637,7 +1637,9 @@ def create_annotation_classes_from_classes_json(
16371637
classes_json = json.load(data)
16381638
annotation_classes = parse_obj_as(List[AnnotationClassEntity], classes_json)
16391639
logger.info(
1640-
"Creating annotation classes in project %s from %s.", project, classes_json_initial,
1640+
"Creating annotation classes in project %s from %s.",
1641+
project,
1642+
classes_json_initial,
16411643
)
16421644
response = controller.create_annotation_classes(
16431645
project_name=project, annotation_classes=annotation_classes,

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

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -95,9 +95,7 @@ class ClassType(StrictStr):
9595
def validate(cls, value: Union[str]) -> Union[str]:
9696
enum_values = [e.name.lower() for e in ClassTypeEnum]
9797
if value.lower() not in enum_values:
98-
raise TypeError(
99-
f"Available class_types are {', '.join(enum_values)}. "
100-
)
98+
raise TypeError(f"Available class_types are {', '.join(enum_values)}. ")
10199
return value.lower()
102100

103101

src/superannotate/lib/core/data_handlers.py

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,9 @@ def get_annotation_class(
4343
self, name: str, class_type: ClassTypeEnum
4444
) -> AnnotationClass:
4545
for annotation_class in self._annotation_classes:
46-
if annotation_class.name == name and class_type.equals(annotation_class.type):
46+
if annotation_class.name == name and class_type.equals(
47+
annotation_class.type
48+
):
4749
return annotation_class
4850

4951
@lru_cache()
@@ -207,7 +209,9 @@ def handle(self, annotation: dict):
207209
i for i in annotation["instances"] if "className" in i and i["classId"] > 0
208210
]:
209211
annotation_class_name = annotation_instance["className"]
210-
annotation_class_type = self._get_class_type(annotation_instance.get("type", ClassTypeEnum.OBJECT))
212+
annotation_class_type = self._get_class_type(
213+
annotation_instance.get("type", ClassTypeEnum.OBJECT)
214+
)
211215

212216
annotation_class = self.get_annotation_class(
213217
annotation_class_name, annotation_class_type
@@ -287,7 +291,9 @@ def convert_timestamp(timestamp):
287291
"locked": False,
288292
}
289293
if class_name:
290-
annotation_class = self.get_annotation_class(class_name,ClassTypeEnum.OBJECT)
294+
annotation_class = self.get_annotation_class(
295+
class_name, ClassTypeEnum.OBJECT
296+
)
291297
if annotation_class:
292298
editor_instance["classId"] = annotation_class.id
293299
else:
@@ -322,7 +328,9 @@ def convert_timestamp(timestamp):
322328
] = timestamp_data["points"]
323329
if not class_name:
324330
continue
325-
annotation_class = self.get_annotation_class(class_name,ClassTypeEnum.OBJECT)
331+
annotation_class = self.get_annotation_class(
332+
class_name, ClassTypeEnum.OBJECT
333+
)
326334
if not annotation_class:
327335
self.reporter.store_message(
328336
"missing_classes", meta["className"]

src/superannotate/lib/core/types.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,10 @@
1-
from typing import Dict
2-
from typing import List
31
from typing import Optional
42
from typing import Union
53

64
from pydantic import BaseModel
75
from pydantic import constr
86
from pydantic import Extra
97
from pydantic import StrictStr
10-
from pydantic import validate_model
11-
from pydantic import validator
128
from pydantic.error_wrappers import ErrorWrapper
139
from pydantic.error_wrappers import ValidationError
1410
from superannotate_schemas.schemas.classes import AttributeGroup as AttributeGroupSchema
@@ -28,7 +24,6 @@ def validate(cls, value: str) -> Union[str]:
2824
return value
2925

3026

31-
3227
class Project(BaseModel):
3328
name: NotEmptyStr
3429

@@ -45,5 +40,3 @@ class MLModel(BaseModel):
4540

4641
class Config:
4742
extra = Extra.allow
48-
49-

src/superannotate/lib/infrastructure/controller.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ def __init__(self, config_path: str, token: str = None):
7070
self._team_name = None
7171
self._reporter = None
7272
self._ssl_verify = not os.environ.get("SA_TESTING", False)
73-
self._config_path = expanduser(config_path) if config_path else constances.CONFIG_FILE_LOCATION
73+
self._config_path = (
74+
expanduser(config_path) if config_path else constances.CONFIG_FILE_LOCATION
75+
)
7476

7577
self._backend_url = os.environ.get("SA_URL", constances.BACKEND_URL)
7678
if not token and not config_path:
@@ -261,7 +263,6 @@ def annotation_validators(self) -> AnnotationValidators:
261263

262264

263265
class Controller(BaseController):
264-
265266
def __init__(self, config_path: str = None):
266267
super().__init__(config_path)
267268
self._team = None
@@ -1150,7 +1151,12 @@ def get_duplicate_images(self, project_name: str, folder_name: str, images: list
11501151
)
11511152

11521153
def create_annotation_class(
1153-
self, project_name: str, name: str, color: str, attribute_groups: List[dict], class_type: str
1154+
self,
1155+
project_name: str,
1156+
name: str,
1157+
color: str,
1158+
attribute_groups: List[dict],
1159+
class_type: str,
11541160
):
11551161
project = self._get_project(project_name)
11561162
annotation_classes = AnnotationClassRepository(

src/superannotate/lib/infrastructure/repositories.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -360,7 +360,7 @@ def dict2entity(data: dict) -> AnnotationClassEntity:
360360
createdAt=data["createdAt"],
361361
updatedAt=data["updatedAt"],
362362
attribute_groups=data["attribute_groups"],
363-
type=ClassTypeEnum.get_name(data.get('type')),
363+
type=ClassTypeEnum.get_name(data.get("type")),
364364
)
365365

366366

src/superannotate/logger.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,11 @@ def get_default_logger():
4343
expanduser(constances.LOG_FILE_LOCATION),
4444
maxBytes=5 * 1024 * 1024,
4545
backupCount=5,
46-
mode="a"
46+
mode="a",
47+
)
48+
formatter = Formatter(
49+
"SA-PYTHON-SDK - %(levelname)s - %(asctime)s - %(message)s"
4750
)
48-
formatter = Formatter("SA-PYTHON-SDK - %(levelname)s - %(asctime)s - %(message)s")
4951
file_handler.setFormatter(formatter)
5052
file_handler.setLevel("DEBUG")
5153
default_logger.addHandler(file_handler)

0 commit comments

Comments
 (0)