-
-
Notifications
You must be signed in to change notification settings - Fork 1.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add isort and ruff linter #6575
Conversation
✅ Deploy Preview for frigate-docs canceled.
|
I have been meaning to fix up the linting, but haven't had time yet. We currently use black. I would like to make sure everything works nicely in the vscode devcontainer on save in addition to github actions. If you're willing to help iron all that out, this sounds great to me. |
6724845
to
8233c7a
Compare
These are a bit annoying to resolve. For example I looked up the openvino documentation, and they say, that they throw an exception, but not which one. I think going with Other try except blocks are 40 lines long and a lot of things could happen in there.
|
Stole the isort setup for .devcontainer from https://github.com/AngellusMortis/pyunifiprotect/blob/master/.devcontainer/devcontainer.json, but I have no idea how to actually test it. |
fb07fe2
to
3c3099e
Compare
a3d6099
to
9472fa6
Compare
The test failures are already on the dev branch apparently. I can reproduce them on 846a180. The escaped is Did you mean file:***192.168.1.3:554
E.....E...E..EEEE...
======================================================================
ERROR: frigate.detectors (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: frigate.detectors
Traceback (most recent call last):
File "/usr/lib/python3.9/unittest/loader.py", line 470, in _find_test_path
package = self._get_module_from_name(name)
File "/usr/lib/python3.9/unittest/loader.py", line 377, in _get_module_from_name
__import__(name)
File "/opt/frigate/frigate/detectors/__init__.py", line 3, in <module>
from .detector_types import DetectorTypeEnum, api_types
File "/opt/frigate/frigate/detectors/detector_types.py", line 25, in <module>
plugin_modules.append(importlib.import_module(name))
File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/opt/frigate/frigate/detectors/plugins/cpu_tfl.py", line 21, in <module>
class CpuDetectorConfig(BaseDetectorConfig):
File "pydantic/main.py", line 197, in pydantic.main.ModelMetaclass.__new__
File "pydantic/fields.py", line 506, in pydantic.fields.ModelField.infer
File "pydantic/fields.py", line 436, in pydantic.fields.ModelField.__init__
File "pydantic/fields.py", line 552, in pydantic.fields.ModelField.prepare
File "pydantic/fields.py", line 668, in pydantic.fields.ModelField._type_analysis
File "/usr/lib/python3.9/typing.py", line 835, in __subclasscheck__
return issubclass(cls, self.__origin__)
TypeError: issubclass() arg 1 must be a class
======================================================================
ERROR: frigate.test.test_config (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: frigate.test.test_config
Traceback (most recent call last):
File "/usr/lib/python3.9/unittest/loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
File "/usr/lib/python3.9/unittest/loader.py", line 377, in _get_module_from_name
__import__(name)
File "/opt/frigate/frigate/test/test_config.py", line 8, in <module>
from frigate.config import BirdseyeModeEnum, FrigateConfig
File "/opt/frigate/frigate/config.py", line 15, in <module>
from frigate.detectors import DetectorConfig, ModelConfig
File "/opt/frigate/frigate/detectors/__init__.py", line 3, in <module>
from .detector_types import DetectorTypeEnum, api_types
File "/opt/frigate/frigate/detectors/detector_types.py", line 25, in <module>
plugin_modules.append(importlib.import_module(name))
File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/opt/frigate/frigate/detectors/plugins/cpu_tfl.py", line 21, in <module>
class CpuDetectorConfig(BaseDetectorConfig):
File "pydantic/main.py", line 197, in pydantic.main.ModelMetaclass.__new__
File "pydantic/fields.py", line 506, in pydantic.fields.ModelField.infer
File "pydantic/fields.py", line 436, in pydantic.fields.ModelField.__init__
File "pydantic/fields.py", line 552, in pydantic.fields.ModelField.prepare
File "pydantic/fields.py", line 668, in pydantic.fields.ModelField._type_analysis
File "/usr/lib/python3.9/typing.py", line 835, in __subclasscheck__
return issubclass(cls, self.__origin__)
TypeError: issubclass() arg 1 must be a class
======================================================================
ERROR: frigate.test.test_ffmpeg_presets (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: frigate.test.test_ffmpeg_presets
Traceback (most recent call last):
File "/usr/lib/python3.9/unittest/loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
File "/usr/lib/python3.9/unittest/loader.py", line 377, in _get_module_from_name
__import__(name)
File "/opt/frigate/frigate/test/test_ffmpeg_presets.py", line 3, in <module>
from frigate.config import FFMPEG_INPUT_ARGS_DEFAULT, FrigateConfig
File "/opt/frigate/frigate/config.py", line 15, in <module>
from frigate.detectors import DetectorConfig, ModelConfig
File "/opt/frigate/frigate/detectors/__init__.py", line 3, in <module>
from .detector_types import DetectorTypeEnum, api_types
File "/opt/frigate/frigate/detectors/detector_types.py", line 25, in <module>
plugin_modules.append(importlib.import_module(name))
File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/opt/frigate/frigate/detectors/plugins/cpu_tfl.py", line 21, in <module>
class CpuDetectorConfig(BaseDetectorConfig):
File "pydantic/main.py", line 197, in pydantic.main.ModelMetaclass.__new__
File "pydantic/fields.py", line 506, in pydantic.fields.ModelField.infer
File "pydantic/fields.py", line 436, in pydantic.fields.ModelField.__init__
File "pydantic/fields.py", line 552, in pydantic.fields.ModelField.prepare
File "pydantic/fields.py", line 668, in pydantic.fields.ModelField._type_analysis
File "/usr/lib/python3.9/typing.py", line 835, in __subclasscheck__
return issubclass(cls, self.__origin__)
TypeError: issubclass() arg 1 must be a class
======================================================================
ERROR: frigate.test.test_http (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: frigate.test.test_http
Traceback (most recent call last):
File "/usr/lib/python3.9/unittest/loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
File "/usr/lib/python3.9/unittest/loader.py", line 377, in _get_module_from_name
__import__(name)
File "/opt/frigate/frigate/test/test_http.py", line 13, in <module>
from frigate.config import FrigateConfig
File "/opt/frigate/frigate/config.py", line 15, in <module>
from frigate.detectors import DetectorConfig, ModelConfig
File "/opt/frigate/frigate/detectors/__init__.py", line 3, in <module>
from .detector_types import DetectorTypeEnum, api_types
File "/opt/frigate/frigate/detectors/detector_types.py", line 25, in <module>
plugin_modules.append(importlib.import_module(name))
File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/opt/frigate/frigate/detectors/plugins/cpu_tfl.py", line 21, in <module>
class CpuDetectorConfig(BaseDetectorConfig):
File "pydantic/main.py", line 197, in pydantic.main.ModelMetaclass.__new__
File "pydantic/fields.py", line 506, in pydantic.fields.ModelField.infer
File "pydantic/fields.py", line 436, in pydantic.fields.ModelField.__init__
File "pydantic/fields.py", line 552, in pydantic.fields.ModelField.prepare
File "pydantic/fields.py", line 668, in pydantic.fields.ModelField._type_analysis
File "/usr/lib/python3.9/typing.py", line 835, in __subclasscheck__
return issubclass(cls, self.__origin__)
TypeError: issubclass() arg 1 must be a class
======================================================================
ERROR: frigate.test.test_object_detector (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: frigate.test.test_object_detector
Traceback (most recent call last):
File "/usr/lib/python3.9/unittest/loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
File "/usr/lib/python3.9/unittest/loader.py", line 377, in _get_module_from_name
__import__(name)
File "/opt/frigate/frigate/test/test_object_detector.py", line 7, in <module>
import frigate.detectors as detectors
File "/opt/frigate/frigate/detectors/__init__.py", line 3, in <module>
from .detector_types import DetectorTypeEnum, api_types
File "/opt/frigate/frigate/detectors/detector_types.py", line 25, in <module>
plugin_modules.append(importlib.import_module(name))
File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/opt/frigate/frigate/detectors/plugins/cpu_tfl.py", line 21, in <module>
class CpuDetectorConfig(BaseDetectorConfig):
File "pydantic/main.py", line 197, in pydantic.main.ModelMetaclass.__new__
File "pydantic/fields.py", line 506, in pydantic.fields.ModelField.infer
File "pydantic/fields.py", line 436, in pydantic.fields.ModelField.__init__
File "pydantic/fields.py", line 552, in pydantic.fields.ModelField.prepare
File "pydantic/fields.py", line 668, in pydantic.fields.ModelField._type_analysis
File "/usr/lib/python3.9/typing.py", line 835, in __subclasscheck__
return issubclass(cls, self.__origin__)
TypeError: issubclass() arg 1 must be a class
======================================================================
ERROR: frigate.test.test_reduce_boxes (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: frigate.test.test_reduce_boxes
Traceback (most recent call last):
File "/usr/lib/python3.9/unittest/loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
File "/usr/lib/python3.9/unittest/loader.py", line 377, in _get_module_from_name
__import__(name)
File "/opt/frigate/frigate/test/test_reduce_boxes.py", line 3, in <module>
from frigate.video import box_overlaps, reduce_boxes
File "/opt/frigate/frigate/video.py", line 17, in <module>
from frigate.config import CameraConfig, DetectConfig, PixelFormatEnum
File "/opt/frigate/frigate/config.py", line 15, in <module>
from frigate.detectors import DetectorConfig, ModelConfig
File "/opt/frigate/frigate/detectors/__init__.py", line 3, in <module>
from .detector_types import DetectorTypeEnum, api_types
File "/opt/frigate/frigate/detectors/detector_types.py", line 25, in <module>
plugin_modules.append(importlib.import_module(name))
File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/opt/frigate/frigate/detectors/plugins/cpu_tfl.py", line 21, in <module>
class CpuDetectorConfig(BaseDetectorConfig):
File "pydantic/main.py", line 197, in pydantic.main.ModelMetaclass.__new__
File "pydantic/fields.py", line 506, in pydantic.fields.ModelField.infer
File "pydantic/fields.py", line 436, in pydantic.fields.ModelField.__init__
File "pydantic/fields.py", line 552, in pydantic.fields.ModelField.prepare
File "pydantic/fields.py", line 668, in pydantic.fields.ModelField._type_analysis
File "/usr/lib/python3.9/typing.py", line 835, in __subclasscheck__
return issubclass(cls, self.__origin__)
TypeError: issubclass() arg 1 must be a class
======================================================================
ERROR: frigate.test.test_storage (unittest.loader._FailedTest)
----------------------------------------------------------------------
ImportError: Failed to import test module: frigate.test.test_storage
Traceback (most recent call last):
File "/usr/lib/python3.9/unittest/loader.py", line 436, in _find_test_path
module = self._get_module_from_name(name)
File "/usr/lib/python3.9/unittest/loader.py", line 377, in _get_module_from_name
__import__(name)
File "/opt/frigate/frigate/test/test_storage.py", line 12, in <module>
from frigate.config import FrigateConfig
File "/opt/frigate/frigate/config.py", line 15, in <module>
from frigate.detectors import DetectorConfig, ModelConfig
File "/opt/frigate/frigate/detectors/__init__.py", line 3, in <module>
from .detector_types import DetectorTypeEnum, api_types
File "/opt/frigate/frigate/detectors/detector_types.py", line 25, in <module>
plugin_modules.append(importlib.import_module(name))
File "/usr/lib/python3.9/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "/opt/frigate/frigate/detectors/plugins/cpu_tfl.py", line 21, in <module>
class CpuDetectorConfig(BaseDetectorConfig):
File "pydantic/main.py", line 197, in pydantic.main.ModelMetaclass.__new__
File "pydantic/fields.py", line 506, in pydantic.fields.ModelField.infer
File "pydantic/fields.py", line 436, in pydantic.fields.ModelField.__init__
File "pydantic/fields.py", line 552, in pydantic.fields.ModelField.prepare
File "pydantic/fields.py", line 668, in pydantic.fields.ModelField._type_analysis
File "/usr/lib/python3.9/typing.py", line 835, in __subclasscheck__
return issubclass(cls, self.__origin__)
TypeError: issubclass() arg 1 must be a class
----------------------------------------------------------------------
Ran 20 tests in 0.053s
FAILED (errors=7) |
Looks like pydantic/pydantic#5821, but downgrading to typing-extensions<4.6.0 didn't make them go away for me. |
I don't see why this just started happening though, their last release was March 22 |
If you rebase on latest dev it's fixed |
d21330e
to
a3e85b1
Compare
Rebased. The following issue will remain until #6579 is on dev and I rebase another time.
Should be good to go otherwise. |
This is about the typing-extensions 4.6.0 bump, not a pydantic update. |
The tests on dev are failing for me with the same error. ======================================================================
ERROR: test_detector_custom_model_path (frigate.test.test_config.TestConfig)
----------------------------------------------------------------------
Traceback (most recent call last):
File "/opt/frigate/frigate/test/test_config.py", line 93, in test_detector_custom_model_path
runtime_config = frigate_config.runtime_config()
File "/opt/frigate/frigate/config.py", line 1030, in runtime_config
detector_config: DetectorConfig = parse_obj_as(DetectorConfig, detector)
File "pydantic/tools.py", line 38, in pydantic.tools.parse_obj_as
File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for ParsingModel[Annotated[Union[frigate.detectors.plugins.cpu_tfl.CpuDetectorConfig, frigate.detectors.plugins.deepstack.DeepstackDetectorConfig, frigate.detectors.plugins.edgetpu_tfl.EdgeTpuDetectorConfig, frigate.detectors.plugins.tensorrt.TensorRTDetectorConfig], FieldInfo(default=PydanticUndefined, discriminator='type', extra={})]]
__root__
No match for discriminator 'type' and value 'openvino' (allowed values: 'cpu', 'deepstack', 'edgetpu', 'tensorrt') (type=value_error.discriminated_union.invalid_discriminator; discriminator_key=type; discriminator_value=openvino; allowed_values='cpu', 'deepstack', 'edgetpu', 'tensorrt')
---------------------------------------------------------------------- |
Looks like a different error to me? also, my commit this morning fixed the tests and confirmed with new test run |
Yeah, but running the tests against dev again shows they are failing now. This is a different error of course. I run the tests like so:
|
And now it succeeded again. Possibly flaky. |
Both linters are pretty common among modern python code bases. The isort tool provides stable sorting and grouping, as well as pruning of unused imports. Ruff is a modern linter, that is very fast due to being written in rust. It can detect many common issues in a python codebase. Removes the pylint dev requirement, since ruff replaces it.
This is necessary for escape sequences to be properly recognized.
Is there a reason to have both ruff and black here? There is a vscode extension for ruff as well. |
Ruff is only a generic linter, it finds all sorts of quirks like that Again, not a vscode user, so my exposure to its extensions is very limited. Feel free to update the devcontainer accordingly. |
The idea of this PR is to gauge interest in setting up these linters. Both are pretty common among modern python code bases. If there is interest to add these linters I can take care of making the CI go green.
https://github.com/PyCQA/isort
https://github.com/charliermarsh/ruff
Removes the pylint dev requirement, since ruff replaces it.
Previews:
ruff
isort
logger = logging.getLogger(name)
diff --git a/frigate/comms/mqtt.py b/frigate/comms/mqtt.py
index 37fdd44..5c58f2f 100644
--- a/frigate/comms/mqtt.py
+++ b/frigate/comms/mqtt.py
@@ -1,6 +1,5 @@
import logging
import threading
from typing import Any, Callable
import paho.mqtt.client as mqtt
@@ -8,7 +7,6 @@ import paho.mqtt.client as mqtt
from frigate.comms.dispatcher import Communicator
from frigate.config import FrigateConfig
logger = logging.getLogger(name)
diff --git a/frigate/comms/ws.py b/frigate/comms/ws.py
index c9cc398..606d705 100644
--- a/frigate/comms/ws.py
+++ b/frigate/comms/ws.py
@@ -3,10 +3,9 @@
import json
import logging
import threading
from typing import Callable
from wsgiref.simple_server import make_server
+
from ws4py.server.wsgirefserver import (
WebSocketWSGIHandler,
WebSocketWSGIRequestHandler,
@@ -18,7 +17,6 @@ from ws4py.websocket import WebSocket
from frigate.comms.dispatcher import Communicator
from frigate.config import FrigateConfig
logger = logging.getLogger(name)
diff --git a/frigate/config.py b/frigate/config.py
index 56e4dc4..ea10d70 100644
--- a/frigate/config.py
+++ b/frigate/config.py
@@ -9,25 +9,17 @@ from typing import Dict, List, Optional, Tuple, Union
import matplotlib.pyplot as plt
import numpy as np
import yaml
-from pydantic import BaseModel, Extra, Field, validator, parse_obj_as
+from pydantic import BaseModel, Extra, Field, parse_obj_as, validator
from pydantic.fields import PrivateAttr
-from frigate.const import (
+from frigate.const import CACHE_DIR, DEFAULT_DB_PATH, REGEX_CAMERA_NAME, YAML_EXT
+from frigate.detectors import (
)
from frigate.detectors.detector_config import BaseDetectorConfig
-from frigate.plus import PlusApi
-from frigate.util import (
-)
from frigate.ffmpeg_presets import (
parse_preset_hardware_acceleration_decode,
parse_preset_hardware_acceleration_scale,
@@ -35,15 +27,17 @@ from frigate.ffmpeg_presets import (
parse_preset_output_record,
parse_preset_output_rtmp,
)
-from frigate.detectors import (
+from frigate.plus import PlusApi
+from frigate.util import (
)
from frigate.version import VERSION
logger = logging.getLogger(name)
TODO: Identify what the default format to display timestamps is
diff --git a/frigate/detectors/init.py b/frigate/detectors/init.py
index 7cbd82f..a19eed2 100644
--- a/frigate/detectors/init.py
+++ b/frigate/detectors/init.py
@@ -1,13 +1,8 @@
import logging
from .detection_api import DetectionApi
-from .detector_config import (
-)
-from .detector_types import DetectorTypeEnum, api_types, DetectorConfig
+from .detector_config import InputTensorEnum, ModelConfig, PixelFormatEnum
+from .detector_types import DetectorConfig, DetectorTypeEnum, api_types
logger = logging.getLogger(name)
diff --git a/frigate/detectors/detection_api.py b/frigate/detectors/detection_api.py
index 60a90b1..f829da2 100644
--- a/frigate/detectors/detection_api.py
+++ b/frigate/detectors/detection_api.py
@@ -1,7 +1,6 @@
import logging
from abc import ABC, abstractmethod
logger = logging.getLogger(name)
diff --git a/frigate/detectors/detector_config.py b/frigate/detectors/detector_config.py
index e949065..c192913 100644
--- a/frigate/detectors/detector_config.py
+++ b/frigate/detectors/detector_config.py
@@ -1,20 +1,18 @@
import hashlib
import json
import logging
-from enum import Enum
import os
-from typing import Dict, List, Optional, Tuple, Union, Literal
+from enum import Enum
+from typing import Dict, List, Literal, Optional, Tuple, Union
-import requests
import matplotlib.pyplot as plt
+import requests
from pydantic import BaseModel, Extra, Field, validator
from pydantic.fields import PrivateAttr
-from frigate.plus import PlusApi
+from frigate.plus import PlusApi
from frigate.util import load_labels
logger = logging.getLogger(name)
diff --git a/frigate/detectors/detector_types.py b/frigate/detectors/detector_types.py
index 5c96b2e..418fcd6 100644
--- a/frigate/detectors/detector_types.py
+++ b/frigate/detectors/detector_types.py
@@ -1,16 +1,16 @@
-import logging
import importlib
+import logging
import pkgutil
-from typing import Union
-from typing_extensions import Annotated
from enum import Enum
+from typing import Union
+
from pydantic import Field
+from typing_extensions import Annotated
from . import plugins
from .detection_api import DetectionApi
from .detector_config import BaseDetectorConfig
logger = logging.getLogger(name)
diff --git a/frigate/detectors/plugins/cpu_tfl.py b/frigate/detectors/plugins/cpu_tfl.py
index b22ac9a..2a73434 100644
--- a/frigate/detectors/plugins/cpu_tfl.py
+++ b/frigate/detectors/plugins/cpu_tfl.py
@@ -1,10 +1,11 @@
import logging
+from typing import Literal
+
import numpy as np
+from pydantic import Extra, Field
from frigate.detectors.detection_api import DetectionApi
from frigate.detectors.detector_config import BaseDetectorConfig
-from typing import Literal
-from pydantic import Extra, Field
try:
from tflite_runtime.interpreter import Interpreter
diff --git a/frigate/detectors/plugins/deepstack.py b/frigate/detectors/plugins/deepstack.py
index 9f3d323..1fd61f5 100644
--- a/frigate/detectors/plugins/deepstack.py
+++ b/frigate/detectors/plugins/deepstack.py
@@ -1,14 +1,14 @@
+import io
import logging
+from typing import Literal
+
import numpy as np
import requests
-import io
+from PIL import Image
+from pydantic import Extra, Field
from frigate.detectors.detection_api import DetectionApi
from frigate.detectors.detector_config import BaseDetectorConfig
-from typing import Literal
-from pydantic import Extra, Field
-from PIL import Image
logger = logging.getLogger(name)
diff --git a/frigate/detectors/plugins/edgetpu_tfl.py b/frigate/detectors/plugins/edgetpu_tfl.py
index 6837adc..5980dc4 100644
--- a/frigate/detectors/plugins/edgetpu_tfl.py
+++ b/frigate/detectors/plugins/edgetpu_tfl.py
@@ -1,10 +1,11 @@
import logging
+from typing import Literal
+
import numpy as np
+from pydantic import Extra, Field
from frigate.detectors.detection_api import DetectionApi
from frigate.detectors.detector_config import BaseDetectorConfig
-from typing import Literal
-from pydantic import Extra, Field
try:
from tflite_runtime.interpreter import Interpreter, load_delegate
diff --git a/frigate/detectors/plugins/openvino.py b/frigate/detectors/plugins/openvino.py
index 993b2b8..fe85d60 100644
--- a/frigate/detectors/plugins/openvino.py
+++ b/frigate/detectors/plugins/openvino.py
@@ -1,12 +1,12 @@
import logging
+from typing import Literal
+
import numpy as np
import openvino.runtime as ov
+from pydantic import Extra, Field
from frigate.detectors.detection_api import DetectionApi
from frigate.detectors.detector_config import BaseDetectorConfig, ModelTypeEnum
-from typing import Literal
-from pydantic import Extra, Field
logger = logging.getLogger(name)
diff --git a/frigate/detectors/plugins/tensorrt.py b/frigate/detectors/plugins/tensorrt.py
index 2d2a678..15b58bc 100644
--- a/frigate/detectors/plugins/tensorrt.py
+++ b/frigate/detectors/plugins/tensorrt.py
@@ -1,6 +1,6 @@
+import ctypes
import logging
-import ctypes
import numpy as np
try:
@@ -11,11 +11,13 @@ try:
except ModuleNotFoundError as e:
TRT_SUPPORT = False
-from frigate.detectors.detection_api import DetectionApi
-from frigate.detectors.detector_config import BaseDetectorConfig
from typing import Literal
+
from pydantic import Field
+from frigate.detectors.detection_api import DetectionApi
+from frigate.detectors.detector_config import BaseDetectorConfig
+
logger = logging.getLogger(name)
DETECTOR_KEY = "tensorrt"
diff --git a/frigate/events/cleanup.py b/frigate/events/cleanup.py
index 09b1964..3f1637e 100644
--- a/frigate/events/cleanup.py
+++ b/frigate/events/cleanup.py
@@ -4,7 +4,7 @@ import datetime
import logging
import os
import threading
+from multiprocessing.synchronize import Event as MpEvent
from pathlib import Path
from peewee import fn
@@ -13,8 +13,6 @@ from frigate.config import FrigateConfig
from frigate.const import CLIPS_DIR
from frigate.models import Event
-from multiprocessing.synchronize import Event as MpEvent
logger = logging.getLogger(name)
diff --git a/frigate/events/external.py b/frigate/events/external.py
index ee2906e..6266bd0 100644
--- a/frigate/events/external.py
+++ b/frigate/events/external.py
@@ -1,17 +1,16 @@
"""Handle external events created by the user."""
import base64
-import cv2
import datetime
import glob
import logging
import os
import random
import string
+from multiprocessing.queues import Queue
from typing import Optional
-from multiprocessing.queues import Queue
+import cv2
from frigate.config import CameraConfig, FrigateConfig
from frigate.const import CLIPS_DIR
diff --git a/frigate/events/maintainer.py b/frigate/events/maintainer.py
index 898218e..c871daf 100644
--- a/frigate/events/maintainer.py
+++ b/frigate/events/maintainer.py
@@ -2,8 +2,10 @@ import datetime
import logging
import queue
import threading
from enum import Enum
+from multiprocessing.queues import Queue
+from multiprocessing.synchronize import Event as MpEvent
+from typing import Dict
from peewee import fn
@@ -12,10 +14,6 @@ from frigate.models import Event
from frigate.types import CameraMetricsTypes
from frigate.util import to_relative_box
-from multiprocessing.queues import Queue
-from multiprocessing.synchronize import Event as MpEvent
-from typing import Dict
logger = logging.getLogger(name)
diff --git a/frigate/ffmpeg_presets.py b/frigate/ffmpeg_presets.py
index 353a8b9..d78cd72 100644
--- a/frigate/ffmpeg_presets.py
+++ b/frigate/ffmpeg_presets.py
@@ -2,13 +2,11 @@
import logging
import os
from typing import Any
-from frigate.version import VERSION
from frigate.const import BTBN_PATH
from frigate.util import vainfo_hwaccel
+from frigate.version import VERSION
logger = logging.getLogger(name)
diff --git a/frigate/http.py b/frigate/http.py
index de9fd03..e8fbf00 100644
--- a/frigate/http.py
+++ b/frigate/http.py
@@ -1,23 +1,20 @@
import base64
-from datetime import datetime, timedelta, timezone
import copy
-import logging
import glob
import json
+import logging
import os
import subprocess as sp
-import pytz
import time
import traceback
+from datetime import datetime, timedelta, timezone
from functools import reduce
from pathlib import Path
-from tzlocal import get_localzone_name
from urllib.parse import unquote
import cv2
import numpy as np
+import pytz
from flask import (
Blueprint,
Flask,
@@ -27,26 +24,26 @@ from flask import (
make_response,
request,
)
-from peewee import SqliteDatabase, operator, fn, DoesNotExist
+from peewee import DoesNotExist, SqliteDatabase, fn, operator
from playhouse.shortcuts import model_to_dict
+from tzlocal import get_localzone_name
from frigate.config import FrigateConfig
from frigate.const import CLIPS_DIR, MAX_SEGMENT_DURATION, RECORD_DIR
-from frigate.models import Event, Recordings, Timeline
from frigate.events.external import ExternalEventProcessor
+from frigate.models import Event, Recordings, Timeline
from frigate.object_processing import TrackedObject
from frigate.plus import PlusApi
from frigate.ptz import OnvifController
from frigate.stats import stats_snapshot
+from frigate.storage import StorageMaintainer
from frigate.util import (
clean_camera_user_pass,
ffprobe_stream,
restart_frigate,
vainfo_hwaccel,
)
-from frigate.storage import StorageMaintainer
from frigate.version import VERSION
logger = logging.getLogger(name)
diff --git a/frigate/log.py b/frigate/log.py
index 6786694..aea550c 100644
--- a/frigate/log.py
+++ b/frigate/log.py
@@ -1,18 +1,17 @@
adapted from https://medium.com/@jonathonbao/python3-logging-with-multiprocessing-f51f460b8778
import logging
-import threading
+import multiprocessing as mp
import os
-import signal
import queue
-import multiprocessing as mp
-from multiprocessing.queues import Queue
+import signal
+import threading
+from collections import deque
from logging import handlers
-from typing import Optional
+from multiprocessing.queues import Queue
from types import FrameType
-from setproctitle import setproctitle
from typing import Deque, Optional
-from types import FrameType
-from collections import deque
+
+from setproctitle import setproctitle
from frigate.util import clean_camera_user_pass
diff --git a/frigate/models.py b/frigate/models.py
index 0d5f1ab..aae2beb 100644
--- a/frigate/models.py
+++ b/frigate/models.py
@@ -1,12 +1,12 @@
from numpy import unique
from peewee import (
CharField,
DateTimeField,
FloatField,
IntegerField,
)
from playhouse.sqlite_ext import JSONField
diff --git a/frigate/motion.py b/frigate/motion.py
index 5580803..19d1629 100644
--- a/frigate/motion.py
+++ b/frigate/motion.py
@@ -1,6 +1,7 @@
import cv2
import imutils
import numpy as np
+
from frigate.config import MotionConfig
diff --git a/frigate/object_detection.py b/frigate/object_detection.py
index 129fd6b..35d4bec 100644
--- a/frigate/object_detection.py
+++ b/frigate/object_detection.py
@@ -12,7 +12,6 @@ from setproctitle import setproctitle
from frigate.config import InputTensorEnum
from frigate.detectors import create_detector
from frigate.util import EventsPerSecond, SharedMemoryFrameManager, listen, load_labels
logger = logging.getLogger(name)
diff --git a/frigate/object_processing.py b/frigate/object_processing.py
index 3088857..9e4397f 100644
--- a/frigate/object_processing.py
+++ b/frigate/object_processing.py
@@ -15,10 +15,10 @@ import numpy as np
from frigate.comms.dispatcher import Dispatcher
from frigate.config import (
CameraConfig,
MqttConfig,
RecordConfig,
)
from frigate.const import CLIPS_DIR
from frigate.events.maintainer import EventTypeEnum
diff --git a/frigate/output.py b/frigate/output.py
index 79a0818..1cdf991 100644
--- a/frigate/output.py
+++ b/frigate/output.py
@@ -3,8 +3,8 @@ import glob
import logging
import math
import multiprocessing as mp
-import os
import operator
+import os
import queue
import signal
import subprocess as sp
diff --git a/frigate/plus.py b/frigate/plus.py
index 7ba67a6..f2b30df 100644
--- a/frigate/plus.py
+++ b/frigate/plus.py
@@ -4,11 +4,13 @@ import logging
import os
import re
from typing import Any, Dict, List
-import requests
-from frigate.const import PLUS_ENV_VAR, PLUS_API_HOST
-from requests.models import Response
import cv2
+import requests
from numpy import ndarray
+from requests.models import Response
+
+from frigate.const import PLUS_API_HOST, PLUS_ENV_VAR
logger = logging.getLogger(name)
diff --git a/frigate/ptz.py b/frigate/ptz.py
index a52006b..44efc83 100644
--- a/frigate/ptz.py
+++ b/frigate/ptz.py
@@ -2,13 +2,12 @@
import logging
import site
from enum import Enum
+
from onvif import ONVIFCamera, ONVIFError
from frigate.config import FrigateConfig
logger = logging.getLogger(name)
diff --git a/frigate/record/cleanup.py b/frigate/record/cleanup.py
index 605979e..0396ef8 100644
--- a/frigate/record/cleanup.py
+++ b/frigate/record/cleanup.py
@@ -5,12 +5,12 @@ import itertools
import logging
import os
import threading
+from multiprocessing.synchronize import Event as MpEvent
from pathlib import Path
from peewee import DoesNotExist
-from multiprocessing.synchronize import Event as MpEvent
-from frigate.config import RetainModeEnum, FrigateConfig
+from frigate.config import FrigateConfig, RetainModeEnum
from frigate.const import RECORD_DIR, SECONDS_IN_DAY
from frigate.models import Event, Recordings, Timeline
from frigate.record.util import remove_empty_directories
diff --git a/frigate/record/maintainer.py b/frigate/record/maintainer.py
index 651bd12..0a19945 100644
--- a/frigate/record/maintainer.py
+++ b/frigate/record/maintainer.py
@@ -9,14 +9,14 @@ import random
import string
import subprocess as sp
import threading
-import psutil
from collections import defaultdict
from multiprocessing.synchronize import Event as MpEvent
from pathlib import Path
from typing import Any, Tuple
-from frigate.config import RetainModeEnum, FrigateConfig
+import psutil
+
+from frigate.config import FrigateConfig, RetainModeEnum
from frigate.const import CACHE_DIR, MAX_SEGMENT_DURATION, RECORD_DIR
from frigate.models import Event, Recordings
from frigate.types import RecordMetricsTypes
diff --git a/frigate/record/record.py b/frigate/record/record.py
index 59fda09..3aaf564 100644
--- a/frigate/record/record.py
+++ b/frigate/record/record.py
@@ -4,12 +4,11 @@ import logging
import multiprocessing as mp
import signal
import threading
-from setproctitle import setproctitle
from types import FrameType
from typing import Optional
from playhouse.sqliteq import SqliteQueueDatabase
+from setproctitle import setproctitle
from frigate.config import FrigateConfig
from frigate.models import Event, Recordings, Timeline
diff --git a/frigate/stats.py b/frigate/stats.py
index 55db809..a9e3d44 100644
--- a/frigate/stats.py
+++ b/frigate/stats.py
@@ -1,23 +1,29 @@
import asyncio
import json
import logging
+import os
+import shutil
import threading
import time
+from multiprocessing.synchronize import Event as MpEvent
+from typing import Any, Optional
+
import psutil
-import shutil
-import os
import requests
-from typing import Optional, Any
-from multiprocessing.synchronize import Event as MpEvent
from frigate.comms.dispatcher import Dispatcher
from frigate.config import FrigateConfig
-from frigate.const import DRIVER_AMD, DRIVER_ENV_VAR, RECORD_DIR, CLIPS_DIR, CACHE_DIR
-from frigate.types import StatsTrackingTypes, CameraMetricsTypes
-from frigate.util import get_amd_gpu_stats, get_intel_gpu_stats, get_nvidia_gpu_stats
-from frigate.version import VERSION
-from frigate.util import get_cpu_stats, get_bandwidth_stats
+from frigate.const import CACHE_DIR, CLIPS_DIR, DRIVER_AMD, DRIVER_ENV_VAR, RECORD_DIR
from frigate.object_detection import ObjectDetectProcess
+from frigate.types import CameraMetricsTypes, StatsTrackingTypes
+from frigate.util import (
+)
+from frigate.version import VERSION
logger = logging.getLogger(name)
diff --git a/frigate/storage.py b/frigate/storage.py
index 5b66abb..7068924 100644
--- a/frigate/storage.py
+++ b/frigate/storage.py
@@ -1,9 +1,9 @@
"""Handle storage retention and usage."""
import logging
-from pathlib import Path
import shutil
import threading
+from pathlib import Path
from peewee import fn
diff --git a/frigate/test/test_config.py b/frigate/test/test_config.py
index 7cd5e22..97ceeb4 100644
--- a/frigate/test/test_config.py
+++ b/frigate/test/test_config.py
@@ -1,13 +1,11 @@
import json
import os
import unittest
+
import numpy as np
from pydantic import ValidationError
-from frigate.config import (
-)
+from frigate.config import BirdseyeModeEnum, FrigateConfig
from frigate.const import MODEL_CACHE_DIR
from frigate.detectors import DetectorTypeEnum
from frigate.plus import PlusApi
diff --git a/frigate/test/test_copy_yuv_to_position.py b/frigate/test/test_copy_yuv_to_position.py
index 16c97b7..33582e2 100644
--- a/frigate/test/test_copy_yuv_to_position.py
+++ b/frigate/test/test_copy_yuv_to_position.py
@@ -1,7 +1,9 @@
+from unittest import TestCase, main
import cv2
import numpy as np
-from unittest import TestCase, main
-from frigate.util import get_yuv_crop, copy_yuv_to_position
+
+from frigate.util import copy_yuv_to_position, get_yuv_crop
class TestCopyYuvToPosition(TestCase):
diff --git a/frigate/test/test_ffmpeg_presets.py b/frigate/test/test_ffmpeg_presets.py
index 92e0fa3..0d3dab8 100644
--- a/frigate/test/test_ffmpeg_presets.py
+++ b/frigate/test/test_ffmpeg_presets.py
@@ -1,4 +1,5 @@
import unittest
+
from frigate.config import FFMPEG_INPUT_ARGS_DEFAULT, FrigateConfig
from frigate.ffmpeg_presets import parse_preset_input
diff --git a/frigate/test/test_http.py b/frigate/test/test_http.py
index ecb5003..12962f4 100644
--- a/frigate/test/test_http.py
+++ b/frigate/test/test_http.py
@@ -6,15 +6,14 @@ import unittest
from unittest.mock import patch
from peewee_migrate import Router
+from playhouse.shortcuts import model_to_dict
from playhouse.sqlite_ext import SqliteExtDatabase
from playhouse.sqliteq import SqliteQueueDatabase
-from playhouse.shortcuts import model_to_dict
from frigate.config import FrigateConfig
from frigate.http import create_app
from frigate.models import Event, Recordings
from frigate.plus import PlusApi
from frigate.test.const import TEST_DB, TEST_DB_CLEANUPS
diff --git a/frigate/test/test_object_detector.py b/frigate/test/test_object_detector.py
index 9cdeeb6..1e1efa9 100644
--- a/frigate/test/test_object_detector.py
+++ b/frigate/test/test_object_detector.py
@@ -4,10 +4,10 @@ from unittest.mock import Mock, patch
import numpy as np
from pydantic import parse_obj_as
-from frigate.config import DetectorConfig, InputTensorEnum, ModelConfig
-from frigate.detectors import DetectorTypeEnum
import frigate.detectors as detectors
import frigate.object_detection
+from frigate.config import DetectorConfig, InputTensorEnum, ModelConfig
+from frigate.detectors import DetectorTypeEnum
class TestLocalObjectDetector(unittest.TestCase):
diff --git a/frigate/test/test_reduce_boxes.py b/frigate/test/test_reduce_boxes.py
index 69d6f71..5333ffe 100644
--- a/frigate/test/test_reduce_boxes.py
+++ b/frigate/test/test_reduce_boxes.py
@@ -1,5 +1,7 @@
-import numpy as np
from unittest import TestCase, main
+
+import numpy as np
+
from frigate.video import box_overlaps, reduce_boxes
diff --git a/frigate/test/test_storage.py b/frigate/test/test_storage.py
index 22ea6fc..a9c89f2 100644
--- a/frigate/test/test_storage.py
+++ b/frigate/test/test_storage.py
@@ -7,15 +7,14 @@ from unittest.mock import MagicMock, patch
from peewee import DoesNotExist
from peewee_migrate import Router
+from playhouse.shortcuts import model_to_dict
from playhouse.sqlite_ext import SqliteExtDatabase
from playhouse.sqliteq import SqliteQueueDatabase
-from playhouse.shortcuts import model_to_dict
from frigate.config import FrigateConfig
from frigate.http import create_app
from frigate.models import Event, Recordings
from frigate.storage import StorageMaintainer
from frigate.test.const import TEST_DB, TEST_DB_CLEANUPS
diff --git a/frigate/test/test_yuv_region_2_rgb.py b/frigate/test/test_yuv_region_2_rgb.py
index 96f4215..9f1c299 100644
--- a/frigate/test/test_yuv_region_2_rgb.py
+++ b/frigate/test/test_yuv_region_2_rgb.py
@@ -1,6 +1,8 @@
+from unittest import TestCase, main
+
import cv2
import numpy as np
-from unittest import TestCase, main
+
from frigate.util import yuv_region_2_rgb
diff --git a/frigate/timeline.py b/frigate/timeline.py
index e40549d..9ca617b 100644
--- a/frigate/timeline.py
+++ b/frigate/timeline.py
@@ -1,16 +1,14 @@
"""Record events for object, audio, etc. detections."""
import logging
-import threading
import queue
+import threading
+from multiprocessing.queues import Queue
+from multiprocessing.synchronize import Event as MpEvent
from frigate.config import FrigateConfig
from frigate.events.maintainer import EventTypeEnum
from frigate.models import Timeline
-from multiprocessing.queues import Queue
-from multiprocessing.synchronize import Event as MpEvent
from frigate.util import to_relative_box
logger = logging.getLogger(name)
diff --git a/frigate/types.py b/frigate/types.py
index 3cc401e..8c3e546 100644
--- a/frigate/types.py
+++ b/frigate/types.py
@@ -1,7 +1,7 @@
-from typing import Optional, TypedDict
+from multiprocessing.context import Process
from multiprocessing.queues import Queue
from multiprocessing.sharedctypes import Synchronized
-from multiprocessing.context import Process
+from typing import Optional, TypedDict
from frigate.object_detection import ObjectDetectProcess
diff --git a/frigate/util.py b/frigate/util.py
index 47b7b43..2f427e2 100755
--- a/frigate/util.py
+++ b/frigate/util.py
@@ -1,28 +1,26 @@
import copy
import datetime
-import logging
-import shlex
-import subprocess as sp
import json
+import logging
+import os
import re
+import shlex
import signal
+import subprocess as sp
import traceback
import urllib.parse
-import yaml
-import os
from abc import ABC, abstractmethod
from collections import Counter
from collections.abc import Mapping
from multiprocessing import shared_memory
from typing import Any, AnyStr, Optional, Tuple
-import py3nvml.py3nvml as nvml
import cv2
import numpy as np
-import os
import psutil
+import py3nvml.py3nvml as nvml
import pytz
+import yaml
from frigate.const import REGEX_HTTP_CAMERA_USER_PASS, REGEX_RTSP_CAMERA_USER_PASS
diff --git a/frigate/video.py b/frigate/video.py
index a3356a5..97ce8de 100755
--- a/frigate/video.py
+++ b/frigate/video.py
@@ -10,15 +10,15 @@ import threading
import time
from collections import defaultdict
-import numpy as np
import cv2
+import numpy as np
from setproctitle import setproctitle
from frigate.config import CameraConfig, DetectConfig, PixelFormatEnum
from frigate.const import CACHE_DIR
-from frigate.object_detection import RemoteObjectDetector
from frigate.log import LogPipe
from frigate.motion import MotionDetector
+from frigate.object_detection import RemoteObjectDetector
from frigate.objects import ObjectTracker
from frigate.util import (
EventsPerSecond,
@@ -30,8 +30,8 @@ from frigate.util import (
intersection,
intersection_over_union,
listen,
yuv_region_2_bgr,
yuv_region_2_yuv,
)
diff --git a/frigate/watchdog.py b/frigate/watchdog.py
index 5df826f..81e846c 100644
--- a/frigate/watchdog.py
+++ b/frigate/watchdog.py
@@ -1,13 +1,13 @@
import datetime
import logging
-import threading
-import time
import os
import signal
+import threading
+import time
+from multiprocessing.synchronize import Event as MpEvent
from frigate.object_detection import ObjectDetectProcess
from frigate.util import restart_frigate
-from multiprocessing.synchronize import Event as MpEvent
logger = logging.getLogger(name)
diff --git a/migrations/001_create_events_table.py b/migrations/001_create_events_table.py
index d9b0f08..2de1efc 100644
--- a/migrations/001_create_events_table.py
+++ b/migrations/001_create_events_table.py
@@ -22,9 +22,10 @@ Some examples (model - class or model name)::
"""
import datetime as dt
-import peewee as pw
from decimal import ROUND_HALF_EVEN
+import peewee as pw
+
try:
import playhouse.postgres_ext as pw_pext
except ImportError:
diff --git a/migrations/002_add_clip_snapshot.py b/migrations/002_add_clip_snapshot.py
index aaa4a03..aac16f6 100644
--- a/migrations/002_add_clip_snapshot.py
+++ b/migrations/002_add_clip_snapshot.py
@@ -22,8 +22,10 @@ Some examples (model - class or model name)::
"""
import datetime as dt
-import peewee as pw
from decimal import ROUND_HALF_EVEN
+
+import peewee as pw
+
from frigate.models import Event
try:
diff --git a/migrations/004_add_bbox_region_area.py b/migrations/004_add_bbox_region_area.py
index bcc362a..ae77676 100644
--- a/migrations/004_add_bbox_region_area.py
+++ b/migrations/004_add_bbox_region_area.py
@@ -22,9 +22,11 @@ Some examples (model - class or model name)::
"""
import datetime as dt
+from decimal import ROUND_HALF_EVEN
+
import peewee as pw
from playhouse.sqlite_ext import *
-from decimal import ROUND_HALF_EVEN
+
from frigate.models import Event
try:
diff --git a/migrations/005_make_end_time_nullable.py b/migrations/005_make_end_time_nullable.py
index 5c8cf65..b53b2bf 100644
--- a/migrations/005_make_end_time_nullable.py
+++ b/migrations/005_make_end_time_nullable.py
@@ -22,9 +22,11 @@ Some examples (model - class or model name)::
"""
import datetime as dt
+from decimal import ROUND_HALF_EVEN
+
import peewee as pw
from playhouse.sqlite_ext import *
-from decimal import ROUND_HALF_EVEN
+
from frigate.models import Event
try:
diff --git a/migrations/006_add_motion_active_objects.py b/migrations/006_add_motion_active_objects.py
index 6bd564b..e3c56ea 100644
--- a/migrations/006_add_motion_active_objects.py
+++ b/migrations/006_add_motion_active_objects.py
@@ -22,9 +22,11 @@ Some examples (model - class or model name)::
"""
import datetime as dt
+from decimal import ROUND_HALF_EVEN
+
import peewee as pw
from playhouse.sqlite_ext import *
-from decimal import ROUND_HALF_EVEN
+
from frigate.models import Recordings
try:
diff --git a/migrations/007_add_retain_indefinitely.py b/migrations/007_add_retain_indefinitely.py
index a46b72e..6c102dd 100644
--- a/migrations/007_add_retain_indefinitely.py
+++ b/migrations/007_add_retain_indefinitely.py
@@ -22,9 +22,11 @@ Some examples (model - class or model name)::
"""
import datetime as dt
+from decimal import ROUND_HALF_EVEN
+
import peewee as pw
from playhouse.sqlite_ext import *
-from decimal import ROUND_HALF_EVEN
+
from frigate.models import Event
try:
diff --git a/migrations/008_add_sub_label.py b/migrations/008_add_sub_label.py
index 00603c6..06ca9d5 100644
--- a/migrations/008_add_sub_label.py
+++ b/migrations/008_add_sub_label.py
@@ -22,9 +22,11 @@ Some examples (model - class or model name)::
"""
import datetime as dt
+from decimal import ROUND_HALF_EVEN
+
import peewee as pw
from playhouse.sqlite_ext import *
-from decimal import ROUND_HALF_EVEN
+
from frigate.models import Event
try:
diff --git a/migrations/009_add_object_filter_ratio.py b/migrations/009_add_object_filter_ratio.py
index cc23e1d..e5a0068 100644
--- a/migrations/009_add_object_filter_ratio.py
+++ b/migrations/009_add_object_filter_ratio.py
@@ -22,6 +22,7 @@ Some examples (model - class or model name)::
"""
import peewee as pw
+
from frigate.models import Event
SQL = pw.SQL
diff --git a/migrations/010_add_plus_image_id.py b/migrations/010_add_plus_image_id.py
index 0e239e5..1004fce 100644
--- a/migrations/010_add_plus_image_id.py
+++ b/migrations/010_add_plus_image_id.py
@@ -22,9 +22,11 @@ Some examples (model - class or model name)::
"""
import datetime as dt
+from decimal import ROUND_HALF_EVEN
+
import peewee as pw
from playhouse.sqlite_ext import *
-from decimal import ROUND_HALF_EVEN
+
from frigate.models import Event
try:
diff --git a/migrations/012_add_segment_size.py b/migrations/012_add_segment_size.py
index c5ac1ed..6970242 100644
--- a/migrations/012_add_segment_size.py
+++ b/migrations/012_add_segment_size.py
@@ -22,9 +22,11 @@ Some examples (model - class or model name)::
"""
import datetime as dt
+from decimal import ROUND_HALF_EVEN
+
import peewee as pw
from playhouse.sqlite_ext import *
-from decimal import ROUND_HALF_EVEN
+
from frigate.models import Recordings
try:
diff --git a/migrations/013_create_timeline_table.py b/migrations/013_create_timeline_table.py
index fea7867..918a2e2 100644
--- a/migrations/013_create_timeline_table.py
+++ b/migrations/013_create_timeline_table.py
@@ -22,9 +22,11 @@ Some examples (model - class or model name)::
"""
import datetime as dt
+from decimal import ROUND_HALF_EVEN
+
import peewee as pw
from playhouse.sqlite_ext import *
-from decimal import ROUND_HALF_EVEN
+
from frigate.models import Recordings
try:
diff --git a/migrations/014_event_updates_for_fp.py b/migrations/014_event_updates_for_fp.py
index 5d07559..6678405 100644
--- a/migrations/014_event_updates_for_fp.py
+++ b/migrations/014_event_updates_for_fp.py
@@ -22,9 +22,11 @@ Some examples (model - class or model name)::
"""
import datetime as dt
+from decimal import ROUND_HALF_EVEN
+
import peewee as pw
from playhouse.sqlite_ext import *
-from decimal import ROUND_HALF_EVEN
+
from frigate.models import Event
try:
diff --git a/migrations/015_event_refactor.py b/migrations/015_event_refactor.py
index d8a8a38..af6c4dd 100644
--- a/migrations/015_event_refactor.py
+++ b/migrations/015_event_refactor.py
@@ -22,9 +22,11 @@ Some examples (model - class or model name)::
"""
import datetime as dt
+from decimal import ROUND_HALF_EVEN
+
import peewee as pw
from playhouse.sqlite_ext import *
-from decimal import ROUND_HALF_EVEN
+
from frigate.models import Event
try:
diff --git a/migrations/016_sublabel_increase.py b/migrations/016_sublabel_increase.py
index b46b9fc..e6bf5ea 100644
--- a/migrations/016_sublabel_increase.py
+++ b/migrations/016_sublabel_increase.py
@@ -1,6 +1,7 @@
import peewee as pw
from playhouse.migrate import *
from playhouse.sqlite_ext import *
+
from frigate.models import Event
diff --git a/process_clip.py b/process_clip.py
index d8dabbe..c3f9a8b 100644
--- a/process_clip.py
+++ b/process_clip.py
@@ -1,8 +1,10 @@
import sys
+
from typing_extensions import runtime
sys.path.append("/lab/frigate")
+import csv
import json
import logging
import multiprocessing as mp
@@ -11,20 +13,15 @@ import subprocess as sp
import sys
import click
-import csv
import cv2
import numpy as np
from frigate.config import FrigateConfig
-from frigate.object_detection import LocalObjectDetector
from frigate.motion import MotionDetector
+from frigate.object_detection import LocalObjectDetector
from frigate.object_processing import CameraState
from frigate.objects import ObjectTracker
-from frigate.util import (
-)
+from frigate.util import EventsPerSecond, SharedMemoryFrameManager, draw_box_with_label
from frigate.video import capture_frames, process_frames, start_or_restart_ffmpeg
logging.basicConfig()