Skip to content

Commit bd2712b

Browse files
committed
Fix
1 parent a3f4a53 commit bd2712b

File tree

3 files changed

+38
-11
lines changed

3 files changed

+38
-11
lines changed

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

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2255,7 +2255,11 @@ def attach_image_urls_to_project(
22552255
logger.warning(
22562256
constances.ALREADY_EXISTING_FILES_WARNING.format(len(duplicate_images))
22572257
)
2258-
logger.info(constances.ATTACHING_FILES_MESSAGE.format(len(images_to_upload),project_folder_name))
2258+
logger.info(
2259+
constances.ATTACHING_FILES_MESSAGE.format(
2260+
len(images_to_upload), project_folder_name
2261+
)
2262+
)
22592263
if use_case.is_valid():
22602264
with tqdm(
22612265
total=use_case.attachments_count, desc="Attaching urls"
@@ -2308,7 +2312,11 @@ def attach_video_urls_to_project(
23082312
logger.warning(
23092313
constances.ALREADY_EXISTING_FILES_WARNING.format(len(duplicate_images))
23102314
)
2311-
logger.info(constances.ATTACHING_FILES_MESSAGE.format(len(images_to_upload),project_folder_name))
2315+
logger.info(
2316+
constances.ATTACHING_FILES_MESSAGE.format(
2317+
len(images_to_upload), project_folder_name
2318+
)
2319+
)
23122320
if use_case.is_valid():
23132321
with tqdm(
23142322
total=use_case.attachments_count, desc="Attaching urls"
@@ -3524,7 +3532,11 @@ def attach_document_urls_to_project(
35243532
logger.warning(
35253533
constances.ALREADY_EXISTING_FILES_WARNING.format(len(duplicate_images))
35263534
)
3527-
logger.info(constances.ATTACHING_FILES_MESSAGE.format(len(images_to_upload),project_folder_name))
3535+
logger.info(
3536+
constances.ATTACHING_FILES_MESSAGE.format(
3537+
len(images_to_upload), project_folder_name
3538+
)
3539+
)
35283540
if use_case.is_valid():
35293541
with tqdm(
35303542
total=use_case.attachments_count, desc="Attaching urls"

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

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,6 @@ def _validate_limitations(self, to_upload_count):
238238
):
239239
raise AppValidationException(constances.ATTACH_USER_LIMIT_ERROR_MESSAGE)
240240

241-
242241
@property
243242
def annotation_status_code(self):
244243
if self._annotation_status:
@@ -1466,7 +1465,8 @@ def execute(self):
14661465
folder=self._folder,
14671466
backend_service_provider=self._backend_client,
14681467
attachments=[
1469-
image.entity for image in uploaded_images[i : i + 100] # noqa: E203
1468+
image.entity
1469+
for image in uploaded_images[i : i + 100] # noqa: E203
14701470
],
14711471
annotation_status=self._annotation_status,
14721472
upload_state_code=constances.UploadState.BASIC.value,
@@ -1594,8 +1594,8 @@ def __init__(
15941594
def auth_data(self):
15951595
if not self._auth_data:
15961596
self._auth_data = self._backend_service.get_s3_upload_auth_token(
1597-
self._project.team_id, self._folder.uuid, self._project.uuid
1598-
)
1597+
self._project.team_id, self._folder.uuid, self._project.uuid
1598+
)
15991599
return self._auth_data
16001600

16011601
@property
@@ -1926,7 +1926,9 @@ def execute(self):
19261926
response = AttachFileUrlsUseCase(
19271927
project=self._project,
19281928
folder=self._folder,
1929-
attachments=self._attachments[i : i + self.CHUNK_SIZE], # noqa: E203
1929+
attachments=self._attachments[
1930+
i : i + self.CHUNK_SIZE
1931+
], # noqa: E203
19301932
backend_service_provider=self._backend_service,
19311933
annotation_status=self._annotation_status,
19321934
upload_state_code=self._upload_state_code,
@@ -2500,6 +2502,7 @@ def __init__(
25002502
self.missing_attribute_groups = set()
25012503
self.missing_classes = set()
25022504
self.missing_attributes = set()
2505+
self._failed_annotation_reports = []
25032506

25042507
@property
25052508
def s3_client(self):
@@ -2741,6 +2744,7 @@ def execute(self):
27412744
missing_annotations,
27422745
)
27432746
self.report_missing_data()
2747+
self.report_failed_annotations()
27442748
return self._response
27452749

27462750
def upload_to_s3(
@@ -2779,9 +2783,18 @@ def upload_to_s3(
27792783
file = io.BytesIO(mask_file.read())
27802784
bucket.put_object(Key=image_info["annotation_bluemap_path"], Body=file)
27812785
return image_id_name_map[image_id], True
2782-
except Exception as _:
2786+
except Exception as e:
2787+
self._failed_annotation_reports.append(
2788+
{"image": image_id_name_map[image_id].name, "message": str(e)}
2789+
)
27832790
return image_id_name_map[image_id], False
27842791

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+
)
2797+
27852798
def report_missing_data(self):
27862799
if self.missing_classes:
27872800
logger.warning(f"Couldn't find classes [{', '.join(self.missing_classes)}]")

src/superannotate/lib/infrastructure/controller.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,10 @@ def init(self, config_path):
6868
self.configs.get_one("token"),
6969
self.configs.get_one("main_endpoint"),
7070
)
71-
if token: token = token.value
72-
if main_endpoint: main_endpoint = main_endpoint.value
71+
if token:
72+
token = token.value
73+
if main_endpoint:
74+
main_endpoint = main_endpoint.value
7375
if not main_endpoint:
7476
self.configs.insert(ConfigEntity("main_endpoint", constances.BACKEND_URL))
7577
if not token:

0 commit comments

Comments
 (0)