Skip to content

Commit 9a99f12

Browse files
Vaghinak BasentsyanVaghinak Basentsyan
authored andcommitted
tod
1 parent eb2378a commit 9a99f12

File tree

4 files changed

+25
-13
lines changed

4 files changed

+25
-13
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3566,6 +3566,8 @@ def _upload_s3_image(image_path: str):
35663566
)
35673567
upload_method = _upload_s3_image if from_s3_bucket else _upload_local_image
35683568

3569+
logger.info(f"Uploading {len(images_to_upload)} images to project.")
3570+
35693571
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
35703572
results = [
35713573
executor.submit(upload_method, image_path)
@@ -3582,8 +3584,6 @@ def _upload_s3_image(image_path: str):
35823584
uploaded = []
35833585
duplicates = []
35843586

3585-
logger.info("Uploading %s images to project.", len(images_to_upload))
3586-
35873587
for i in range(0, len(uploaded_image_entities), 500):
35883588
response = controller.upload_images(
35893589
project_name=project_name,
@@ -3592,7 +3592,7 @@ def _upload_s3_image(image_path: str):
35923592
annotation_status=annotation_status,
35933593
)
35943594
attachments, duplications = response.data
3595-
uploaded.extend(attachments)
3595+
uploaded.extend([attachment["name"] for attachment in attachments])
35963596
duplicates.extend(duplications)
35973597

35983598
if len(duplicates):

src/superannotate/lib/core/usecases.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5256,13 +5256,15 @@ def __init__(
52565256
def execute(self):
52575257
res = []
52585258
for i in range(0, len(self._images), self._chunk_size):
5259-
images = self._service.get_bulk_images(
5259+
response = self._service.get_bulk_images(
52605260
project_id=self._project_id,
52615261
team_id=self._team_id,
52625262
folder_id=self._folder_id,
5263-
images=self._images[i : i + self._chunk_size],
5263+
images=self._images[i : i + self._chunk_size], # noqa: E203
52645264
)
5265-
res += [ImageEntity.from_dict(**image) for image in images] # noqa: E203
5265+
if "error" in response:
5266+
raise AppException(response["error"])
5267+
res += [ImageEntity.from_dict(**image) for image in response]
52665268
self._response.data = res
52675269
return self._response
52685270

tests/integration/test_attach_document_urls.py

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,6 @@ def test_attach_image_urls(self):
4444
self.assertEqual(len(could_not_upload), 0)
4545
self.assertEqual(len(existing_images), 1)
4646

47-
4847
uploaded, could_not_upload, existing_images = sa.attach_image_urls_to_project(
4948
self.PROJECT_NAME,
5049
os.path.join(dirname(dirname(__file__)), self.PATH_TO_URLS),
@@ -69,7 +68,6 @@ def test_attach_image_urls(self):
6968
self.assertEqual(len(could_not_upload), 0)
7069
self.assertEqual(len(existing_images), 1)
7170

72-
7371
uploaded, could_not_upload, existing_images = sa.attach_video_urls_to_project(
7472
self.PROJECT_NAME,
7573
os.path.join(dirname(dirname(__file__)), self.PATH_TO_URLS),

tests/integration/test_duplicate_image_upload.py

Lines changed: 17 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -27,8 +27,15 @@ def test_single_image_upload(self):
2727
uploaded,
2828
could_not_upload,
2929
existing_images,
30-
) = sa.upload_images_from_folder_to_project(
31-
self.PROJECT_NAME, self.folder_path, annotation_status="InProgress",
30+
) = sa.upload_images_to_project(
31+
self.PROJECT_NAME,
32+
[
33+
f"{self.folder_path}/example_image_1.jpg",
34+
f"{self.folder_path}/example_image_2.jpg",
35+
f"{self.folder_path}/example_image_3.jpg",
36+
f"{self.folder_path}/example_image_4.jpg"
37+
],
38+
annotation_status="InProgress",
3239
)
3340
self.assertEqual(len(uploaded), 4)
3441
self.assertEqual(len(could_not_upload), 0)
@@ -38,8 +45,14 @@ def test_single_image_upload(self):
3845
uploaded,
3946
could_not_upload,
4047
existing_images,
41-
) = sa.upload_images_from_folder_to_project(
42-
self.PROJECT_NAME, self.folder_path, annotation_status="InProgress",
48+
) = sa.upload_images_to_project(
49+
self.PROJECT_NAME, [
50+
f"{self.folder_path}/example_image_1.jpg",
51+
f"{self.folder_path}/example_image_2.jpg",
52+
f"{self.folder_path}/example_image_3.jpg",
53+
f"{self.folder_path}/example_image_4.jpg"
54+
],
55+
annotation_status="InProgress",
4356
)
4457
self.assertEqual(len(uploaded), 0)
4558
self.assertEqual(len(could_not_upload), 0)
@@ -48,7 +61,6 @@ def test_single_image_upload(self):
4861
uploaded, could_not_upload, existing_images = sa.upload_images_to_project(
4962
self.PROJECT_NAME, [f"{self.folder_path}/dd.jpg"]
5063
)
51-
5264
self.assertEqual(len(uploaded), 0)
5365
self.assertEqual(len(could_not_upload), 1)
5466
self.assertEqual(len(existing_images), 0)

0 commit comments

Comments
 (0)