diff --git a/frigate/__main__.py b/frigate/__main__.py index baab67e76..688daf93a 100644 --- a/frigate/__main__.py +++ b/frigate/__main__.py @@ -1,9 +1,3 @@ -# This is required to satisfy the chromadb dependency -__import__("pysqlite3") -import sys # noqa: E402 - -sys.modules["sqlite3"] = sys.modules.pop("pysqlite3") - import faulthandler # noqa: E402 import threading # noqa: E402 diff --git a/frigate/embeddings/__init__.py b/frigate/embeddings/__init__.py index 8a3d3d84b..989fc396f 100644 --- a/frigate/embeddings/__init__.py +++ b/frigate/embeddings/__init__.py @@ -3,12 +3,22 @@ import base64 import io import logging import os +import sys import time import numpy as np -from chromadb import Collection -from chromadb import HttpClient as ChromaClient -from chromadb.config import Settings + +try: + from chromadb import Collection + from chromadb import HttpClient as ChromaClient + from chromadb.config import Settings +except RuntimeError: + __import__("pysqlite3") + sys.modules["sqlite3"] = sys.modules.pop("pysqlite3") + from chromadb import Collection + from chromadb import HttpClient as ChromaClient + from chromadb.config import Settings + from PIL import Image from playhouse.shortcuts import model_to_dict diff --git a/frigate/test/__init__.py b/frigate/test/__init__.py index 11f933bdd..e69de29bb 100644 --- a/frigate/test/__init__.py +++ b/frigate/test/__init__.py @@ -1,5 +0,0 @@ -# This is required to satisfy the chromadb dependency -__import__("pysqlite3") -import sys # noqa: E402 - -sys.modules["sqlite3"] = sys.modules.pop("pysqlite3") diff --git a/frigate/test/test_http.py b/frigate/test/test_http.py index 932a468a3..ad0218852 100644 --- a/frigate/test/test_http.py +++ b/frigate/test/test_http.py @@ -121,6 +121,7 @@ class TestHttp(unittest.TestCase): None, None, PlusApi(), + None, ) id = "123456.random" id2 = "7890.random" @@ -157,6 +158,7 @@ class TestHttp(unittest.TestCase): None, None, PlusApi(), + None, ) id = "123456.random" @@ -178,6 +180,7 @@ class TestHttp(unittest.TestCase): None, None, PlusApi(), + None, ) id = "123456.random" bad_id = "654321.other" @@ -198,6 +201,7 @@ class TestHttp(unittest.TestCase): None, None, PlusApi(), + None, ) id = "123456.random" @@ -220,6 +224,7 @@ class TestHttp(unittest.TestCase): None, None, PlusApi(), + None, ) id = "123456.random" @@ -246,6 +251,7 @@ class TestHttp(unittest.TestCase): None, None, PlusApi(), + None, ) morning_id = "123456.random" evening_id = "654321.random" @@ -284,6 +290,7 @@ class TestHttp(unittest.TestCase): None, None, PlusApi(), + None, ) id = "123456.random" sub_label = "sub" @@ -319,6 +326,7 @@ class TestHttp(unittest.TestCase): None, None, PlusApi(), + None, ) id = "123456.random" sub_label = "sub" @@ -344,6 +352,7 @@ class TestHttp(unittest.TestCase): None, None, PlusApi(), + None, ) with app.test_client() as client: @@ -361,6 +370,7 @@ class TestHttp(unittest.TestCase): None, None, PlusApi(), + None, ) id = "123456.random" @@ -381,6 +391,7 @@ class TestHttp(unittest.TestCase): None, None, PlusApi(), + None, ) mock_stats.return_value = self.test_stats