Skip to content

Commit 2027bfc

Browse files
Vaghinak BasentsyanVaghinak Basentsyan
authored andcommitted
tod
1 parent d19346e commit 2027bfc

File tree

5 files changed

+21
-11
lines changed

5 files changed

+21
-11
lines changed

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

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3517,7 +3517,10 @@ def upload_images_to_project(
35173517
with tqdm(total=len(images_to_upload), desc="Uploading images") as progress_bar:
35183518
for _ in use_case.execute():
35193519
progress_bar.update(1)
3520-
return use_case.data
3520+
uploaded, failed_images, duplications = use_case.data
3521+
if duplications:
3522+
logger.info(f"Duplicated images {', '.join(duplications)}")
3523+
return uploaded, failed_images, duplications
35213524
raise AppException(use_case.response.errors)
35223525

35233526

src/superannotate/lib/core/types.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ class Attribute(BaseModel):
1717

1818
class AttributeGroup(BaseModel):
1919
name: StrictStr
20+
is_multiselect: Optional[int]
2021
attributes: List[Attribute]
2122

2223

src/superannotate/lib/core/usecases.py

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -3268,9 +3268,6 @@ def execute(self):
32683268
annotations,
32693269
fuse_image,
32703270
)
3271-
logger.info(
3272-
"Downloaded image %s to %s.", self._image.name, str(download_path)
3273-
)
32743271

32753272
return self._response
32763273

@@ -4067,6 +4064,8 @@ def download_to_local_storage(self, destination: str):
40674064
project_id=self._project.uuid,
40684065
export_id=export["id"],
40694066
)
4067+
if "error" in export:
4068+
raise AppException(export["error"])
40704069
export_status = export["status"]
40714070
if export_status in (ExportStatus.ERROR.value, ExportStatus.CANCELED.value):
40724071
raise AppException("Couldn't download export.")
@@ -4877,7 +4876,7 @@ def _upload_image(self, image_path: str):
48774876
else:
48784877
try:
48794878
image_bytes = io.BytesIO(open(image_path, "rb").read())
4880-
except FileNotFoundError:
4879+
except OSError:
48814880
return ProcessedImage(
48824881
uploaded=False,
48834882
path=image_path,
@@ -4927,10 +4926,6 @@ def images_to_upload(self):
49274926
[extension in path for extension in self.exclude_file_patterns]
49284927
)
49294928
]
4930-
excluded_paths = [path for path in paths if path not in filtered_paths]
4931-
if excluded_paths:
4932-
logger.info(f"Excluded paths {', '.join(excluded_paths)}")
4933-
49344929
image_entities = (
49354930
GetBulkImages(
49364931
service=self._backend_client,
@@ -4994,8 +4989,6 @@ def execute(self):
49944989
duplications.extend(attach_duplications)
49954990
uploaded = [image["name"] for image in uploaded]
49964991
failed_images = [image.split("/")[-1] for image in failed_images]
4997-
if duplications:
4998-
logger.info(f"Duplicated images {', '.join(duplications)}")
49994992
self._response.data = uploaded, failed_images, duplications
50004993
return self._response
50014994

src/superannotate/lib/infrastructure/services.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,7 @@ def __init__(
3939
self._paginate_by = paginate_by
4040
self._verify_ssl = verify_ssl
4141
self.team_id = auth_token.split("=")[-1]
42+
self.get_session()
4243

4344
@timed_lru_cache(seconds=360)
4445
def get_session(self):

tests/integration/test_interface.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,18 @@ def test_overlay_fuse(self):
138138
)
139139
self.assertIsNotNone(paths)
140140

141+
def test_upload_images_to_project_returned_data(self):
142+
upload, not_uploaded, duplicated = sa.upload_images_to_project(
143+
self.PROJECT_NAME,
144+
[f"{self.folder_path}/{self.EXAMPLE_IMAGE_1}", f"{self.folder_path}/{self.EXAMPLE_IMAGE_2}"]
145+
)
146+
self.assertEqual(2, len(upload))
147+
upload, not_uploaded, duplicated = sa.upload_images_to_project(
148+
self.PROJECT_NAME,
149+
[f"{self.folder_path}/{self.EXAMPLE_IMAGE_1}", f"{self.folder_path}/{self.EXAMPLE_IMAGE_2}"]
150+
)
151+
self.assertEqual(2, len(duplicated))
152+
141153
def test_upload_images_to_project_image_quality_in_editor(self):
142154
self.assertRaises(
143155
AppException,

0 commit comments

Comments
 (0)