Skip to content

Commit 99288d1

Browse files
committed
Fix folders download
1 parent 3375e3e commit 99288d1

File tree

3 files changed

+27
-4
lines changed

3 files changed

+27
-4
lines changed

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

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1443,8 +1443,6 @@ def execute(self):
14431443
folders = self._service_provider.folders.list(
14441444
Condition("project_id", self._project.id, EQ)
14451445
).data
1446-
folders.append(self._folder)
1447-
14481446
if not folders:
14491447
folders.append(self._folder)
14501448
with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor:

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -254,7 +254,7 @@ def execute(self):
254254
] = self._service_provider.annotation_classes.create_multiple(
255255
entity, [annotation_class]
256256
)
257-
self._response.data.classes = self._project.classes
257+
data["classes"] = self._project.classes
258258
if self._project.workflows:
259259
set_workflow_use_case = SetWorkflowUseCase(
260260
service_provider=self._service_provider,

tests/integration/annotations/test_download_annotations.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
import json
22
import os
3+
import glob
34
import tempfile
45
from pathlib import Path
56

@@ -70,4 +71,28 @@ def test_download_empty_annotations_from_folders(self):
7071
)
7172
with tempfile.TemporaryDirectory() as temp_dir:
7273
annotations_path = sa.download_annotations(f"{self.PROJECT_NAME}", temp_dir)
73-
self.assertEqual(len(os.listdir(annotations_path)), 1)
74+
self.assertEqual(len(os.listdir(annotations_path)), 1)
75+
76+
@pytest.mark.flaky(reruns=3)
77+
def test_download_annotations_from_folders(self):
78+
sa.create_folder(self.PROJECT_NAME, self.FOLDER_NAME)
79+
sa.create_folder(self.PROJECT_NAME, self.FOLDER_NAME_2)
80+
sa.create_annotation_classes_from_classes_json(
81+
self.PROJECT_NAME, f"{self.folder_path}/classes/classes.json"
82+
)
83+
sa.attach_items(
84+
f'{self.PROJECT_NAME}/{self.FOLDER_NAME}',
85+
[{"name": f"example_image_{i}.jpg", "url": f"url_{i}"} for i in range(1, 5)] # noqa
86+
)
87+
sa.attach_items(
88+
self.PROJECT_NAME,
89+
[{"name": f"example_image_{i}.jpg", "url": f"url_{i}"} for i in range(1, 19)] # noqa
90+
)
91+
sa.attach_items(
92+
f'{self.PROJECT_NAME}/{self.FOLDER_NAME_2}',
93+
[{"name": f"example_image_{i}.jpg", "url": f"url_{i}"} for i in range(1, 10)] # noqa
94+
)
95+
with tempfile.TemporaryDirectory() as temp_dir:
96+
annotations_path = sa.download_annotations(self.PROJECT_NAME, temp_dir, recursive=True)
97+
count = len([i for i in glob.iglob(annotations_path + '**/**', recursive=True)])
98+
assert count == 31 + 5 # folder names and classes

0 commit comments

Comments
 (0)