From 2797a60d4f59c6dbf2f82829707c9cee1dddf46a Mon Sep 17 00:00:00 2001 From: Nicolas Mowen Date: Sun, 19 Feb 2023 06:41:14 -0700 Subject: [PATCH] Don't fail if openvino fails to import (#5532) * Don't fail if openvino fails to import * Ensure all modules are imported safely * Undo * Fix list append --- frigate/detectors/detector_types.py | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/frigate/detectors/detector_types.py b/frigate/detectors/detector_types.py index 1e2269c94..5c96b2e16 100644 --- a/frigate/detectors/detector_types.py +++ b/frigate/detectors/detector_types.py @@ -13,12 +13,19 @@ from .detector_config import BaseDetectorConfig logger = logging.getLogger(__name__) -plugin_modules = [ - importlib.import_module(name) - for finder, name, ispkg in pkgutil.iter_modules( - plugins.__path__, plugins.__name__ + "." - ) -] + +_included_modules = pkgutil.iter_modules(plugins.__path__, plugins.__name__ + ".") + +plugin_modules = [] + +for _, name, _ in _included_modules: + try: + # currently openvino may fail when importing + # on an arm device with 64 KiB page size. + plugin_modules.append(importlib.import_module(name)) + except ImportError as e: + logger.error(f"Error importing detector runtime: {e}") + api_types = {det.type_key: det for det in DetectionApi.__subclasses__()}