Skip to content

Commit 59febda

Browse files
sandereggCopilot
andauthored
🐛🎨⚗️Computational backend: Stability (Step 1) (#8323)
Co-authored-by: Copilot <[email protected]>
1 parent a98b2fb commit 59febda

File tree

13 files changed

+550
-342
lines changed

13 files changed

+550
-342
lines changed

packages/dask-task-models-library/src/dask_task_models_library/plugins/task_life_cycle_worker_plugin.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@ def transition(
3434
):
3535
_logger.info("Task '%s' transition from %s to %s", key, start, finish)
3636
assert self._worker # nosec
37+
assert isinstance(self._worker, Worker) # nosec
3738
self._worker.log_event(
3839
TASK_LIFE_CYCLE_EVENT.format(key=key),
3940
TaskLifeCycleState.from_worker_task_state(

packages/pytest-simcore/src/pytest_simcore/pydantic_models.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -97,7 +97,6 @@ def _is_model_cls(obj) -> bool:
9797
assert inspect.ismodule(module)
9898

9999
for model_name, model_cls in inspect.getmembers(module, _is_model_cls):
100-
101100
yield from iter_model_examples_in_class(model_cls, model_name)
102101

103102

@@ -172,7 +171,7 @@ def model_cls_examples(model_cls: type[BaseModel]) -> dict[str, dict[str, Any]]:
172171
"""
173172
warnings.warn(
174173
"The 'model_cls_examples' fixture is deprecated and will be removed in a future version. "
175-
"Please use 'iter_model_example_in_class' or 'iter_model_examples_in_module' as an alternative.",
174+
"Please use 'iter_model_examples_in_class' or 'iter_model_examples_in_module' as an alternative.",
176175
DeprecationWarning,
177176
stacklevel=2,
178177
)

services/director-v2/src/simcore_service_director_v2/core/settings.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,6 +99,14 @@ class ComputationalBackendSettings(BaseCustomSettings):
9999
),
100100
] = datetime.timedelta(minutes=10)
101101

102+
COMPUTATIONAL_BACKEND_MAX_WAITING_FOR_RETRIEVING_RESULTS: Annotated[
103+
datetime.timedelta,
104+
Field(
105+
description="maximum time the computational scheduler waits until retrieving results from the computational backend is failed"
106+
"(default to seconds, or see https://pydantic-docs.helpmanual.io/usage/types/#datetime-types for string formatting)."
107+
),
108+
] = datetime.timedelta(minutes=10)
109+
102110
@cached_property
103111
def default_cluster(self) -> BaseCluster:
104112
return BaseCluster(

services/director-v2/src/simcore_service_director_v2/models/comp_run_snapshot_tasks.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,21 @@
1+
from contextlib import suppress
12
from datetime import datetime
23
from typing import Annotated, Any
34

45
from models_library.projects import ProjectID
56
from models_library.projects_nodes_io import NodeID
67
from models_library.projects_state import RunningState
78
from models_library.resource_tracker import HardwareInfo
8-
from pydantic import BaseModel, BeforeValidator, ConfigDict, PositiveInt
9+
from pydantic import (
10+
BaseModel,
11+
BeforeValidator,
12+
ConfigDict,
13+
PositiveInt,
14+
field_validator,
15+
)
16+
from simcore_postgres_database.models.comp_pipeline import StateType
917

18+
from ..utils.db import DB_TO_RUNNING_STATE
1019
from .comp_tasks import BaseCompTaskAtDB, Image
1120

1221

@@ -100,3 +109,15 @@ class CompRunSnapshotTaskDBGet(BaseModel):
100109
started_at: datetime | None
101110
ended_at: datetime | None
102111
iteration: PositiveInt
112+
113+
@field_validator("state", mode="before")
114+
@classmethod
115+
def convert_result_from_state_type_enum_if_needed(cls, v):
116+
if isinstance(v, str):
117+
# try to convert to a StateType, if it fails the validations will continue
118+
# and pydantic will try to convert it to a RunninState later on
119+
with suppress(ValueError):
120+
v = StateType(v)
121+
if isinstance(v, StateType):
122+
return RunningState(DB_TO_RUNNING_STATE[StateType(v)])
123+
return v

0 commit comments

Comments
 (0)