Skip to content

Commit 1c0d5ab

Browse files
author
Andrei Neagu
committed
connected export job
1 parent ed60ba7 commit 1c0d5ab

File tree

6 files changed

+42
-105
lines changed

6 files changed

+42
-105
lines changed
Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
1+
import logging
2+
from typing import cast
3+
4+
from celery import Task # type: ignore[import-untyped]
5+
from models_library.progress_bar import ProgressReport
6+
from models_library.projects_nodes_io import StorageFileID
7+
from models_library.users import UserID
8+
9+
from ...dsm import get_dsm_provider
10+
from ...modules.celery.utils import get_celery_worker, get_fastapi_app
11+
from ...simcore_s3_dsm import SimcoreS3DataManager
12+
from ._tqdm_utils import get_export_progress, set_absolute_progress
13+
14+
_logger = logging.getLogger(__name__)
15+
16+
17+
async def data_export(
18+
task: Task,
19+
*,
20+
user_id: UserID,
21+
paths_to_export: list[StorageFileID],
22+
) -> StorageFileID:
23+
_logger.info("Exporting for user '%s' files: %s", user_id, paths_to_export)
24+
25+
dsm = cast(
26+
SimcoreS3DataManager,
27+
get_dsm_provider(get_fastapi_app(task.app)).get(
28+
SimcoreS3DataManager.get_location_id()
29+
),
30+
)
31+
32+
with get_export_progress(total=1, description=f"{task.name}") as pbar:
33+
34+
async def _progress_cb(report: ProgressReport) -> None:
35+
set_absolute_progress(pbar, current_progress=report.actual_value)
36+
await get_celery_worker(task.app).set_task_progress(task, report)
37+
38+
return await dsm.create_s3_export(
39+
user_id, paths_to_export, progress_cb=_progress_cb
40+
)

β€Žservices/storage/src/simcore_service_storage/api/_worker_tasks/_export_task.pyβ€Ž

Lines changed: 0 additions & 31 deletions
This file was deleted.

β€Žservices/storage/src/simcore_service_storage/api/celery/__init__.pyβ€Ž

Whitespace-only changes.

β€Žservices/storage/src/simcore_service_storage/api/celery/_export_task.pyβ€Ž

Lines changed: 0 additions & 73 deletions
This file was deleted.

β€Žservices/storage/src/simcore_service_storage/api/rpc/_data_export.pyβ€Ž

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,8 @@ async def start_data_export(
5555
task_uuid = await get_celery_client(app).send_task(
5656
data_export.__name__,
5757
task_context=job_id_data.model_dump(),
58-
files=data_export_start.file_and_folder_ids,
58+
user_id=job_id_data.user_id,
59+
paths_to_export=data_export_start.file_and_folder_ids,
5960
)
6061

6162
return AsyncJobGet(

0 commit comments

Comments
Β (0)