1111from models_library .projects_nodes_io import NodeID
1212from models_library .services import DynamicServiceKey , RunID , ServiceVersion
1313from models_library .users import UserID
14- from pydantic import ByteSize , Field , PositiveInt , parse_obj_as , validator
14+ from pydantic import (
15+ AliasChoices ,
16+ ByteSize ,
17+ Field ,
18+ PositiveInt ,
19+ TypeAdapter ,
20+ field_validator ,
21+ )
1522from settings_library .aws_s3_cli import AwsS3CliSettings
1623from settings_library .base import BaseCustomSettings
1724from settings_library .docker_registry import RegistrySettings
@@ -61,7 +68,10 @@ class ApplicationSettings(BaseCustomSettings, MixinLoggingSettings):
6168
6269 # LOGGING
6370 LOG_LEVEL : str = Field (
64- default = "WARNING" , env = ["DYNAMIC_SIDECAR_LOG_LEVEL" , "LOG_LEVEL" , "LOGLEVEL" ]
71+ default = "WARNING" ,
72+ validation_alias = AliasChoices (
73+ "DYNAMIC_SIDECAR_LOG_LEVEL" , "LOG_LEVEL" , "LOGLEVEL"
74+ ),
6575 )
6676
6777 # SERVICE SERVER (see : https://www.uvicorn.org/settings/)
@@ -100,7 +110,7 @@ class ApplicationSettings(BaseCustomSettings, MixinLoggingSettings):
100110 )
101111
102112 DYNAMIC_SIDECAR_RESERVED_SPACE_SIZE : ByteSize = Field (
103- parse_obj_as (ByteSize , "10Mib" ),
113+ TypeAdapter (ByteSize ). validate_python ( "10Mib" ),
104114 description = (
105115 "Disk space reserve when the dy-sidecar is started. Can be freed at "
106116 "any time via an API call. Main reason to free this disk space is "
@@ -130,7 +140,10 @@ class ApplicationSettings(BaseCustomSettings, MixinLoggingSettings):
130140 )
131141 DY_SIDECAR_LOG_FORMAT_LOCAL_DEV_ENABLED : bool = Field (
132142 default = False ,
133- env = ["DY_SIDECAR_LOG_FORMAT_LOCAL_DEV_ENABLED" , "LOG_FORMAT_LOCAL_DEV_ENABLED" ],
143+ validation_alias = AliasChoices (
144+ "DY_SIDECAR_LOG_FORMAT_LOCAL_DEV_ENABLED" ,
145+ "LOG_FORMAT_LOCAL_DEV_ENABLED" ,
146+ ),
134147 description = "Enables local development log format. WARNING: make sure it is disabled if you want to have structured logs!" ,
135148 )
136149 DY_SIDECAR_USER_ID : UserID
@@ -144,28 +157,38 @@ class ApplicationSettings(BaseCustomSettings, MixinLoggingSettings):
144157 DY_SIDECAR_PRODUCT_NAME : ProductName | None = None
145158
146159 NODE_PORTS_STORAGE_AUTH : StorageAuthSettings | None = Field (
147- auto_default_from_env = True
160+ json_schema_extra = {"auto_default_from_env" : True }
161+ )
162+ DY_SIDECAR_R_CLONE_SETTINGS : RCloneSettings = Field (
163+ json_schema_extra = {"auto_default_from_env" : True }
148164 )
149- DY_SIDECAR_R_CLONE_SETTINGS : RCloneSettings = Field (auto_default_from_env = True )
150165 DY_SIDECAR_AWS_S3_CLI_SETTINGS : AwsS3CliSettings | None = Field (
151166 None ,
152167 description = "AWS S3 settings are used for the AWS S3 CLI. If these settings are filled, the AWS S3 CLI is used instead of RClone." ,
153168 )
154- POSTGRES_SETTINGS : PostgresSettings = Field (auto_default_from_env = True )
155- RABBIT_SETTINGS : RabbitSettings = Field (auto_default_from_env = True )
169+ POSTGRES_SETTINGS : PostgresSettings = Field (
170+ json_schema_extra = {"auto_default_from_env" : True }
171+ )
172+ RABBIT_SETTINGS : RabbitSettings = Field (
173+ json_schema_extra = {"auto_default_from_env" : True }
174+ )
156175
157176 DY_DEPLOYMENT_REGISTRY_SETTINGS : RegistrySettings = Field ()
158177 DY_DOCKER_HUB_REGISTRY_SETTINGS : RegistrySettings | None = Field ()
159178
160- RESOURCE_TRACKING : ResourceTrackingSettings = Field (auto_default_from_env = True )
179+ RESOURCE_TRACKING : ResourceTrackingSettings = Field (
180+ json_schema_extra = {"auto_default_from_env" : True }
181+ )
161182
162- SYSTEM_MONITOR_SETTINGS : SystemMonitorSettings = Field (auto_default_from_env = True )
183+ SYSTEM_MONITOR_SETTINGS : SystemMonitorSettings = Field (
184+ json_schema_extra = {"auto_default_from_env" : True }
185+ )
163186
164187 @property
165188 def are_prometheus_metrics_enabled (self ) -> bool :
166189 return self .DY_SIDECAR_CALLBACKS_MAPPING .metrics is not None
167190
168- @validator ("LOG_LEVEL" )
191+ @field_validator ("LOG_LEVEL" )
169192 @classmethod
170193 def _check_log_level (cls , value ):
171194 return cls .validate_log_level (value )
0 commit comments