Skip to content

Commit ae5ac90

Browse files
committed
Updated duplicatinos detection behevior
1 parent ddd1269 commit ae5ac90

File tree

4 files changed

+31
-52
lines changed

4 files changed

+31
-52
lines changed

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2051,8 +2051,7 @@ def upload_images_to_project(
20512051
images_to_upload, duplicates = use_case.images_to_upload
20522052
if len(duplicates):
20532053
logger.warning(
2054-
"%s already existing images found that won't be uploaded.",
2055-
len(duplicates),
2054+
f"{len(duplicates)} duplicated images found that won't be uploaded."
20562055
)
20572056
logger.info(f"Uploading {len(images_to_upload)} images to project {project}.")
20582057
uploaded, failed_images, duplications = [], [], duplicates

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

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1020,6 +1020,7 @@ def filter_paths(self, paths: List[str]):
10201020
name_path_map[Path(path).name].append(path)
10211021

10221022
CHUNK_SIZE = UploadImagesToProject.LIST_NAME_CHUNK_SIZE
1023+
10231024
filtered_paths = []
10241025
duplicated_paths = []
10251026
for file_name in name_path_map:
@@ -1059,7 +1060,7 @@ def images_to_upload(self):
10591060

10601061
def execute(self):
10611062
if self.is_valid():
1062-
images_to_upload, duplications = self.images_to_upload
1063+
images_to_upload, _ = self.images_to_upload
10631064
images_to_upload = images_to_upload[: self.auth_data["availableImageCount"]]
10641065
if not images_to_upload:
10651066
return self._response
@@ -1082,6 +1083,7 @@ def execute(self):
10821083
yield
10831084

10841085
uploaded = []
1086+
duplications = [] # existing items
10851087
for i in range(0, len(uploaded_images), 100):
10861088
response = AttachFileUrlsUseCase(
10871089
project=self._project,

src/superannotate/logger.py

Lines changed: 0 additions & 35 deletions
This file was deleted.

tests/integration/test_image_upload.py

Lines changed: 27 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -97,17 +97,30 @@ def test_multiple_image_upload(self):
9797
self.assertEqual(len(existing_images), 0)
9898

9999
def test_multiple_image_upload_with_duplicates(self):
100-
(uploaded, could_not_upload, existing_images,) = sa.upload_images_to_project(
101-
self.PROJECT_NAME,
102-
[
103-
f"{self.folder_path}/example_image_1.jpg",
104-
f"{self.folder_path}/example_image_1.jpg",
105-
f"{self.folder_path}/example_image_1.jpg",
106-
f"{self.folder_path}/example_image_3.jpg",
107-
f"{self.folder_path}/example_image_4.jpg",
108-
],
109-
annotation_status="InProgress",
110-
)
111-
self.assertEqual(len(uploaded), 3)
112-
self.assertEqual(len(could_not_upload), 0)
113-
self.assertEqual(len(existing_images), 2)
100+
with self.assertLogs("sa", level="INFO") as mock_log:
101+
(
102+
uploaded,
103+
could_not_upload,
104+
existing_images,
105+
) = sa.upload_images_to_project(
106+
self.PROJECT_NAME,
107+
[
108+
f"{self.folder_path}/example_image_1.jpg",
109+
f"{self.folder_path}/example_image_1.jpg",
110+
f"{self.folder_path}/example_image_1.jpg",
111+
f"{self.folder_path}/example_image_3.jpg",
112+
f"{self.folder_path}/example_image_4.jpg",
113+
],
114+
annotation_status="InProgress",
115+
)
116+
assert (
117+
mock_log.records[0].msg
118+
== "2 duplicated images found that won't be uploaded."
119+
)
120+
assert (
121+
mock_log.records[1].msg
122+
== "Uploading 3 images to project test_multiple_image_upload."
123+
)
124+
self.assertEqual(len(uploaded), 3)
125+
self.assertEqual(len(could_not_upload), 0)
126+
self.assertEqual(len(existing_images), 2)

0 commit comments

Comments
 (0)