Skip to content

Commit 948090c

Browse files
committed
further cleanup of ProgressReport
1 parent 546d35d commit 948090c

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@
3636
_CELERY_TASK_ID_KEY_ENCODING = "utf-8"
3737

3838
_MIN_PROGRESS_VALUE = 0.0
39-
_MAX_PROGRESS_VALUE = 100.0
39+
_MAX_PROGRESS_VALUE = 1.0
4040

4141

4242
def _build_context_prefix(task_context: TaskContext) -> list[str]:
@@ -99,8 +99,12 @@ def _get_progress_report(
9999
TaskState.ERROR,
100100
TaskState.SUCCESS,
101101
):
102-
return ProgressReport(actual_value=_MAX_PROGRESS_VALUE)
103-
return ProgressReport(actual_value=_MIN_PROGRESS_VALUE)
102+
return ProgressReport(
103+
actual_value=_MAX_PROGRESS_VALUE, total=_MAX_PROGRESS_VALUE
104+
)
105+
return ProgressReport(
106+
actual_value=_MIN_PROGRESS_VALUE, total=_MAX_PROGRESS_VALUE
107+
)
104108

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

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

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@
1313

1414
def export_data(task: Task, files: list[StorageFileID]):
1515
_logger.info("Exporting files: %s", files)
16+
assert len(files) > 0
1617
for n, file in enumerate(files, start=1):
1718
with log_context(
1819
_logger,
@@ -23,7 +24,7 @@ def export_data(task: Task, files: list[StorageFileID]):
2324
get_celery_worker(task.app).set_task_progress(
2425
task_name=task.name,
2526
task_id=task.request.id,
26-
report=ProgressReport(actual_value=n / len(files) * 100),
27+
report=ProgressReport(actual_value=n, total=len(files)),
2728
)
2829
time.sleep(10)
2930
return "done"

0 commit comments

Comments
 (0)