Skip to content

Commit

Permalink
Merge pull request #650 from roflcoopter/feature/darknet-retry-setup
Browse files Browse the repository at this point in the history
raise ComponentNotReady if darknet setup fails
  • Loading branch information
roflcoopter committed Jul 17, 2023
2 parents 813306c + 4ad64a2 commit 7df8ee5
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions viseron/components/darknet/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@
from viseron.domains.object_detector import BASE_CONFIG_SCHEMA
from viseron.domains.object_detector.const import CONFIG_CAMERAS
from viseron.domains.object_detector.detected_object import DetectedObject
from viseron.exceptions import ViseronError
from viseron.exceptions import ComponentNotReady, ViseronError
from viseron.helpers import letterbox_resize, pop_if_full
from viseron.helpers.child_process_worker import ChildProcessWorker
from viseron.helpers.logs import CTypesLogPipe
Expand Down Expand Up @@ -124,7 +124,10 @@ def setup(vis: Viseron, config: dict[str, Any]) -> bool:
and config[CONFIG_OBJECT_DETECTOR][CONFIG_DNN_BACKEND] is None
and config[CONFIG_OBJECT_DETECTOR][CONFIG_DNN_TARGET] is None
):
vis.data[COMPONENT] = DarknetNative(vis, config[CONFIG_OBJECT_DETECTOR])
try:
vis.data[COMPONENT] = DarknetNative(vis, config[CONFIG_OBJECT_DETECTOR])
except LoadDarknetError as error:
raise ComponentNotReady from error
else:
vis.data[COMPONENT] = DarknetDNN(vis, config[CONFIG_OBJECT_DETECTOR])

Expand Down

0 comments on commit 7df8ee5

Please sign in to comment.