Skip to content

Commit 082361a

Browse files
committed
tod
1 parent 7b4e828 commit 082361a

File tree

6 files changed

+16
-12
lines changed

6 files changed

+16
-12
lines changed

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2112,7 +2112,7 @@ def upload_image_annotations(
21122112
mask=mask,
21132113
verbose=verbose,
21142114
)
2115-
if response.errors and not response.errors == constances.INVALID_JSON_MESSSAGE:
2115+
if response.errors and not response.errors == constances.INVALID_JSON_MESSAGE:
21162116
raise AppException(response.errors)
21172117

21182118

src/superannotate/lib/core/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@
123123
"which an annotation is invalid."
124124
)
125125

126-
INVALID_JSON_MESSSAGE = "Invalid json"
126+
INVALID_JSON_MESSAGE = "Invalid json"
127127

128128
__alL__ = (
129129
ProjectType,

src/superannotate/lib/core/reporter.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,12 @@ def __init__(
2424
self.custom_messages = defaultdict(set)
2525
self.progress_bar = None
2626

27+
def disable_warnings(self):
28+
self._log_warning = False
29+
30+
def enable_warnings(self):
31+
self._log_warning = True
32+
2733
def log_info(self, value: str):
2834
if self._log_info:
2935
self.logger.info(value)

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

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,6 +168,7 @@ def _upload_annotation(
168168
bucket,
169169
):
170170
try:
171+
self.reporter.disable_warnings()
171172
response = UploadAnnotationUseCase(
172173
project=self._project,
173174
folder=self._folder,
@@ -196,6 +197,8 @@ def _upload_annotation(
196197
except Exception as e:
197198
logger.debug(str(e), exc_info=True)
198199
return path, False
200+
finally:
201+
self.reporter.enable_warnings()
199202

200203
def get_bucket_to_upload(self, ids: List[int]):
201204
upload_data = self.get_annotation_upload_data(ids)
@@ -485,13 +488,11 @@ def execute(self):
485488
)
486489
self._images.update(self._image)
487490
if self._verbose:
488-
logger.info(
489-
"Uploading annotations for image %s in project %s.",
490-
str(self._image.name),
491-
self._project.name,
491+
self.reporter.log_info(
492+
f"Uploading annotations for image {str(self._image.name)} in project {self._project.name}."
492493
)
493494
else:
494-
self._response.errors = constances.INVALID_JSON_MESSSAGE
495+
self._response.errors = constances.INVALID_JSON_MESSAGE
495496
self.reporter.store_message("invalid_jsons", self._annotation_path)
496497
self.reporter.log_warning(
497498
f"Couldn't validate annotations. {constances.USE_VALIDATE_MESSAGE}"

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
from lib.core.repositories import BaseManageableRepository
4141
from lib.core.repositories import BaseReadOnlyRepository
4242
from lib.core.response import Response
43-
from lib.core.reporter import Progress
4443
from lib.core.serviceproviders import SuerannotateServiceProvider
4544
from lib.core.usecases.base import BaseInteractiveUseCase
4645
from lib.core.usecases.base import BaseReportableUseCae

src/superannotate/lib/infrastructure/controller.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -216,9 +216,7 @@ def team_id(self) -> int:
216216

217217
@property
218218
def default_reporter(self):
219-
if not self._reporter:
220-
self._reporter = Reporter()
221-
return self._reporter
219+
return Reporter()
222220

223221
@timed_lru_cache(seconds=3600)
224222
def get_auth_data(self, project_id: int, team_id: int, folder_id: int):
@@ -1313,7 +1311,7 @@ def upload_image_annotations(
13131311
backend_service_provider=self._backend_client,
13141312
mask=mask,
13151313
verbose=verbose,
1316-
reporter=Reporter(log_info=True, log_warning=True),
1314+
reporter=self.default_reporter,
13171315
validators=self.annotation_validators,
13181316
)
13191317
return use_case.execute()

0 commit comments

Comments
 (0)