Skip to content

Commit 546d35d

Browse files
committed
use internal max and min values
1 parent b453ddc commit 546d35d

File tree

2 files changed

+9
-10
lines changed

2 files changed

+9
-10
lines changed

services/storage/src/simcore_service_storage/api/rpc/_async_jobs.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ async def result(
123123
exc_type = ""
124124
exc_msg = ""
125125
with log_catch(logger=_logger, reraise=False):
126-
task_error = TaskError.model_validate_json(_result)
126+
task_error = TaskError.model_validate(_result)
127127
exc_type = task_error.exc_type
128128
exc_msg = task_error.exc_msg
129129
raise JobError(job_id=job_id, exc_type=exc_type, exc_msg=exc_msg)

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

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
from enum import StrEnum, auto
2-
from typing import Any, Final, Self, TypeAlias
2+
from typing import Any, Self, TypeAlias
33
from uuid import UUID
44

55
from models_library.progress_bar import ProgressReport
@@ -9,9 +9,6 @@
99
TaskID: TypeAlias = str
1010
TaskUUID: TypeAlias = UUID
1111

12-
_MIN_PROGRESS: Final[float] = 0.0
13-
_MAX_PROGRESS: Final[float] = 100.0
14-
1512

1613
class TaskState(StrEnum):
1714
PENDING = auto()
@@ -36,13 +33,15 @@ def is_done(self) -> bool:
3633
@model_validator(mode="after")
3734
def _check_consistency(self) -> Self:
3835
value = self.progress_report.actual_value
36+
min_value = 0.0
37+
max_value = self.progress_report.total
3938

4039
valid_states = {
41-
TaskState.PENDING: value == _MIN_PROGRESS,
42-
TaskState.RUNNING: _MIN_PROGRESS <= value <= _MAX_PROGRESS,
43-
TaskState.SUCCESS: value == _MAX_PROGRESS,
44-
TaskState.ABORTED: value == _MAX_PROGRESS,
45-
TaskState.ERROR: value == _MAX_PROGRESS,
40+
TaskState.PENDING: value == min_value,
41+
TaskState.RUNNING: min_value <= value <= max_value,
42+
TaskState.SUCCESS: value == max_value,
43+
TaskState.ABORTED: value == max_value,
44+
TaskState.ERROR: value == max_value,
4645
}
4746

4847
if not valid_states.get(self.task_state, True):

0 commit comments

Comments
 (0)