From 1b1048280bccb25a9cacf52cdd361ec407414956 Mon Sep 17 00:00:00 2001 From: Andrei Neagu <5694077+GitHK@users.noreply.github.com> Date: Wed, 22 Mar 2023 09:00:37 +0100 Subject: [PATCH] =?UTF-8?q?=E2=99=BB=EF=B8=8F=20director-v2=20SchedulerDat?= =?UTF-8?q?a=20legacy=20data=20format=20update=20(#4005)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../schemas/dynamic_services/scheduler.py | 29 +-------- .../mocks/legacy_scheduler_data_format.json | 64 +++++++++++++++++-- 2 files changed, 61 insertions(+), 32 deletions(-) diff --git a/services/director-v2/src/simcore_service_director_v2/models/schemas/dynamic_services/scheduler.py b/services/director-v2/src/simcore_service_director_v2/models/schemas/dynamic_services/scheduler.py index 20937393abe..0bd30b170c4 100644 --- a/services/director-v2/src/simcore_service_director_v2/models/schemas/dynamic_services/scheduler.py +++ b/services/director-v2/src/simcore_service_director_v2/models/schemas/dynamic_services/scheduler.py @@ -1,6 +1,5 @@ import json import logging -import warnings from enum import Enum from functools import cached_property from typing import Any, Mapping, Optional @@ -17,15 +16,7 @@ ) from models_library.services import RunID from models_library.services_resources import ServiceResourcesDict -from pydantic import ( - AnyHttpUrl, - BaseModel, - Extra, - Field, - constr, - parse_obj_as, - root_validator, -) +from pydantic import AnyHttpUrl, BaseModel, Extra, Field, constr, parse_obj_as from servicelib.error_codes import ErrorCodeStr from servicelib.exception_utils import DelayedExceptionHandler @@ -116,24 +107,6 @@ def from_container(cls, container: dict[str, Any]) -> "DockerContainerInspect": id=container["Id"], ) - @root_validator(pre=True) - @classmethod - def _ensure_legacy_format_compatibility(cls, values): - warnings.warn( - ( - "Once https://github.com/ITISFoundation/osparc-simcore/pull/3610 " - "reaches production this entire root_validator function " - "can be safely removed. Please check the " - "https://github.com/ITISFoundation/osparc-simcore/releases" - ), - DeprecationWarning, - stacklevel=2, - ) - status: Optional[str] = values.get("status") - if status: - values["container_state"] = {"Status": status} - return values - class Config: keep_untouched = (cached_property,) allow_mutation = False diff --git a/services/director-v2/tests/mocks/legacy_scheduler_data_format.json b/services/director-v2/tests/mocks/legacy_scheduler_data_format.json index d433b331a0f..95a3d67217b 100644 --- a/services/director-v2/tests/mocks/legacy_scheduler_data_format.json +++ b/services/director-v2/tests/mocks/legacy_scheduler_data_format.json @@ -31,7 +31,21 @@ { "status": "running", "name": "/dy-sidecar-12fb3055-db35-4a34-a9c0-bff1267aa859-0-container", - "id": "dddbc3c10cd074e4cce0fbb6c49258e82befa003c2714159aef6214750646dc8" + "id": "dddbc3c10cd074e4cce0fbb6c49258e82befa003c2714159aef6214750646dc8", + "container_state": { + "Status": "running", + "Running": null, + "Paused": null, + "Restarting": null, + "OOMKilled": null, + "Dead": null, + "Pid": null, + "ExitCode": null, + "Error": null, + "StartedAt": null, + "FinishedAt": null, + "Health": null + } } ], "was_dynamic_sidecar_started": true, @@ -109,17 +123,59 @@ { "status": "running", "name": "/dy-sidecar-d14bf3ea-abcf-52f2-8146-fc244b70f307-0-rt-web-dy", - "id": "eb076666d7da05ac69e60a211ff500d6b8d8dd6a823e0d0cc362d3421b6f37d7" + "id": "eb076666d7da05ac69e60a211ff500d6b8d8dd6a823e0d0cc362d3421b6f37d7", + "container_state": { + "Status": "running", + "Running": null, + "Paused": null, + "Restarting": null, + "OOMKilled": null, + "Dead": null, + "Pid": null, + "ExitCode": null, + "Error": null, + "StartedAt": null, + "FinishedAt": null, + "Health": null + } }, { "status": "running", "name": "/dy-sidecar-d14bf3ea-abcf-52f2-8146-fc244b70f307-1-s4l-core", - "id": "3a0a443dd2732ae147b9e2d56f8ce44a72e7ca0b20886092c0b49d3cf5073dd9" + "id": "3a0a443dd2732ae147b9e2d56f8ce44a72e7ca0b20886092c0b49d3cf5073dd9", + "container_state": { + "Status": "running", + "Running": null, + "Paused": null, + "Restarting": null, + "OOMKilled": null, + "Dead": null, + "Pid": null, + "ExitCode": null, + "Error": null, + "StartedAt": null, + "FinishedAt": null, + "Health": null + } }, { "status": "running", "name": "/dy-sidecar-d14bf3ea-abcf-52f2-8146-fc244b70f307-2-sym-server", - "id": "454858d71c4eed4e62723cf55dbdc72a97c41073a5b4cf6bbffd79a04df2f80a" + "id": "454858d71c4eed4e62723cf55dbdc72a97c41073a5b4cf6bbffd79a04df2f80a", + "container_state": { + "Status": "running", + "Running": null, + "Paused": null, + "Restarting": null, + "OOMKilled": null, + "Dead": null, + "Pid": null, + "ExitCode": null, + "Error": null, + "StartedAt": null, + "FinishedAt": null, + "Health": null + } } ], "was_dynamic_sidecar_started": true,