mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-02-08 20:25:26 +03:00
Fix config checks
This commit is contained in:
parent
8921255da3
commit
318fb419f5
@ -1139,7 +1139,7 @@ class FrigateConfig(FrigateBaseModel):
|
||||
|
||||
def runtime_config(self, plus_api: PlusApi = None) -> FrigateConfig:
|
||||
"""Merge camera config with globals."""
|
||||
config = self.copy(deep=True)
|
||||
config = self.model_copy(deep=True)
|
||||
|
||||
# MQTT user/password substitutions
|
||||
if config.mqtt.user or config.mqtt.password:
|
||||
@ -1330,7 +1330,7 @@ class FrigateConfig(FrigateBaseModel):
|
||||
|
||||
for key, detector in config.detectors.items():
|
||||
adapter = TypeAdapter(DetectorConfig)
|
||||
detector_config: DetectorConfig = adapter.validate_python(detector)
|
||||
detector_config: DetectorConfig = adapter.validate_python(detector.model_dump())
|
||||
if detector_config.model is None:
|
||||
detector_config.model = config.model
|
||||
else:
|
||||
|
||||
@ -140,7 +140,7 @@ class ModelConfig(BaseModel):
|
||||
class BaseDetectorConfig(BaseModel):
|
||||
# the type field must be defined in all subclasses
|
||||
type: str = Field(default="cpu", title="Detector Type")
|
||||
model: ModelConfig = Field(
|
||||
model: Optional[ModelConfig] = Field(
|
||||
default=None, title="Detector specific model configuration."
|
||||
)
|
||||
model_config = ConfigDict(extra="allow", arbitrary_types_allowed=True)
|
||||
|
||||
@ -1,6 +1,7 @@
|
||||
import json
|
||||
import os
|
||||
import unittest
|
||||
from unittest.mock import patch
|
||||
|
||||
import numpy as np
|
||||
from pydantic import ValidationError
|
||||
@ -70,7 +71,9 @@ class TestConfig(unittest.TestCase):
|
||||
assert runtime_config.detectors["cpu"].type == DetectorTypeEnum.cpu
|
||||
assert runtime_config.detectors["cpu"].model.width == 320
|
||||
|
||||
def test_detector_custom_model_path(self):
|
||||
@patch("frigate.detectors.detector_config.load_labels")
|
||||
def test_detector_custom_model_path(self, mock_labels):
|
||||
mock_labels.return_value = {}
|
||||
config = {
|
||||
"detectors": {
|
||||
"cpu": {
|
||||
@ -83,7 +86,6 @@ class TestConfig(unittest.TestCase):
|
||||
},
|
||||
"openvino": {
|
||||
"type": "openvino",
|
||||
"model": {"path": "/openvino_model.xml"}
|
||||
},
|
||||
},
|
||||
# needs to be a file that will exist, doesnt matter what
|
||||
@ -111,7 +113,7 @@ class TestConfig(unittest.TestCase):
|
||||
assert runtime_config.detectors["openvino"].model.path == "/etc/hosts"
|
||||
|
||||
assert runtime_config.model.width == 512
|
||||
assert runtime_config.detectors["cpu"].model.width == 512
|
||||
assert runtime_config.detectors["cpu"].model.width == 320
|
||||
assert runtime_config.detectors["edgetpu"].model.width == 160
|
||||
assert runtime_config.detectors["openvino"].model.width == 512
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user