File tree Expand file tree Collapse file tree 4 files changed +22
-44
lines changed
services/storage/src/simcore_service_storage Expand file tree Collapse file tree 4 files changed +22
-44
lines changed Original file line number Diff line number Diff line change 55
66from ...modules .celery ._celery_types import register_celery_types
77from ...modules .celery ._task import define_task
8- from ... modules . celery . tasks import export_data
8+ from ._data_export import data_export
99from ._paths import compute_path_size
1010
1111_logger = logging .getLogger (__name__ )
@@ -18,5 +18,5 @@ def setup_worker_tasks(app: Celery) -> None:
1818 logging .INFO ,
1919 msg = "Storage setup Worker Tasks" ,
2020 ):
21- define_task (app , export_data )
21+ define_task (app , data_export )
2222 define_task (app , compute_path_size )
Original file line number Diff line number Diff line change 1717from ...modules .celery import get_celery_client
1818from ...modules .datcore_adapter .datcore_adapter_exceptions import DatcoreAdapterError
1919from ...simcore_s3_dsm import SimcoreS3DataManager
20+ from .._worker_tasks ._data_export import data_export
2021
2122router = RPCRouter ()
2223
@@ -52,9 +53,9 @@ async def start_data_export(
5253 ) from err
5354
5455 task_uuid = await get_celery_client (app ).send_task (
55- "export_data" ,
56+ data_export . __name__ ,
5657 task_context = job_id_data .model_dump (),
57- files = data_export_start .file_and_folder_ids , # ANE: adapt here your signature
58+ files = data_export_start .file_and_folder_ids ,
5859 )
5960
6061 return AsyncJobGet (
Load Diff This file was deleted.
Original file line number Diff line number Diff line change 11import logging
22
3- from celery import Celery # type: ignore[import-untyped]
3+ from celery import Celery , Task # type: ignore[import-untyped]
4+ from common_library .async_tools import make_async
45from models_library .progress_bar import ProgressReport
56from servicelib .logging_utils import log_context
67
7- from .models import TaskID
8-
98_logger = logging .getLogger (__name__ )
109
1110
1211class CeleryTaskQueueWorker :
1312 def __init__ (self , celery_app : Celery ) -> None :
1413 self .celery_app = celery_app
1514
16- def set_task_progress (
17- self , task_name : str , task_id : TaskID , report : ProgressReport
18- ) -> None :
15+ @make_async ()
16+ def set_task_progress (self , task : Task , report : ProgressReport ) -> None :
17+ assert task .name # nosec
18+ task_name = task .name
19+ task_id = task .request .id
20+
1921 with log_context (
2022 _logger ,
2123 logging .DEBUG ,
2224 msg = f"Setting progress for { task_name } : { report .model_dump_json ()} " ,
2325 ):
24- self .celery_app .tasks [task_name ].update_state (
25- task_id = task_id ,
26- state = "RUNNING" ,
27- meta = report .model_dump (mode = "json" ),
28- )
26+ try :
27+ self .celery_app .tasks [task_name ].update_state (
28+ task_id = task_id ,
29+ state = "RUNNING" ,
30+ meta = report .model_dump (mode = "json" ),
31+ )
32+ except ValueError as e :
33+ if "task_id must not be empty. Got None instead." not in f"{ e } " :
34+ raise
You can’t perform that action at this time.
0 commit comments