Skip to content

Commit 18a0748

Browse files
Vaghinak BasentsyanVaghinak Basentsyan
authored andcommitted
tod
1 parent d19346e commit 18a0748

File tree

5 files changed

+21
-12
lines changed

5 files changed

+21
-12
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 & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -2353,7 +2353,6 @@ def fill_classes_data(self, annotations: dict):
23532353
attribute["groupId"]
23542354
]["attributes"]
23552355
):
2356-
del attribute["groupId"]
23572356
continue
23582357
attribute["name"] = annotation_classes[annotation_class_id][
23592358
"attribute_groups"
@@ -3268,9 +3267,6 @@ def execute(self):
32683267
annotations,
32693268
fuse_image,
32703269
)
3271-
logger.info(
3272-
"Downloaded image %s to %s.", self._image.name, str(download_path)
3273-
)
32743270

32753271
return self._response
32763272

@@ -4067,6 +4063,8 @@ def download_to_local_storage(self, destination: str):
40674063
project_id=self._project.uuid,
40684064
export_id=export["id"],
40694065
)
4066+
if "error" in export:
4067+
raise AppException(export["error"])
40704068
export_status = export["status"]
40714069
if export_status in (ExportStatus.ERROR.value, ExportStatus.CANCELED.value):
40724070
raise AppException("Couldn't download export.")
@@ -4877,7 +4875,7 @@ def _upload_image(self, image_path: str):
48774875
else:
48784876
try:
48794877
image_bytes = io.BytesIO(open(image_path, "rb").read())
4880-
except FileNotFoundError:
4878+
except OSError:
48814879
return ProcessedImage(
48824880
uploaded=False,
48834881
path=image_path,
@@ -4927,10 +4925,6 @@ def images_to_upload(self):
49274925
[extension in path for extension in self.exclude_file_patterns]
49284926
)
49294927
]
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-
49344928
image_entities = (
49354929
GetBulkImages(
49364930
service=self._backend_client,
@@ -4994,8 +4988,6 @@ def execute(self):
49944988
duplications.extend(attach_duplications)
49954989
uploaded = [image["name"] for image in uploaded]
49964990
failed_images = [image.split("/")[-1] for image in failed_images]
4997-
if duplications:
4998-
logger.info(f"Duplicated images {', '.join(duplications)}")
49994991
self._response.data = uploaded, failed_images, duplications
50004992
return self._response
50014993

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)