Remove warnings from pydantic serialization

This commit is contained in:
Nicolas Mowen 2024-04-16 09:08:02 -06:00
parent c7e6f023b5
commit 6bc5cd4b43
3 changed files with 13 additions and 8 deletions

View File

@ -139,7 +139,7 @@ def stats_history():
def config():
config_obj: FrigateConfig = current_app.frigate_config
config: dict[str, dict[str, any]] = config_obj.model_dump(
mode="json", exclude_none=True
mode="json", warnings="error", exclude_none=True
)
# remove the mqtt password

View File

@ -1351,11 +1351,12 @@ class FrigateConfig(FrigateBaseModel):
"timestamp_style": ...,
},
exclude_unset=True,
warnings="error",
)
for name, camera in config.cameras.items():
merged_config = deep_merge(
camera.model_dump(exclude_unset=True), global_config
camera.model_dump(exclude_unset=True, warnings="error"), global_config
)
camera_config: CameraConfig = CameraConfig.model_validate(
{"name": name, **merged_config}
@ -1466,7 +1467,7 @@ class FrigateConfig(FrigateBaseModel):
# Set runtime filter to create masks
camera_config.objects.filters[object] = RuntimeFilterConfig(
frame_shape=camera_config.frame_shape,
**filter.model_dump(exclude_unset=True),
**filter.model_dump(exclude_unset=True, warnings="error"),
)
# Convert motion configuration
@ -1478,7 +1479,9 @@ class FrigateConfig(FrigateBaseModel):
camera_config.motion = RuntimeMotionConfig(
frame_shape=camera_config.frame_shape,
raw_mask=camera_config.motion.mask,
**camera_config.motion.model_dump(exclude_unset=True),
**camera_config.motion.model_dump(
exclude_unset=True, warnings="error"
),
)
camera_config.motion.enabled_in_config = camera_config.motion.enabled
@ -1515,7 +1518,9 @@ class FrigateConfig(FrigateBaseModel):
for key, detector in config.detectors.items():
adapter = TypeAdapter(DetectorConfig)
model_dict = (
detector if isinstance(detector, dict) else detector.model_dump()
detector
if isinstance(detector, dict)
else detector.model_dump(warnings="error")
)
detector_config: DetectorConfig = adapter.validate_python(model_dict)
if detector_config.model is None:
@ -1536,8 +1541,8 @@ class FrigateConfig(FrigateBaseModel):
"Customizing more than a detector model path is unsupported."
)
merged_model = deep_merge(
detector_config.model.model_dump(exclude_unset=True),
config.model.model_dump(exclude_unset=True),
detector_config.model.model_dump(exclude_unset=True, warnings="error"),
config.model.model_dump(exclude_unset=True, warnings="error"),
)
if "path" not in merged_model:

View File

@ -31,7 +31,7 @@ function Logs() {
const [logService, setLogService] = useState<LogType>("frigate");
useEffect(() => {
document.title = `${logService[0].toUpperCase()}${logService.substring(1)} Stats - Frigate`;
document.title = `${logService[0].toUpperCase()}${logService.substring(1)} Logs - Frigate`;
}, [logService]);
// log data handling