Skip to content

Commit 0ec94b6

Browse files
update
1 parent c56b8b7 commit 0ec94b6

File tree

3 files changed

+16
-7
lines changed

3 files changed

+16
-7
lines changed

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

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,12 @@ def wrapper(task: Task, *args, **kwargs):
4040
exc_message = f"{exc}"
4141
exc_traceback = traceback.format_exc().split('\n')
4242

43+
_logger.exception(
44+
"Task %s failed with exception: %s",
45+
task.request.id,
46+
exc_message,
47+
)
48+
4349
task.update_state(
4450
state="ERROR",
4551
meta=TaskError(

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

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,9 @@
3434
_CELERY_TASK_ID_KEY_SEPARATOR: Final[str] = ":"
3535
_CELERY_TASK_ID_KEY_ENCODING = "utf-8"
3636

37+
_MIN_PROGRESS_VALUE = 0.0
38+
_MAX_PROGRESS_VALUE = 100.0
39+
3740

3841
def _build_context_prefix(task_context: TaskContext) -> list[str]:
3942
return [f"{task_context[key]}" for key in sorted(task_context)]
@@ -97,8 +100,8 @@ def _get_progress_report(
97100
TaskState.ERROR,
98101
TaskState.SUCCESS,
99102
):
100-
return ProgressReport(actual_value=100.0)
101-
return ProgressReport(actual_value=0.0)
103+
return ProgressReport(actual_value=_MAX_PROGRESS_VALUE)
104+
return ProgressReport(actual_value=_MIN_PROGRESS_VALUE)
102105

103106
def _get_state(self, task_context: TaskContext, task_uuid: TaskUUID) -> TaskState:
104107
task_id = _build_task_id(task_context, task_uuid)

services/storage/tests/unit/modules/celery/test_celery.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -96,15 +96,15 @@ async def test_sumitting_task_calling_async_function_results_with_success_state(
9696
stop=stop_after_delay(30),
9797
):
9898
with attempt:
99-
progress = await celery_client.get_task_status(task_context, task_uuid)
100-
assert progress.task_state == TaskState.SUCCESS
99+
status = await celery_client.get_task_status(task_context, task_uuid)
100+
assert status.task_state == TaskState.SUCCESS
101101

102-
assert (
103-
await celery_client.get_task_result(task_context, task_uuid)
104-
) == "archive.zip"
105102
assert (
106103
await celery_client.get_task_status(task_context, task_uuid)
107104
).task_state == TaskState.SUCCESS
105+
assert (
106+
await celery_client.get_task_result(task_context, task_uuid)
107+
) == "archive.zip"
108108

109109

110110
@pytest.mark.usefixtures("celery_worker")

0 commit comments

Comments
 (0)