Skip to content

Commit 7a20ef7

Browse files
run bump-pydantic
1 parent 9c71e51 commit 7a20ef7

File tree

1 file changed

+12
-8
lines changed
  • services/datcore-adapter/src/simcore_service_datcore_adapter/core

1 file changed

+12
-8
lines changed

services/datcore-adapter/src/simcore_service_datcore_adapter/core/settings.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
from functools import cached_property
22

33
from models_library.basic_types import BootModeEnum, LogLevel
4-
from pydantic import Field, parse_obj_as, validator
4+
from pydantic import AliasChoices, Field, TypeAdapter, field_validator
55
from pydantic.networks import AnyUrl
66
from settings_library.base import BaseCustomSettings
77
from settings_library.utils_logging import MixinLoggingSettings
@@ -10,7 +10,9 @@
1010
class PennsieveSettings(BaseCustomSettings):
1111
PENNSIEVE_ENABLED: bool = True
1212

13-
PENNSIEVE_API_URL: AnyUrl = parse_obj_as(AnyUrl, "https://api.pennsieve.io")
13+
PENNSIEVE_API_URL: AnyUrl = TypeAdapter(AnyUrl).validate_python(
14+
"https://api.pennsieve.io"
15+
)
1416
PENNSIEVE_API_GENERAL_TIMEOUT: float = 20.0
1517
PENNSIEVE_HEALTCHCHECK_TIMEOUT: float = 1.0
1618

@@ -21,22 +23,24 @@ class ApplicationSettings(BaseCustomSettings, MixinLoggingSettings):
2123

2224
LOG_LEVEL: LogLevel = Field(
2325
LogLevel.INFO.value,
24-
env=[
26+
validation_alias=AliasChoices(
2527
"DATCORE_ADAPTER_LOGLEVEL",
2628
"DATCORE_ADAPTER_LOG_LEVEL",
2729
"LOG_LEVEL",
2830
"LOGLEVEL",
29-
],
31+
),
3032
)
3133

32-
PENNSIEVE: PennsieveSettings = Field(auto_default_from_env=True)
34+
PENNSIEVE: PennsieveSettings = Field(
35+
json_schema_extra={"auto_default_from_env": True}
36+
)
3337

3438
DATCORE_ADAPTER_LOG_FORMAT_LOCAL_DEV_ENABLED: bool = Field(
3539
False,
36-
env=[
40+
validation_alias=AliasChoices(
3741
"DATCORE_ADAPTER_LOG_FORMAT_LOCAL_DEV_ENABLED",
3842
"LOG_FORMAT_LOCAL_DEV_ENABLED",
39-
],
43+
),
4044
description="Enables local development log format. WARNING: make sure it is disabled if you want to have structured logs!",
4145
)
4246
DATCORE_ADAPTER_PROMETHEUS_INSTRUMENTATION_ENABLED: bool = True
@@ -50,7 +54,7 @@ def debug(self) -> bool:
5054
BootModeEnum.LOCAL,
5155
]
5256

53-
@validator("LOG_LEVEL", pre=True)
57+
@field_validator("LOG_LEVEL", mode="before")
5458
@classmethod
5559
def _validate_loglevel(cls, value) -> str:
5660
return cls.validate_log_level(value)

0 commit comments

Comments
 (0)