mirror of
https://github.com/blakeblackshear/frigate.git
synced 2026-10-31 19:00:30 +03:00
docstrings
This commit is contained in:
@@ -101,6 +101,7 @@ def object_masks(camera: CameraConfig) -> int:
|
|||||||
|
|
||||||
|
|
||||||
def collect(ctx: ReportContext) -> CamerasSection:
|
def collect(ctx: ReportContext) -> CamerasSection:
|
||||||
|
"""Count camera settings across the cameras enabled in config."""
|
||||||
cameras = {
|
cameras = {
|
||||||
name: camera
|
name: camera
|
||||||
for name, camera in ctx.config.cameras.items()
|
for name, camera in ctx.config.cameras.items()
|
||||||
@@ -171,7 +172,9 @@ def collect(ctx: ReportContext) -> CamerasSection:
|
|||||||
)
|
)
|
||||||
flags["detect"] += camera.detect.enabled
|
flags["detect"] += camera.detect.enabled
|
||||||
flags["record"] += camera.record.enabled
|
flags["record"] += camera.record.enabled
|
||||||
flags["sub_stream_record"] += camera.record.sub.enabled
|
flags["sub_stream_record"] += (
|
||||||
|
camera.record.enabled and camera.record.sub.enabled
|
||||||
|
)
|
||||||
flags["snapshots"] += camera.snapshots.enabled
|
flags["snapshots"] += camera.snapshots.enabled
|
||||||
flags["audio"] += camera.audio.enabled
|
flags["audio"] += camera.audio.enabled
|
||||||
flags["audio_transcription"] += (
|
flags["audio_transcription"] += (
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ def model_source(path: str | None) -> ModelSource:
|
|||||||
|
|
||||||
|
|
||||||
def collect(ctx: ReportContext) -> DetectionSection:
|
def collect(ctx: ReportContext) -> DetectionSection:
|
||||||
|
"""Describe each configured model and its measured inference speed."""
|
||||||
config = ctx.config
|
config = ctx.config
|
||||||
detectors = ctx.stats.get("detectors", {})
|
detectors = ctx.stats.get("detectors", {})
|
||||||
model_specs = [(model, config.devices_for_model(model)) for model in config.models]
|
model_specs = [(model, config.devices_for_model(model)) for model in config.models]
|
||||||
|
|||||||
@@ -86,6 +86,7 @@ def users() -> dict[UserRole, int]:
|
|||||||
|
|
||||||
|
|
||||||
def collect(ctx: ReportContext) -> FeaturesSection:
|
def collect(ctx: ReportContext) -> FeaturesSection:
|
||||||
|
"""Report which enrichments and integrations are configured."""
|
||||||
config = ctx.config
|
config = ctx.config
|
||||||
devices = ctx.stats.get("embeddings", {}).get("devices", {})
|
devices = ctx.stats.get("embeddings", {}).get("devices", {})
|
||||||
cameras = [
|
cameras = [
|
||||||
|
|||||||
@@ -96,6 +96,7 @@ def storage(stats: dict[str, Any]) -> StorageInfo:
|
|||||||
|
|
||||||
|
|
||||||
def collect(ctx: ReportContext) -> HardwareSection:
|
def collect(ctx: ReportContext) -> HardwareSection:
|
||||||
|
"""Describe the host: CPU, memory, GPUs, decoders, detectors, storage."""
|
||||||
return HardwareSection(
|
return HardwareSection(
|
||||||
cpu_model=cpu_model(),
|
cpu_model=cpu_model(),
|
||||||
cpu_cores=os.cpu_count() or 0,
|
cpu_cores=os.cpu_count() or 0,
|
||||||
|
|||||||
@@ -46,6 +46,7 @@ def notice_deltas(notice_stats: list[dict[str, Any]]) -> dict[Any, NoticeCounts]
|
|||||||
|
|
||||||
|
|
||||||
def collect(ctx: ReportContext) -> HealthSection:
|
def collect(ctx: ReportContext) -> HealthSection:
|
||||||
|
"""Read health figures from the latest stats and notice counts."""
|
||||||
service = ctx.stats.get("service", {})
|
service = ctx.stats.get("service", {})
|
||||||
embeddings = ctx.stats.get("embeddings", {})
|
embeddings = ctx.stats.get("embeddings", {})
|
||||||
cpu = ctx.stats.get("cpu_usages", {}).get("frigate.full_system", {}).get("cpu")
|
cpu = ctx.stats.get("cpu_usages", {}).get("frigate.full_system", {}).get("cpu")
|
||||||
|
|||||||
@@ -53,6 +53,7 @@ def kernel(release: str) -> str:
|
|||||||
|
|
||||||
|
|
||||||
def collect(ctx: ReportContext) -> InstallSection:
|
def collect(ctx: ReportContext) -> InstallSection:
|
||||||
|
"""Describe the Frigate version, image, install method, and platform."""
|
||||||
return InstallSection(
|
return InstallSection(
|
||||||
version=VERSION[:32],
|
version=VERSION[:32],
|
||||||
image_variant=image_variant(os.environ.get("FRIGATE_IMAGE_VARIANT")),
|
image_variant=image_variant(os.environ.get("FRIGATE_IMAGE_VARIANT")),
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ def gather_context(
|
|||||||
stats_emitter: "StatsEmitter | None",
|
stats_emitter: "StatsEmitter | None",
|
||||||
notice_registry: "NoticeRegistry | None",
|
notice_registry: "NoticeRegistry | None",
|
||||||
) -> ReportContext:
|
) -> ReportContext:
|
||||||
|
"""Snapshot the config, latest stats, and notice counts for one report."""
|
||||||
return ReportContext(
|
return ReportContext(
|
||||||
config=config,
|
config=config,
|
||||||
stats=stats_emitter.get_latest_stats() if stats_emitter is not None else {},
|
stats=stats_emitter.get_latest_stats() if stats_emitter is not None else {},
|
||||||
|
|||||||
@@ -105,6 +105,7 @@ class AnalyticsReporter(threading.Thread):
|
|||||||
delete_state(self.state_path)
|
delete_state(self.state_path)
|
||||||
|
|
||||||
def tick(self) -> None:
|
def tick(self) -> None:
|
||||||
|
"""Apply consent and send a report when one is due."""
|
||||||
with self._lock:
|
with self._lock:
|
||||||
config = self.config_holder.config
|
config = self.config_holder.config
|
||||||
|
|
||||||
|
|||||||
@@ -22,6 +22,7 @@ class AnalyticsState:
|
|||||||
|
|
||||||
|
|
||||||
def new_state() -> AnalyticsState:
|
def new_state() -> AnalyticsState:
|
||||||
|
"""A fresh install ID that has never attempted a report."""
|
||||||
return AnalyticsState(install_id=uuid4().hex, last_attempt_at=0.0)
|
return AnalyticsState(install_id=uuid4().hex, last_attempt_at=0.0)
|
||||||
|
|
||||||
|
|
||||||
|
|||||||
@@ -51,7 +51,7 @@ CONFIG = {
|
|||||||
},
|
},
|
||||||
"audio": {"enabled": True},
|
"audio": {"enabled": True},
|
||||||
"detect": {"height": 2160, "width": 3840, "fps": 15},
|
"detect": {"height": 2160, "width": 3840, "fps": 15},
|
||||||
"record": {"enabled": False},
|
"record": {"enabled": False, "sub": {"enabled": True}},
|
||||||
},
|
},
|
||||||
"attic": {
|
"attic": {
|
||||||
"enabled": False,
|
"enabled": False,
|
||||||
@@ -95,6 +95,7 @@ class TestCamerasCollector(unittest.TestCase):
|
|||||||
self.assertEqual((section.zones, section.cameras_with_zones), (2, 1))
|
self.assertEqual((section.zones, section.cameras_with_zones), (2, 1))
|
||||||
self.assertEqual((section.motion_masks, section.object_masks), (1, 2))
|
self.assertEqual((section.motion_masks, section.object_masks), (1, 2))
|
||||||
self.assertEqual((section.audio, section.audio_transcription), (1, 1))
|
self.assertEqual((section.audio, section.audio_transcription), (1, 1))
|
||||||
|
self.assertEqual(section.sub_stream_record, 0)
|
||||||
self.assertEqual(section.connection_quality, {"excellent": 1})
|
self.assertEqual(section.connection_quality, {"excellent": 1})
|
||||||
|
|
||||||
def test_runtime_disabled_camera_skips_connection_quality(self):
|
def test_runtime_disabled_camera_skips_connection_quality(self):
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ def render() -> str:
|
|||||||
|
|
||||||
|
|
||||||
def main() -> int:
|
def main() -> int:
|
||||||
|
"""Write or check the schema file; returns the process exit code."""
|
||||||
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
parser = argparse.ArgumentParser(description=__doc__.splitlines()[0])
|
||||||
parser.add_argument(
|
parser.add_argument(
|
||||||
"--check", action="store_true", help="fail if the committed schema is stale"
|
"--check", action="store_true", help="fail if the committed schema is stale"
|
||||||
|
|||||||
Reference in New Issue
Block a user