Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
chenpangpang
ComfyUI
Commits
7da0147d
Commit
7da0147d
authored
Feb 15, 2023
by
Hacker 17082006
Browse files
Done custom_node import error fixing
parent
b67b6920
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
11 additions
and
5 deletions
+11
-5
custom_nodes/example_folder/main.py
custom_nodes/example_folder/main.py
+0
-0
nodes.py
nodes.py
+11
-5
No files found.
custom_nodes/example_folder/
__init__
.py
→
custom_nodes/example_folder/
main
.py
View file @
7da0147d
File moved
nodes.py
View file @
7da0147d
...
...
@@ -11,12 +11,13 @@ from PIL.PngImagePlugin import PngInfo
import
numpy
as
np
sys
.
path
.
insert
(
0
,
os
.
path
.
join
(
sys
.
path
[
0
],
"comfy"
))
sys
.
dont_write_bytecode
=
True
#No __pycache_ plz
import
comfy.samplers
import
comfy.sd
import
model_management
from
import
lib
import
import_module
import
import
lib
supported_ckpt_extensions
=
[
'.ckpt'
]
supported_pt_extensions
=
[
'.ckpt'
,
'.pt'
,
'.bin'
]
...
...
@@ -605,14 +606,19 @@ def load_custom_nodes():
possible_modules
.
remove
(
"example.py"
)
possible_modules
.
remove
(
"example_folder"
)
except
ValueError
:
pass
for
possible_module
in
possible_modules
:
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
try
:
custom_nodes
=
import_module
(
os
.
path
.
join
(
possible_module
,
CUSTOM_NODE_PATH
))
if
getattr
(
custom_nodes
,
"NODE_CLASS_MAPPINGS"
)
is
not
None
:
NODE_CLASS_MAPPINGS
.
update
(
custom_nodes
.
NODE_CLASS_MAPPINGS
)
if
os
.
path
.
isfile
(
module_path
):
module_spec
=
importlib
.
util
.
spec_from_file_location
(
os
.
path
.
basename
(
module_path
),
module_path
)
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
:
print
(
f
"Skip
{
possible_module
}
module for custom nodes due to the lack of NODE_CLASS_MAPPINGS."
)
except
ImportError
as
e
:
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment