Skip to content

Commit 4dd373c

Browse files
committed
refactor
1 parent 76c0932 commit 4dd373c

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

packages/models-library/src/models_library/projects_state.py

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
"""
44

55
from enum import Enum, unique
6-
from typing import Annotated, Self, TypeAlias
6+
from typing import Annotated, Final, Self, TypeAlias
77

88
from pydantic import (
99
BaseModel,
@@ -65,6 +65,13 @@ def is_running(self) -> bool:
6565
return self in self.list_running_states()
6666

6767

68+
RUNNING_STATE_COMPLETED_STATES: Final[tuple[RunningState, ...]] = (
69+
RunningState.ABORTED,
70+
RunningState.FAILED,
71+
RunningState.SUCCESS,
72+
)
73+
74+
6875
@unique
6976
class DataState(str, Enum):
7077
UP_TO_DATE = "UPTODATE"

services/director-v2/src/simcore_service_director_v2/utils/computations.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
from typing import Any
44

55
import arrow
6-
from models_library.projects_state import RunningState
6+
from models_library.projects_state import RUNNING_STATE_COMPLETED_STATES, RunningState
77
from models_library.services import ServiceKeyVersion
88
from models_library.services_regex import SERVICE_KEY_RE
99
from models_library.users import UserID
@@ -15,7 +15,7 @@
1515

1616
_logger = logging.getLogger(__name__)
1717

18-
_COMPLETED_STATES = (RunningState.ABORTED, RunningState.FAILED, RunningState.SUCCESS)
18+
1919
_RUNNING_STATES = (RunningState.STARTED,)
2020
_TASK_TO_PIPELINE_CONVERSIONS = {
2121
# tasks are initially in NOT_STARTED state, then they transition to published
@@ -50,16 +50,16 @@
5050
RunningState.NOT_STARTED,
5151
): RunningState.NOT_STARTED,
5252
# if there are only completed states with FAILED --> FAILED
53-
(*_COMPLETED_STATES,): RunningState.FAILED,
53+
(*RUNNING_STATE_COMPLETED_STATES,): RunningState.FAILED,
5454
# if there are only completed states with FAILED and not started ones --> NOT_STARTED
5555
(
56-
*_COMPLETED_STATES,
56+
*RUNNING_STATE_COMPLETED_STATES,
5757
RunningState.NOT_STARTED,
5858
): RunningState.NOT_STARTED,
5959
# the generic case where we have a combination of completed states, running states,
6060
# or published/pending tasks, not_started is a started pipeline
6161
(
62-
*_COMPLETED_STATES,
62+
*RUNNING_STATE_COMPLETED_STATES,
6363
*_RUNNING_STATES,
6464
RunningState.PUBLISHED,
6565
RunningState.PENDING,

0 commit comments

Comments
 (0)