Skip to content

Commit 414b3c9

Browse files
authored
Merge pull request #22 from superannotateai/folder-limitations
Fix copy images
2 parents b2bbf1b + 3863ac2 commit 414b3c9

File tree

1 file changed

+12
-5
lines changed

1 file changed

+12
-5
lines changed

superannotate/db/project_images.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -164,6 +164,7 @@ def _copy_images(
164164
json_req["destination_folder_id"] = destination_folder_id
165165
res = {}
166166
res['skipped'] = []
167+
res['completed'] = []
167168
for start_index in range(0, len(image_names), NUM_TO_SEND):
168169
json_req["image_names"] = image_names[start_index:start_index +
169170
NUM_TO_SEND]
@@ -179,6 +180,7 @@ def _copy_images(
179180
response.status_code, "Couldn't copy images " + response.text
180181
)
181182
res['skipped'] += response.json()['skipped']
183+
res['completed'] += response.json()['completed']
182184

183185
for image_name in image_names:
184186
_copy_annotations_and_metadata(
@@ -226,21 +228,26 @@ def copy_images(
226228
limit = _get_available_image_counts(
227229
destination_project, destination_project_folder
228230
)
229-
image_names = image_names[:limit]
231+
imgs_to_upload = image_names[:limit]
230232
res = _copy_images(
231233
(source_project, source_project_folder),
232-
(destination_project, destination_project_folder), image_names,
234+
(destination_project, destination_project_folder), imgs_to_upload,
233235
include_annotations, copy_annotation_status, copy_pin
234236
)
237+
uploaded_imgs = res['completed']
238+
skipped_imgs = [i for i in imgs_to_upload if i not in uploaded_imgs]
239+
240+
skipped_images_count = len(skipped_imgs) + len(image_names[limit:])
241+
235242
logger.info(
236243
"Copied images %s from %s to %s. Number of skipped images %s",
237-
image_names, source_project["name"] +
244+
uploaded_imgs, source_project["name"] +
238245
"" if source_project_folder is None else source_project["name"] + "/" +
239246
source_project_folder["name"], destination_project["name"] + ""
240247
if destination_project_folder is None else destination_project["name"] +
241-
"/" + destination_project_folder["name"], len(res["skipped"])
248+
"/" + destination_project_folder["name"], skipped_images_count
242249
)
243-
return res["skipped"]
250+
return skipped_imgs
244251

245252

246253
def delete_images(project, image_names):

0 commit comments

Comments
 (0)