Skip to content

Commit d1a6791

Browse files
committed
Merge branch 'develop' of https://github.com/superannotateai/superannotate-python-sdk into download_export
2 parents a687ce2 + 9a99f12 commit d1a6791

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
@@ -3552,6 +3552,8 @@ def _upload_s3_image(image_path: str):
35523552
)
35533553
upload_method = _upload_s3_image if from_s3_bucket else _upload_local_image
35543554

3555+
logger.info(f"Uploading {len(images_to_upload)} images to project.")
3556+
35553557
with concurrent.futures.ThreadPoolExecutor(max_workers=10) as executor:
35563558
results = [
35573559
executor.submit(upload_method, image_path)
@@ -3568,8 +3570,6 @@ def _upload_s3_image(image_path: str):
35683570
uploaded = []
35693571
duplicates = []
35703572

3571-
logger.info("Uploading %s images to project.", len(images_to_upload))
3572-
35733573
for i in range(0, len(uploaded_image_entities), 500):
35743574
response = controller.upload_images(
35753575
project_name=project_name,
@@ -3578,7 +3578,7 @@ def _upload_s3_image(image_path: str):
35783578
annotation_status=annotation_status,
35793579
)
35803580
attachments, duplications = response.data
3581-
uploaded.extend(attachments)
3581+
uploaded.extend([attachment["name"] for attachment in attachments])
35823582
duplicates.extend(duplications)
35833583

35843584
if len(duplicates):

src/superannotate/lib/core/usecases.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5294,13 +5294,15 @@ def __init__(
52945294
def execute(self):
52955295
res = []
52965296
for i in range(0, len(self._images), self._chunk_size):
5297-
images = self._service.get_bulk_images(
5297+
response = self._service.get_bulk_images(
52985298
project_id=self._project_id,
52995299
team_id=self._team_id,
53005300
folder_id=self._folder_id,
5301-
images=self._images[i : i + self._chunk_size],
5301+
images=self._images[i : i + self._chunk_size], # noqa: E203
53025302
)
5303-
res += [ImageEntity.from_dict(**image) for image in images] # noqa: E203
5303+
if "error" in response:
5304+
raise AppException(response["error"])
5305+
res += [ImageEntity.from_dict(**image) for image in response]
53045306
self._response.data = res
53055307
return self._response
53065308

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)