mirror of
https://github.com/comfyanonymous/ComfyUI.git
synced 2025-01-11 02:15:17 +00:00
Done custom_node import error fixing
This commit is contained in:
parent
b67b6920d1
commit
7da0147d8a
16
nodes.py
16
nodes.py
@ -11,12 +11,13 @@ from PIL.PngImagePlugin import PngInfo
|
|||||||
import numpy as np
|
import numpy as np
|
||||||
|
|
||||||
sys.path.insert(0, os.path.join(sys.path[0], "comfy"))
|
sys.path.insert(0, os.path.join(sys.path[0], "comfy"))
|
||||||
|
sys.dont_write_bytecode = True #No __pycache_ plz
|
||||||
|
|
||||||
|
|
||||||
import comfy.samplers
|
import comfy.samplers
|
||||||
import comfy.sd
|
import comfy.sd
|
||||||
import model_management
|
import model_management
|
||||||
from importlib import import_module
|
import importlib
|
||||||
|
|
||||||
supported_ckpt_extensions = ['.ckpt']
|
supported_ckpt_extensions = ['.ckpt']
|
||||||
supported_pt_extensions = ['.ckpt', '.pt', '.bin']
|
supported_pt_extensions = ['.ckpt', '.pt', '.bin']
|
||||||
@ -605,14 +606,19 @@ def load_custom_nodes():
|
|||||||
possible_modules.remove("example.py")
|
possible_modules.remove("example.py")
|
||||||
possible_modules.remove("example_folder")
|
possible_modules.remove("example_folder")
|
||||||
except ValueError: pass
|
except ValueError: pass
|
||||||
|
|
||||||
for possible_module in possible_modules:
|
for possible_module in possible_modules:
|
||||||
module_path = os.path.join(CUSTOM_NODE_PATH, possible_module)
|
module_path = os.path.join(CUSTOM_NODE_PATH, possible_module)
|
||||||
if os.path.isfile(module_path) and os.path.splitext(module_path)[1] != ".py": continue
|
if os.path.isfile(module_path) and os.path.splitext(module_path)[1] != ".py": continue
|
||||||
|
|
||||||
try:
|
try:
|
||||||
custom_nodes = import_module(os.path.join(possible_module, CUSTOM_NODE_PATH))
|
if os.path.isfile(module_path):
|
||||||
if getattr(custom_nodes, "NODE_CLASS_MAPPINGS") is not None:
|
module_spec = importlib.util.spec_from_file_location(os.path.basename(module_path), module_path)
|
||||||
NODE_CLASS_MAPPINGS.update(custom_nodes.NODE_CLASS_MAPPINGS)
|
else:
|
||||||
|
module_spec = importlib.util.spec_from_file_location(module_path, "main.py")
|
||||||
|
module = importlib.util.module_from_spec(module_spec)
|
||||||
|
module_spec.loader.exec_module(module)
|
||||||
|
if getattr(module, "NODE_CLASS_MAPPINGS") is not None:
|
||||||
|
NODE_CLASS_MAPPINGS.update(module.NODE_CLASS_MAPPINGS)
|
||||||
else:
|
else:
|
||||||
print(f"Skip {possible_module} module for custom nodes due to the lack of NODE_CLASS_MAPPINGS.")
|
print(f"Skip {possible_module} module for custom nodes due to the lack of NODE_CLASS_MAPPINGS.")
|
||||||
except ImportError as e:
|
except ImportError as e:
|
||||||
|
Loading…
Reference in New Issue
Block a user