-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy path__init__.py
59 lines (47 loc) · 1.81 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
import importlib
import os
import sys
import traceback
from pathlib import Path
import folder_paths
here = Path(__file__).parent.resolve()
comfy_path = folder_paths.base_path
sys.path.insert(0, str(Path(here, "").resolve()))
sys.path.insert(0, str(Path(here, "src").resolve()))
for pkg_name in os.listdir(str(Path(here, "src"))):
sys.path.insert(0, str(Path(here, "src", pkg_name).resolve()))
os.environ["PYTORCH_ENABLE_MPS_FALLBACK"] = '1'
def load_nodes():
shorted_errors = []
full_error_messages = []
node_class_mappings = {}
node_display_name_mappings = {}
for filename in (here / "node_wrappers").iterdir():
module_name = filename.stem
try:
module = importlib.import_module(
f".node_wrappers.{module_name}", package=__package__
)
node_class_mappings.update(getattr(module, "NODE_CLASS_MAPPINGS"))
if hasattr(module, "NODE_DISPLAY_NAME_MAPPINGS"):
node_display_name_mappings.update(getattr(module, "NODE_DISPLAY_NAME_MAPPINGS"))
except AttributeError:
pass # wip nodes
except Exception:
error_message = traceback.format_exc()
full_error_messages.append(error_message)
error_message = error_message.splitlines()[-1]
shorted_errors.append(
f"Failed to import module {module_name} because {error_message}"
)
if len(shorted_errors) > 0:
full_err_log = '\n\n'.join(full_error_messages)
print(f"\n\nFull error log from comfyui-hiforce-plugin: \n{full_err_log}\n\n")
return node_class_mappings, node_display_name_mappings
HF_NODE_MAPPINGS, HF_DISPLAY_NAME_MAPPINGS = load_nodes()
NODE_CLASS_MAPPINGS = {
**HF_NODE_MAPPINGS,
}
NODE_DISPLAY_NAME_MAPPINGS = {
**HF_DISPLAY_NAME_MAPPINGS,
}