Skip to content

Commit 0504fb0

Browse files
authored
Merge pull request #229 from superannotateai/346
Fix
2 parents 1d5223f + 3e574b4 commit 0504fb0

File tree

4 files changed

+45
-11
lines changed

4 files changed

+45
-11
lines changed

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

Lines changed: 18 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2259,7 +2259,11 @@ def attach_image_urls_to_project(
22592259
logger.warning(
22602260
constances.ALREADY_EXISTING_FILES_WARNING.format(len(duplicate_images))
22612261
)
2262-
logger.info(constances.ATTACHING_FILES_MESSAGE.format(len(images_to_upload),project_folder_name))
2262+
logger.info(
2263+
constances.ATTACHING_FILES_MESSAGE.format(
2264+
len(images_to_upload), project_folder_name
2265+
)
2266+
)
22632267
if use_case.is_valid():
22642268
with tqdm(
22652269
total=use_case.attachments_count, desc="Attaching urls"
@@ -2312,7 +2316,11 @@ def attach_video_urls_to_project(
23122316
logger.warning(
23132317
constances.ALREADY_EXISTING_FILES_WARNING.format(len(duplicate_images))
23142318
)
2315-
logger.info(constances.ATTACHING_FILES_MESSAGE.format(len(images_to_upload),project_folder_name))
2319+
logger.info(
2320+
constances.ATTACHING_FILES_MESSAGE.format(
2321+
len(images_to_upload), project_folder_name
2322+
)
2323+
)
23162324
if use_case.is_valid():
23172325
with tqdm(
23182326
total=use_case.attachments_count, desc="Attaching urls"
@@ -2405,6 +2413,9 @@ def upload_annotations_from_folder_to_project(
24052413
progress_bar.update(1)
24062414
else:
24072415
raise AppException(use_case.response.errors)
2416+
if use_case.response.report:
2417+
for i in use_case.response.report_messages:
2418+
logger.info(i)
24082419
return use_case.data
24092420

24102421

@@ -3528,7 +3539,11 @@ def attach_document_urls_to_project(
35283539
logger.warning(
35293540
constances.ALREADY_EXISTING_FILES_WARNING.format(len(duplicate_images))
35303541
)
3531-
logger.info(constances.ATTACHING_FILES_MESSAGE.format(len(images_to_upload),project_folder_name))
3542+
logger.info(
3543+
constances.ATTACHING_FILES_MESSAGE.format(
3544+
len(images_to_upload), project_folder_name
3545+
)
3546+
)
35323547
if use_case.is_valid():
35333548
with tqdm(
35343549
total=use_case.attachments_count, desc="Attaching urls"

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: 10 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,
@@ -2779,9 +2781,11 @@ def upload_to_s3(
27792781
file = io.BytesIO(mask_file.read())
27802782
bucket.put_object(Key=image_info["annotation_bluemap_path"], Body=file)
27812783
return image_id_name_map[image_id], True
2782-
except Exception as _:
2784+
except Exception as e:
2785+
self._response.report = f"Couldn't upload annotation {image_id_name_map[image_id].name} - {str(e)}"
27832786
return image_id_name_map[image_id], False
27842787

2788+
27852789
def report_missing_data(self):
27862790
if self.missing_classes:
27872791
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)