Skip to content

Commit 7462c0b

Browse files
committed
Fixed annotations download
1 parent 8820ff6 commit 7462c0b

File tree

3 files changed

+11
-5
lines changed

3 files changed

+11
-5
lines changed

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

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1386,11 +1386,11 @@ async def download_small_annotations(
13861386
)
13871387

13881388
async def distribute_to_queues(
1389-
self, item_names, sm_queue_id, l_queue_id, folder_id
1389+
self, item_names, sm_queue_id, l_queue_id, folder: FolderEntity
13901390
):
13911391
try:
13921392
resp = self._service_provider.annotations.sort_items_by_size(
1393-
project=self._project, folder=self._folder, item_names=item_names
1393+
project=self._project, folder=folder, item_names=item_names
13941394
)
13951395

13961396
for item in resp["large"]:
@@ -1410,7 +1410,7 @@ async def run_workers(self, item_names, folder: FolderEntity, export_path):
14101410
big_file_queue_idx = len(self._big_file_queues) - 1
14111411
res = await asyncio.gather(
14121412
self.distribute_to_queues(
1413-
item_names, small_file_queue_idx, big_file_queue_idx, folder.id
1413+
item_names, small_file_queue_idx, big_file_queue_idx, folder
14141414
),
14151415
self.download_big_annotations(big_file_queue_idx, export_path),
14161416
self.download_big_annotations(big_file_queue_idx, export_path),

src/superannotate/lib/infrastructure/services/http_client.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,8 @@
1616
from lib.core.exceptions import AppException
1717
from lib.core.service_types import ServiceResponse
1818
from lib.core.serviceproviders import BaseClient
19+
from requests.adapters import HTTPAdapter
20+
from requests.adapters import Retry
1921
from superannotate import __version__
2022

2123
logger = logging.getLogger("sa")
@@ -39,7 +41,11 @@ def __init__(self, api_url: str, token: str, verify_ssl: bool = True):
3941
def _get_session(self, thread_id, ttl=None): # noqa
4042
del ttl
4143
del thread_id
44+
retries = Retry(total=3, backoff_factor=0.1, status_forcelist=[502, 503, 504])
45+
4246
session = requests.Session()
47+
session.mount("http://", HTTPAdapter(max_retries=retries)) # noqa
48+
session.mount("https://", HTTPAdapter(max_retries=retries))
4349
session.headers.update(self.default_headers)
4450
return session
4551

tests/integration/annotations/test_upload_annotations_from_folder_to_project.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,8 @@
22
from pathlib import Path
33

44
from src.superannotate import SAClient
5-
from tests.integration.base import BaseTestCase
65
from tests import DATA_SET_PATH
6+
from tests.integration.base import BaseTestCase
77

88
sa = SAClient()
99

@@ -33,7 +33,7 @@ def big_annotations_folder_path(self):
3333
@property
3434
def large_annotations_folder_path(self):
3535
return os.path.join(DATA_SET_PATH, self.TEST_LARGE_FOLDER_PATH)
36-
36+
3737
def test_annotation_folder_upload_download(self):
3838
self._attach_items()
3939
sa.create_annotation_classes_from_classes_json(

0 commit comments

Comments
 (0)