Skip to content

Commit

Permalink
frigate: pin to python3.11, support mpl 3.9.0
Browse files Browse the repository at this point in the history
and backport a patch that prevents crashes if /run/secrets exists, but
is unaccessible to frigate.

Closes: #325228
  • Loading branch information
mweinelt committed Jul 7, 2024
1 parent 5178410 commit 5831972
Show file tree
Hide file tree
Showing 2 changed files with 52 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkgs/applications/video/frigate/default.nix
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{ lib
, callPackage
, python3
, python311
, fetchFromGitHub
, fetchurl
, fetchpatch2
Expand All @@ -23,7 +23,7 @@ let
inherit version src;
};

python = python3.override {
python = python311.override {
packageOverrides = self: super: {
pydantic = super.pydantic_1;

Expand Down Expand Up @@ -71,6 +71,14 @@ python.pkgs.buildPythonApplication rec {
url = "https://github.com/blakeblackshear/frigate/commit/b65656fa8733c1c2f3d944f716d2e9493ae7c99f.patch";
hash = "sha256-taPWFV4PldBGUKAwFMKag4W/3TLMSGdKLYG8bj1Y5mU=";
})
(fetchpatch2 {
# https://github.com/blakeblackshear/frigate/pull/10097
name = "frigate-secrets-permissionerror.patch";
url = "https://github.com/blakeblackshear/frigate/commit/a1424bad6c0163e790129ade7a9784514d0bf89d.patch";
hash = "sha256-/kIy4aW9o5AKHJQfCDVY46si+DKaUb+CsZsCGIbXvUQ=";
})
# https://github.com/blakeblackshear/frigate/pull/12324
./mpl-3.9.0.patch
];

postPatch = ''
Expand Down
42 changes: 42 additions & 0 deletions pkgs/applications/video/frigate/mpl-3.9.0.patch
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
From fba8cff13186bd80ceaa06806392957598139deb Mon Sep 17 00:00:00 2001
From: Martin Weinelt <[email protected]>
Date: Sun, 7 Jul 2024 14:23:29 +0200
Subject: [PATCH] Fix colormap usage with matplotlib 3.9.0

The mpl.cm toplevel registration has been removed.

https://matplotlib.org/stable/api/prev_api_changes/api_changes_3.9.0.html#top-level-cmap-registration-and-access-functions-in-mpl-cm
---
frigate/config.py | 2 +-
frigate/detectors/detector_config.py | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/frigate/config.py b/frigate/config.py
index 2e8b2570..af4f3263 100644
--- a/frigate/config.py
+++ b/frigate/config.py
@@ -807,7 +807,7 @@ class CameraConfig(FrigateBaseModel):
def __init__(self, **config):
# Set zone colors
if "zones" in config:
- colors = plt.cm.get_cmap("tab10", len(config["zones"]))
+ colors = plt.colormaps["tab10"].resampled(len(config["zones"]))
config["zones"] = {
name: {**z, "color": tuple(round(255 * c) for c in colors(idx)[:3])}
for idx, (name, z) in enumerate(config["zones"].items())
diff --git a/frigate/detectors/detector_config.py b/frigate/detectors/detector_config.py
index 7fc958a3..b65631eb 100644
--- a/frigate/detectors/detector_config.py
+++ b/frigate/detectors/detector_config.py
@@ -125,7 +125,7 @@ class ModelConfig(BaseModel):

def create_colormap(self, enabled_labels: set[str]) -> None:
"""Get a list of colors for enabled labels."""
- cmap = plt.cm.get_cmap("tab10", len(enabled_labels))
+ cmap = plt.colormaps["tab10"].resampled(len(enabled_labels))

for key, val in enumerate(enabled_labels):
self._colormap[val] = tuple(int(round(255 * c)) for c in cmap(key)[:3])
--
2.45.1

0 comments on commit 5831972

Please sign in to comment.