-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy path__init__.py
51 lines (42 loc) · 1.89 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
import importlib
import os
def do_install():
try:
# Construct the file path to install.py
install_script_path = os.path.join(os.path.dirname(__file__), "install.py")
# Check if the installation script actually exists
if not os.path.exists(install_script_path):
print("Captain says: Installation script not found. Please check the presence of 'install.py'.")
return
# Load and execute the installation script
spec = importlib.util.spec_from_file_location("captain_install", install_script_path)
captain_install = importlib.util.module_from_spec(spec)
spec.loader.exec_module(captain_install)
print("Captain says: Dependencies installed successfully.")
except Exception as e:
print(f"Captain says: Failed to install dependencies: {str(e)}")
# Ensure dependencies are installed before loading any custom nodes
do_install()
# List of node files
node_list = [
"join_text",
"openai_chat",
"openai_image_analysis",
"image_to_base64",
"preview_text"
]
NODE_CLASS_MAPPINGS = {}
NODE_DISPLAY_NAME_MAPPINGS = {}
WEB_DIRECTORY = "./web"
for module_name in node_list:
module_path = ".nodes." + module_name # Adjusted to include the subfolder
try:
imported_module = importlib.import_module(module_path, __name__)
NODE_CLASS_MAPPINGS = {**NODE_CLASS_MAPPINGS, **imported_module.NODE_CLASS_MAPPINGS}
if hasattr(imported_module, "NODE_DISPLAY_NAME_MAPPINGS"):
NODE_DISPLAY_NAME_MAPPINGS = {**NODE_DISPLAY_NAME_MAPPINGS, **imported_module.NODE_DISPLAY_NAME_MAPPINGS}
except ModuleNotFoundError as e:
print(f"Captain says: Failed to load module {module_name}. Error: {e}")
except Exception as e:
print(f"Captain says: An error occurred while loading module {module_name}. Error: {e}")
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS"]