Refactor recordings retention to be based on review items (#13355)

* Refactor recordings config to be based off of review items

* Update object processing logic for when an event is created

* Migrate to deciding recording retention based on review items

* Refactor recording expiration to be based off of review items

* Remove remainder of recording events access

* Handle migration automatically

* Update version and cleanup

* Update docs

* Clarify docs

* Cleanup

* Target camera config

* Safely access all fields
This commit is contained in:
Nicolas Mowen
2024-09-02 07:22:53 -06:00
committed by GitHub
parent e3da5ef2d5
commit 0acbd3d5e8
11 changed files with 363 additions and 278 deletions

View File

@@ -381,9 +381,7 @@ class TestConfig(unittest.TestCase):
def test_motion_mask_relative_matches_explicit(self):
config = {
"mqtt": {"host": "mqtt"},
"record": {
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
},
"record": {"alerts": {"retain": {"days": 20}}},
"cameras": {
"explicit": {
"ffmpeg": {
@@ -555,9 +553,7 @@ class TestConfig(unittest.TestCase):
def test_inherit_clips_retention(self):
config = {
"mqtt": {"host": "mqtt"},
"record": {
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
},
"record": {"alerts": {"retain": {"days": 20}}},
"cameras": {
"back": {
"ffmpeg": {
@@ -577,15 +573,17 @@ class TestConfig(unittest.TestCase):
assert config == frigate_config.model_dump(exclude_unset=True)
runtime_config = frigate_config.runtime_config()
assert (
runtime_config.cameras["back"].record.events.retain.objects["person"] == 30
)
assert runtime_config.cameras["back"].record.alerts.retain.days == 20
def test_roles_listed_twice_throws_error(self):
config = {
"mqtt": {"host": "mqtt"},
"record": {
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
"alerts": {
"retain": {
"days": 20,
}
}
},
"cameras": {
"back": {
@@ -609,7 +607,11 @@ class TestConfig(unittest.TestCase):
config = {
"mqtt": {"host": "mqtt"},
"record": {
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
"alerts": {
"retain": {
"days": 20,
}
}
},
"cameras": {
"back": {
@@ -633,7 +635,11 @@ class TestConfig(unittest.TestCase):
config = {
"mqtt": {"host": "mqtt"},
"record": {
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
"alerts": {
"retain": {
"days": 20,
}
}
},
"cameras": {
"back": {
@@ -664,7 +670,11 @@ class TestConfig(unittest.TestCase):
config = {
"mqtt": {"host": "mqtt"},
"record": {
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
"alerts": {
"retain": {
"days": 20,
}
}
},
"cameras": {
"back": {
@@ -695,37 +705,6 @@ class TestConfig(unittest.TestCase):
frigate_config.cameras["back"].zones["relative"].contour,
)
def test_clips_should_default_to_global_objects(self):
config = {
"mqtt": {"host": "mqtt"},
"record": {
"events": {"retain": {"default": 20, "objects": {"person": 30}}}
},
"objects": {"track": ["person", "dog"]},
"cameras": {
"back": {
"ffmpeg": {
"inputs": [
{"path": "rtsp://10.0.0.1:554/video", "roles": ["detect"]}
]
},
"detect": {
"height": 1080,
"width": 1920,
"fps": 5,
},
"record": {"events": {}},
}
},
}
frigate_config = FrigateConfig(**config)
assert config == frigate_config.model_dump(exclude_unset=True)
runtime_config = frigate_config.runtime_config()
back_camera = runtime_config.cameras["back"]
assert back_camera.record.events.objects is None
assert back_camera.record.events.retain.objects["person"] == 30
def test_role_assigned_but_not_enabled(self):
config = {
"mqtt": {"host": "mqtt"},