Skip to content

Commit 3e574b4

Browse files
committed
Add logger to response
1 parent bd2712b commit 3e574b4

File tree

3 files changed

+17
-10
lines changed

3 files changed

+17
-10
lines changed

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

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2409,6 +2409,9 @@ def upload_annotations_from_folder_to_project(
24092409
progress_bar.update(1)
24102410
else:
24112411
raise AppException(use_case.response.errors)
2412+
if use_case.response.report:
2413+
for i in use_case.response.report_messages:
2414+
logger.info(i)
24122415
return use_case.data
24132416

24142417

src/superannotate/lib/core/response.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ class Response:
55
def __init__(self, status: str = None, data: Union[dict, list] = None):
66
self._status = status
77
self._data = data
8+
self._report = []
89
self._errors = []
910

1011
@property
@@ -15,6 +16,18 @@ def data(self):
1516
def data(self, value):
1617
self._data = value
1718

19+
@property
20+
def report(self):
21+
return "\n".join(self._report)
22+
23+
@report.setter
24+
def report(self, value: str):
25+
self._report.append(value)
26+
27+
@property
28+
def report_messages(self):
29+
return self._report
30+
1831
@property
1932
def status(self):
2033
return self.data

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

Lines changed: 1 addition & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2502,7 +2502,6 @@ def __init__(
25022502
self.missing_attribute_groups = set()
25032503
self.missing_classes = set()
25042504
self.missing_attributes = set()
2505-
self._failed_annotation_reports = []
25062505

25072506
@property
25082507
def s3_client(self):
@@ -2744,7 +2743,6 @@ def execute(self):
27442743
missing_annotations,
27452744
)
27462745
self.report_missing_data()
2747-
self.report_failed_annotations()
27482746
return self._response
27492747

27502748
def upload_to_s3(
@@ -2784,16 +2782,9 @@ def upload_to_s3(
27842782
bucket.put_object(Key=image_info["annotation_bluemap_path"], Body=file)
27852783
return image_id_name_map[image_id], True
27862784
except Exception as e:
2787-
self._failed_annotation_reports.append(
2788-
{"image": image_id_name_map[image_id].name, "message": str(e)}
2789-
)
2785+
self._response.report = f"Couldn't upload annotation {image_id_name_map[image_id].name} - {str(e)}"
27902786
return image_id_name_map[image_id], False
27912787

2792-
def report_failed_annotations(self):
2793-
for info in self._failed_annotation_reports:
2794-
logger.warning(
2795-
f"Couldn't upload annotation {info['image']} - {info['message']}"
2796-
)
27972788

27982789
def report_missing_data(self):
27992790
if self.missing_classes:

0 commit comments

Comments
 (0)