mirror of
https://github.com/yavook/kiwi-simple-metrics.git
synced 2024-11-21 15:23:01 +00:00
workaround for default value
This commit is contained in:
parent
9d754ad4e8
commit
a8627bad84
3 changed files with 32 additions and 11 deletions
4
.vscode/launch.json
vendored
4
.vscode/launch.json
vendored
|
@ -9,6 +9,10 @@
|
|||
"type": "python",
|
||||
"request": "launch",
|
||||
"module": "kiwi_simple_metrics.main",
|
||||
"env": {
|
||||
"METRIC_DISK__THRESHOLD": "85", // workaround!
|
||||
"METRIC_DISK__PARAMS": "[\"/var\", \"/\"]",
|
||||
},
|
||||
"justMyCode": true
|
||||
}
|
||||
]
|
||||
|
|
|
@ -24,17 +24,9 @@ class Settings(BaseSettings):
|
|||
env_nested_delimiter="__",
|
||||
)
|
||||
|
||||
cpu: MetricS = MetricS(
|
||||
threshold=100,
|
||||
)
|
||||
|
||||
memory: MetricS = MetricS(
|
||||
threshold=90,
|
||||
)
|
||||
|
||||
disk: ParamMS = ParamMS(
|
||||
threshold=85,
|
||||
)
|
||||
cpu: MetricS = MetricS(threshold=100)
|
||||
memory: MetricS = MetricS(threshold=90)
|
||||
disk: ParamMS = ParamMS(threshold=85)
|
||||
|
||||
|
||||
SETTINGS = Settings()
|
||||
|
|
25
min_fail_example.py
Normal file
25
min_fail_example.py
Normal file
|
@ -0,0 +1,25 @@
|
|||
from pydantic import BaseModel
|
||||
|
||||
|
||||
class SubModel(BaseModel):
|
||||
optional: int = 42
|
||||
required: str
|
||||
|
||||
|
||||
class Settings(BaseModel):
|
||||
sub: SubModel = SubModel(required="foo")
|
||||
sub2: SubModel = SubModel(required="bar")
|
||||
|
||||
|
||||
def main() -> None:
|
||||
settings = Settings.model_validate({
|
||||
"sub": {"optional": "69"},
|
||||
})
|
||||
|
||||
# settings = Settings()
|
||||
|
||||
print(settings.model_dump())
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Reference in a new issue