File tree Expand file tree Collapse file tree 2 files changed +17
-8
lines changed
packages/common-library/src/common_library
services/dynamic-sidecar/src/simcore_service_dynamic_sidecar/core Expand file tree Collapse file tree 2 files changed +17
-8
lines changed Original file line number Diff line number Diff line change 11import datetime
22
3+ from models_library .services_types import RunID
34from pydantic import field_validator
45
56
@@ -18,3 +19,13 @@ def _try_convert_str_to_float_or_return(
1819def timedelta_try_convert_str_to_float (field : str ):
1920 """Transforms a float/int number into a valid datetime as it used to work in the past"""
2021 return field_validator (field , mode = "before" )(_try_convert_str_to_float_or_return )
22+
23+
24+ def _convert_str_to_run_id_object (v : RunID | str ) -> RunID :
25+ if isinstance (v , str ):
26+ return RunID (v )
27+ return v
28+
29+
30+ def convert_str_to_run_id_object (field : str ):
31+ return field_validator (field , mode = "before" )(_convert_str_to_run_id_object )
Original file line number Diff line number Diff line change 55from typing import cast
66
77from common_library .pydantic_type_adapters import ByteSizeAdapter
8- from common_library .pydantic_validators import timedelta_try_convert_str_to_float
8+ from common_library .pydantic_validators import (
9+ convert_str_to_run_id_object ,
10+ timedelta_try_convert_str_to_float ,
11+ )
912from models_library .basic_types import BootModeEnum , PortInt
1013from models_library .callbacks_mapping import CallbacksMapping
1114from models_library .products import ProductName
@@ -189,18 +192,13 @@ def are_prometheus_metrics_enabled(self) -> bool:
189192 self .DY_SIDECAR_CALLBACKS_MAPPING .metrics is not None
190193 )
191194
192- @field_validator ("DY_SIDECAR_RUN_ID" , mode = "before" )
193- @classmethod
194- def convert_str_to_run_id_object (cls , v ):
195- if isinstance (v , str ):
196- return RunID (v )
197- return v
198-
199195 @field_validator ("LOG_LEVEL" )
200196 @classmethod
201197 def _check_log_level (cls , value ):
202198 return cls .validate_log_level (value )
203199
200+ _convert_str_to_run_id_object = convert_str_to_run_id_object ("DY_SIDECAR_RUN_ID" )
201+
204202 _try_convert_dynamic_sidecar_telemetry_disk_usage_monitor_interval = (
205203 timedelta_try_convert_str_to_float (
206204 "DYNAMIC_SIDECAR_TELEMETRY_DISK_USAGE_MONITOR_INTERVAL"
You can’t perform that action at this time.
0 commit comments