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:
@@ -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:
|
||||||
|
|||||||
Reference in New Issue
Block a user