fix: guard omnivoice import in loader.py so node classes are importable without package

Wrap `from omnivoice import OmniVoice` in a try/except ImportError, setting
OmniVoice=None when absent. Add a clear runtime ImportError in load_model()
so users get an actionable message. Allows `from nodes.loader import
OmniVoiceModelLoader` to succeed outside of pytest (where conftest.py injects
the mock) while keeping all 13 tests green.

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-04-05 09:11:09 +02:00
parent 18fe6359cf
commit 808580b771
+8
View File
@@ -1,7 +1,10 @@
import os import os
import torch import torch
try:
from omnivoice import OmniVoice from omnivoice import OmniVoice
except ImportError:
OmniVoice = None # deferred; will raise at runtime if package is missing
try: try:
import folder_paths import folder_paths
@@ -46,6 +49,11 @@ class OmniVoiceModelLoader:
CATEGORY = "OmniVoice" CATEGORY = "OmniVoice"
def load_model(self, model_source, device, dtype, local_path=""): def load_model(self, model_source, device, dtype, local_path=""):
if OmniVoice is None:
raise ImportError(
"omnivoice is not installed. Run: pip install omnivoice"
)
if model_source == "Local path" and local_path: if model_source == "Local path" and local_path:
source = local_path source = local_path
else: else: