Skip to content

Commit 9f021e3

Browse files
author
Andrei Neagu
committed
revert interfaces
1 parent 1aa630e commit 9f021e3

File tree

4 files changed

+12
-10
lines changed

4 files changed

+12
-10
lines changed

services/storage/src/simcore_service_storage/api/_worker_tasks/_data_export.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,10 @@ async def data_export(
3333

3434
async def _progress_cb(report: ProgressReport) -> None:
3535
set_tqdm_absolute_progress(pbar, report)
36-
await get_celery_worker(task.app).set_task_progress(task, task_id, report)
36+
assert task.name # nosec
37+
await get_celery_worker(task.app).set_task_progress(
38+
task.name, task_id, report
39+
)
3740

3841
async with ProgressBarData(
3942
num_steps=1, description="data export", progress_report_cb=_progress_cb

services/storage/src/simcore_service_storage/api/_worker_tasks/_simcore_s3.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ async def _task_progress_cb(
2222
) -> None:
2323
worker = get_celery_worker(task.app)
2424
assert task.name # nosec
25-
await worker.set_task_progress(task=task, task_id=task_id, report=report)
25+
await worker.set_task_progress(task.name, task_id, report)
2626

2727

2828
async def deep_copy_files_from_project(

services/storage/src/simcore_service_storage/modules/celery/worker.py

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import logging
22

3-
from celery import Celery, Task # type: ignore[import-untyped]
3+
from celery import Celery # type: ignore[import-untyped]
44
from common_library.async_tools import make_async
55
from models_library.progress_bar import ProgressReport
66
from servicelib.logging_utils import log_context
@@ -16,11 +16,8 @@ def __init__(self, celery_app: Celery) -> None:
1616

1717
@make_async()
1818
def set_task_progress(
19-
self, task: Task, task_id: TaskID, report: ProgressReport
19+
self, task_name: str, task_id: TaskID, report: ProgressReport
2020
) -> None:
21-
assert task.name # nosec
22-
task_name = task.name
23-
2421
with log_context(
2522
_logger,
2623
logging.DEBUG,

services/storage/tests/unit/test_modules_celery.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,9 @@ def celery_client(
4646
return get_celery_client(initialized_app)
4747

4848

49-
async def _async_archive(celery_app: Celery, task: Task, files: list[str]) -> str:
49+
async def _async_archive(
50+
celery_app: Celery, task_name: str, task_id: str, files: list[str]
51+
) -> str:
5052
worker_client = get_celery_worker(celery_app)
5153

5254
def sleep_for(seconds: float) -> None:
@@ -55,7 +57,7 @@ def sleep_for(seconds: float) -> None:
5557
for n, file in enumerate(files, start=1):
5658
with log_context(_logger, logging.INFO, msg=f"Processing file {file}"):
5759
await worker_client.set_task_progress(
58-
task, task.id, ProgressReport(actual_value=n / len(files) * 10)
60+
task_name, task_id, ProgressReport(actual_value=n / len(files) * 10)
5961
)
6062
await asyncio.get_event_loop().run_in_executor(None, sleep_for, 1)
6163

@@ -66,7 +68,7 @@ def sync_archive(task: Task, files: list[str]) -> str:
6668
assert task.name
6769
_logger.info("Calling async_archive")
6870
return asyncio.run_coroutine_threadsafe(
69-
_async_archive(task.app, task, files),
71+
_async_archive(task.app, task.name, task.request.id, files),
7072
get_event_loop(get_fastapi_app(task.app)),
7173
).result()
7274

0 commit comments

Comments
 (0)