Skip to content

Commit 405955c

Browse files
committed
adressing PR change requests
1 parent 8ba0754 commit 405955c

File tree

2 files changed

+31
-42
lines changed

2 files changed

+31
-42
lines changed

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

Lines changed: 16 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1094,34 +1094,20 @@ async def download_small_annotations(self, queue_idx, export_path):
10941094
postfix = self.get_postfix()
10951095
while item is not None:
10961096
item = await cur_queue.get()
1097-
if not item:
1098-
await self._backend_client.download_small_annotations(
1099-
team_id=self._project.team_id,
1100-
project_id=self._project.id,
1101-
folder_id=self._folder.uuid,
1102-
items=items,
1103-
reporter=self.reporter,
1104-
download_path=f"{export_path}{'/' + self._folder.name if not self._folder.is_root else ''}",
1105-
postfix=postfix,
1106-
callback=self._callback,
1107-
)
1108-
await cur_queue.put(None)
1109-
break
1097+
if item:
1098+
items.append(item)
11101099

1111-
items.append(item)
1112-
if len(items) == max_chunk_size:
1113-
await self._backend_client.download_small_annotations(
1114-
team_id=self._project.team_id,
1115-
project_id=self._project.id,
1116-
folder_id=self._folder.uuid,
1117-
items=items,
1118-
reporter=self.reporter,
1119-
download_path=f"{export_path}{'/' + self._folder.name if not self._folder.is_root else ''}",
1120-
postfix=postfix,
1121-
callback=self._callback,
1122-
)
1123-
items = []
11241100

1101+
await self._backend_client.download_small_annotations(
1102+
team_id=self._project.team_id,
1103+
project_id=self._project.id,
1104+
folder_id=self._folder.uuid,
1105+
items=items,
1106+
reporter=self.reporter,
1107+
download_path=f"{export_path}{'/' + self._folder.name if not self._folder.is_root else ''}",
1108+
postfix=postfix,
1109+
callback=self._callback,
1110+
)
11251111

11261112
async def distribute_to_queues(self, item_names, sm_queue_id, l_queue_id, folder_id):
11271113

@@ -1215,11 +1201,11 @@ def execute(self):
12151201
new_export_path = export_path
12161202
if folder.name != 'root':
12171203
new_export_path += f'/{folder.name}'
1218-
executor.submit(self.per_folder_execute, item_names, folder.uuid, new_export_path)
1219-
1204+
future = executor.submit(self.per_folder_execute, item_names, folder.uuid, new_export_path)
1205+
futures.append(future)
12201206

1221-
for future in concurrent.futures.as_completed(futures):
1222-
print("asd")
1207+
for future in concurrent.futures.as_completed(futures):
1208+
pass
12231209

12241210

12251211
self.reporter.stop_spinner()

src/superannotate/lib/infrastructure/services.py

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,7 @@ class BaseBackendService(SuperannotateServiceProvider):
5757
PAGINATE_BY = 100
5858
LIMIT = 100
5959
MAX_ITEMS_COUNT = 50 * 1000
60+
ASSETS_PROVIDER_VERSION = 'v2'
6061

6162
"""
6263
Base service class
@@ -80,12 +81,14 @@ def __init__(
8081
self._testing = testing
8182
self.get_session()
8283

83-
def get_assets_provider_url(self, version = 'v2'):
84+
85+
@property
86+
def assets_provider_url(self):
8487
if self.api_url != constants.BACKEND_URL:
85-
return f"https://assets-provider.devsuperannotate.com/api/{version}/"
86-
return f"https://assets-provider.superannotate.com/api/{version}/"
88+
return f"https://assets-provider.devsuperannotate.com/api/{self.ASSETS_PROVIDER_VERSION}/"
89+
return f"https://assets-provider.superannotate.com/api/{self.ASSETS_PROVIDER_VERSION}/"
90+
8791

88-
assets_provider_url = property(get_assets_provider_url)
8992

9093

9194
@lru_cache(maxsize=32)
@@ -315,8 +318,9 @@ class SuperannotateBackendService(BaseBackendService):
315318
URL_START_FILE_SYNC = "items/{item_id}/annotations/sync"
316319
URL_START_FILE_SYNC_STATUS = "items/{item_id}/annotations/sync/status"
317320
URL_CLASSIFY_ITEM_SIZE = "items/annotations/download/method"
318-
URL_SYNC_LARGE_ANNOTATION = "items/{}/annotations/sync"
319-
URL_SYNC_LARGE_ANNOTATION_STATUS = "items/{}/annotations/sync/status"
321+
URL_SYNC_LARGE_ANNOTATION = "items/{item_id}/annotations/sync"
322+
URL_SYNC_LARGE_ANNOTATION_STATUS = "items/{item_id}/annotations/sync/status"
323+
URL_DOWNLOAD_LARGE_ANNOTATION = "items/{item_id}/annotations/download"
320324

321325
def upload_priority_scores(
322326
self, team_id: int, project_id: int, folder_id: int, priorities: list
@@ -1170,7 +1174,7 @@ async def download_big_annotation(
11701174
"version":"V1.00"
11711175
}
11721176

1173-
url = urljoin(self.get_assets_provider_url('v1.01'), f'items/{item_id}/annotations/download')
1177+
url = urljoin(self.assets_provider_url, self.URL_DOWNLOAD_LARGE_ANNOTATION.format(item_id=item_id))
11741178

11751179
sync_params = {
11761180
"team_id": team_id,
@@ -1182,7 +1186,7 @@ async def download_big_annotation(
11821186
"desired_source":"secondary"
11831187
}
11841188

1185-
sync_url = urljoin(self.get_assets_provider_url('v2'), self.URL_SYNC_LARGE_ANNOTATION.format(item_id))
1189+
sync_url = urljoin(self.assets_provider_url, self.URL_SYNC_LARGE_ANNOTATION.format(item_id=item_id))
11861190

11871191
res = self._request(
11881192
url = sync_url,
@@ -1196,7 +1200,7 @@ async def download_big_annotation(
11961200

11971201
synced = False
11981202

1199-
sync_status_url = urljoin(self.get_assets_provider_url('v2'), self.URL_SYNC_LARGE_ANNOTATION_STATUS.format(item_id))
1203+
sync_status_url = urljoin(self.assets_provider_url, self.URL_SYNC_LARGE_ANNOTATION_STATUS.format(item_id=item_id))
12001204
while synced != 'SUCCESS':
12011205
synced = self._request(
12021206
url = sync_status_url,
@@ -1207,7 +1211,7 @@ async def download_big_annotation(
12071211

12081212

12091213
async with aiohttp.ClientSession(
1210-
connector=aiohttp.TCPConnector(ssl=False), headers = self.default_headers
1214+
connector=aiohttp.TCPConnector(ssl=False), headers = self.default_headers,
12111215
) as session:
12121216

12131217
start_response = await session.post(
@@ -1247,7 +1251,6 @@ async def download_small_annotations(
12471251
callback=callback,
12481252
)
12491253

1250-
Path(download_path).mkdir(exist_ok=True, parents=True)
12511254
return await handler.download_data(
12521255
url=urljoin(self.assets_provider_url, self.URL_GET_ANNOTATIONS),
12531256
data=items,
@@ -1592,7 +1595,7 @@ def sort_items_by_size(self, item_names, team_id, project_id, folder_id):
15921595
}
15931596

15941597
url = urljoin(
1595-
self.get_assets_provider_url('v2'), 'items/annotations/download/method'
1598+
self.assets_provider_url, self.URL_CLASSIFY_ITEM_SIZE
15961599
)
15971600

15981601
body = {

0 commit comments

Comments
 (0)