Skip to content

Commit ed60ba7

Browse files
author
Andrei Neagu
committed
fixed task
1 parent e5859f6 commit ed60ba7

File tree

1 file changed

+31
-0
lines changed
  • services/storage/src/simcore_service_storage/api/_worker_tasks

1 file changed

+31
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
import asyncio
2+
import logging
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 servicelib.logging_utils import log_context
8+
9+
from ...modules.celery.utils import get_celery_worker
10+
11+
_logger = logging.getLogger(__name__)
12+
13+
14+
async def export_data(task: Task, files: list[StorageFileID]):
15+
await get_celery_worker(task.app).set_task_progress(
16+
task, ProgressReport(actual_value=0.1)
17+
)
18+
19+
_logger.info("Exporting files: %s", files)
20+
for n, file in enumerate(files, start=1):
21+
with log_context(
22+
_logger,
23+
logging.INFO,
24+
msg=f"Exporting {file=} ({n}/{len(files)})",
25+
):
26+
assert task.name
27+
await get_celery_worker(task.app).set_task_progress(
28+
task, ProgressReport(actual_value=n / len(files) * 100)
29+
)
30+
await asyncio.sleep(10)
31+
return "done"

0 commit comments

Comments
 (0)