Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
from enum import StrEnum, auto
from typing import Any, Final, Protocol, Self, TypeAlias
from typing import Any, Final, Protocol, TypeAlias
from uuid import UUID

from models_library.progress_bar import ProgressReport
Expand Down Expand Up @@ -56,26 +56,6 @@ class TaskStatus(BaseModel):
def is_done(self) -> bool:
return self.task_state in _TASK_DONE

# @model_validator(mode="after") This does not work MB
def _check_consistency(self) -> Self:
value = self.progress_report.actual_value
min_value = 0.0
max_value = self.progress_report.total

valid_states = {
TaskState.PENDING: value == min_value,
TaskState.RUNNING: min_value <= value <= max_value,
TaskState.SUCCESS: value == max_value,
TaskState.ABORTED: value == max_value,
TaskState.ERROR: value == max_value,
}

if not valid_states.get(self.task_state, True):
msg = f"Inconsistent progress actual value for state={self.task_state}: {value}"
raise ValueError(msg)

return self


class TaskError(BaseModel):
exc_type: str
Expand Down
Loading