Skip to content

Commit 068adad

Browse files
committed
Fix uploaded image info in threads
1 parent cd3754e commit 068adad

File tree

1 file changed

+22
-16
lines changed

1 file changed

+22
-16
lines changed

superannotate/db/projects.py

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -692,19 +692,29 @@ def __upload_images_to_aws_thread(
692692
uploaded_imgs_info[1].append(key)
693693
uploaded_imgs_info[2].append(images_array[2])
694694
if len(uploaded_imgs) >= 100:
695-
__create_image(
696-
uploaded_imgs_info[0], uploaded_imgs_info[1], project,
697-
annotation_status, prefix, uploaded_imgs_info[2]
698-
)
699-
uploaded[thread_id] += uploaded_imgs
695+
try:
696+
__create_image(
697+
uploaded_imgs_info[0], uploaded_imgs_info[1], project,
698+
annotation_status, prefix, uploaded_imgs_info[2]
699+
)
700+
except SABaseException as e:
701+
couldnt_upload[thread_id] += uploaded_imgs
702+
logger.warning(e)
703+
else:
704+
uploaded[thread_id] += uploaded_imgs
700705
uploaded_imgs = []
701706
uploaded_imgs_info = ([], [], [])
702707
tried_upload[thread_id].append(path)
703-
__create_image(
704-
uploaded_imgs_info[0], uploaded_imgs_info[1], project,
705-
annotation_status, prefix, uploaded_imgs_info[2]
706-
)
707-
uploaded[thread_id] += uploaded_imgs
708+
try:
709+
__create_image(
710+
uploaded_imgs_info[0], uploaded_imgs_info[1], project,
711+
annotation_status, prefix, uploaded_imgs_info[2]
712+
)
713+
except SABaseException as e:
714+
couldnt_upload[thread_id] += uploaded_imgs
715+
logger.warning(e)
716+
else:
717+
uploaded[thread_id] += uploaded_imgs
708718

709719

710720
def __create_image(
@@ -809,13 +819,9 @@ def upload_images_to_project(
809819
params = {
810820
'team_id': team_id,
811821
}
812-
uploaded = []
813-
for _ in range(_NUM_THREADS):
814-
uploaded.append([])
822+
uploaded = [[] for _ in range(_NUM_THREADS)]
815823
tried_upload = [[] for _ in range(_NUM_THREADS)]
816-
couldnt_upload = []
817-
for _ in range(_NUM_THREADS):
818-
couldnt_upload.append([])
824+
couldnt_upload = [[] for _ in range(_NUM_THREADS)]
819825
finish_event = threading.Event()
820826
chunksize = int(math.ceil(len(img_paths) / _NUM_THREADS))
821827
response = _api.send_request(

0 commit comments

Comments
 (0)