|
53 | 53 | BIG_FILE_THRESHOLD = 15 * 1024 * 1024 |
54 | 54 | ANNOTATION_CHUNK_SIZE_MB = 10 * 1024 * 1024 |
55 | 55 | URI_THRESHOLD = 4 * 1024 - 120 |
56 | | -nest_asyncio.apply() |
57 | 56 |
|
58 | 57 |
|
59 | 58 | @dataclass |
@@ -376,6 +375,7 @@ def execute(self): |
376 | 375 | len(items_to_upload), description="Uploading Annotations" |
377 | 376 | ) |
378 | 377 | try: |
| 378 | + nest_asyncio.apply() |
379 | 379 | asyncio.run(self.run_workers(items_to_upload)) |
380 | 380 | except Exception: |
381 | 381 | logger.debug(traceback.format_exc()) |
@@ -720,6 +720,7 @@ def execute(self): |
720 | 720 | except KeyError: |
721 | 721 | missing_annotations.append(name) |
722 | 722 | try: |
| 723 | + nest_asyncio.apply() |
723 | 724 | asyncio.run(self.run_workers(items_to_upload)) |
724 | 725 | except Exception: |
725 | 726 | logger.debug(traceback.format_exc()) |
@@ -917,6 +918,7 @@ def execute(self): |
917 | 918 | json.dump(annotation_json, annotation_file) |
918 | 919 | size = annotation_file.tell() |
919 | 920 | annotation_file.seek(0) |
| 921 | + nest_asyncio.apply() |
920 | 922 | if size > BIG_FILE_THRESHOLD: |
921 | 923 | uploaded = asyncio.run( |
922 | 924 | self._service_provider.annotations.upload_big_annotation( |
@@ -1109,6 +1111,7 @@ def execute(self): |
1109 | 1111 | ) |
1110 | 1112 | small_annotations = [x["name"] for x in items["small"]] |
1111 | 1113 | try: |
| 1114 | + nest_asyncio.apply() |
1112 | 1115 | annotations = asyncio.run( |
1113 | 1116 | self.run_workers(items["large"], small_annotations) |
1114 | 1117 | ) |
@@ -1355,14 +1358,6 @@ def download_annotation_classes(self, path: str): |
1355 | 1358 | def get_items_count(path: str): |
1356 | 1359 | return sum([len(files) for r, d, files in os.walk(path)]) |
1357 | 1360 |
|
1358 | | - @staticmethod |
1359 | | - def coroutine_wrapper(coroutine): |
1360 | | - loop = asyncio.new_event_loop() |
1361 | | - asyncio.set_event_loop(loop) |
1362 | | - count = loop.run_until_complete(coroutine) |
1363 | | - loop.close() |
1364 | | - return count |
1365 | | - |
1366 | 1361 | async def download_big_annotations(self, queue_idx, export_path): |
1367 | 1362 | while True: |
1368 | 1363 | cur_queue = self._big_file_queues[queue_idx] |
@@ -1463,6 +1458,7 @@ def execute(self): |
1463 | 1458 | if not folders: |
1464 | 1459 | folders.append(self._folder) |
1465 | 1460 | with concurrent.futures.ThreadPoolExecutor(max_workers=5) as executor: |
| 1461 | + nest_asyncio.apply() |
1466 | 1462 | futures = [] |
1467 | 1463 | for folder in folders: |
1468 | 1464 | if not self._item_names: |
|
0 commit comments