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
83f70a88
Unverified
Commit
83f70a88
authored
Jul 09, 2024
by
Chenlei Hu
Committed by
GitHub
Jul 09, 2024
Browse files
Add __module__ to node info (#3936)
Use more explicit name 'python_module' Parse abs ath Move parse to nodes.py
parent
f1a01c2c
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
27 additions
and
3 deletions
+27
-3
nodes.py
nodes.py
+26
-3
server.py
server.py
+1
-0
No files found.
nodes.py
View file @
83f70a88
...
@@ -1889,7 +1889,29 @@ NODE_DISPLAY_NAME_MAPPINGS = {
...
@@ -1889,7 +1889,29 @@ NODE_DISPLAY_NAME_MAPPINGS = {
EXTENSION_WEB_DIRS
=
{}
EXTENSION_WEB_DIRS
=
{}
def
load_custom_node
(
module_path
,
ignore
=
set
()):
def
get_relative_module_name
(
module_path
:
str
)
->
str
:
"""
Returns the module name based on the given module path.
Examples:
get_module_name("C:/Users/username/ComfyUI/custom_nodes/my_custom_node.py") -> "custom_nodes.my_custom_node"
get_module_name("C:/Users/username/ComfyUI/custom_nodes/my_custom_node") -> "custom_nodes.my_custom_node"
get_module_name("C:/Users/username/ComfyUI/custom_nodes/my_custom_node/") -> "custom_nodes.my_custom_node"
get_module_name("C:/Users/username/ComfyUI/custom_nodes/my_custom_node/__init__.py") -> "custom_nodes.my_custom_node"
get_module_name("C:/Users/username/ComfyUI/custom_nodes/my_custom_node/__init__") -> "custom_nodes.my_custom_node"
get_module_name("C:/Users/username/ComfyUI/custom_nodes/my_custom_node/__init__/") -> "custom_nodes.my_custom_node"
get_module_name("C:/Users/username/ComfyUI/custom_nodes/my_custom_node.disabled") -> "custom_nodes.my
Args:
module_path (str): The path of the module.
Returns:
str: The module name.
"""
relative_path
=
os
.
path
.
relpath
(
module_path
,
folder_paths
.
base_path
)
if
os
.
path
.
isfile
(
module_path
):
relative_path
=
os
.
path
.
splitext
(
relative_path
)[
0
]
return
relative_path
.
replace
(
os
.
sep
,
'.'
)
def
load_custom_node
(
module_path
:
str
,
ignore
=
set
())
->
bool
:
module_name
=
os
.
path
.
basename
(
module_path
)
module_name
=
os
.
path
.
basename
(
module_path
)
if
os
.
path
.
isfile
(
module_path
):
if
os
.
path
.
isfile
(
module_path
):
sp
=
os
.
path
.
splitext
(
module_path
)
sp
=
os
.
path
.
splitext
(
module_path
)
...
@@ -1913,9 +1935,10 @@ def load_custom_node(module_path, ignore=set()):
...
@@ -1913,9 +1935,10 @@ def load_custom_node(module_path, ignore=set()):
EXTENSION_WEB_DIRS
[
module_name
]
=
web_dir
EXTENSION_WEB_DIRS
[
module_name
]
=
web_dir
if
hasattr
(
module
,
"NODE_CLASS_MAPPINGS"
)
and
getattr
(
module
,
"NODE_CLASS_MAPPINGS"
)
is
not
None
:
if
hasattr
(
module
,
"NODE_CLASS_MAPPINGS"
)
and
getattr
(
module
,
"NODE_CLASS_MAPPINGS"
)
is
not
None
:
for
name
in
module
.
NODE_CLASS_MAPPINGS
:
for
name
,
node_cls
in
module
.
NODE_CLASS_MAPPINGS
.
items
()
:
if
name
not
in
ignore
:
if
name
not
in
ignore
:
NODE_CLASS_MAPPINGS
[
name
]
=
module
.
NODE_CLASS_MAPPINGS
[
name
]
NODE_CLASS_MAPPINGS
[
name
]
=
node_cls
node_cls
.
RELATIVE_PYTHON_MODULE
=
get_relative_module_name
(
module_path
)
if
hasattr
(
module
,
"NODE_DISPLAY_NAME_MAPPINGS"
)
and
getattr
(
module
,
"NODE_DISPLAY_NAME_MAPPINGS"
)
is
not
None
:
if
hasattr
(
module
,
"NODE_DISPLAY_NAME_MAPPINGS"
)
and
getattr
(
module
,
"NODE_DISPLAY_NAME_MAPPINGS"
)
is
not
None
:
NODE_DISPLAY_NAME_MAPPINGS
.
update
(
module
.
NODE_DISPLAY_NAME_MAPPINGS
)
NODE_DISPLAY_NAME_MAPPINGS
.
update
(
module
.
NODE_DISPLAY_NAME_MAPPINGS
)
return
True
return
True
...
...
server.py
View file @
83f70a88
...
@@ -416,6 +416,7 @@ class PromptServer():
...
@@ -416,6 +416,7 @@ class PromptServer():
info
[
'name'
]
=
node_class
info
[
'name'
]
=
node_class
info
[
'display_name'
]
=
nodes
.
NODE_DISPLAY_NAME_MAPPINGS
[
node_class
]
if
node_class
in
nodes
.
NODE_DISPLAY_NAME_MAPPINGS
.
keys
()
else
node_class
info
[
'display_name'
]
=
nodes
.
NODE_DISPLAY_NAME_MAPPINGS
[
node_class
]
if
node_class
in
nodes
.
NODE_DISPLAY_NAME_MAPPINGS
.
keys
()
else
node_class
info
[
'description'
]
=
obj_class
.
DESCRIPTION
if
hasattr
(
obj_class
,
'DESCRIPTION'
)
else
''
info
[
'description'
]
=
obj_class
.
DESCRIPTION
if
hasattr
(
obj_class
,
'DESCRIPTION'
)
else
''
info
[
'python_module'
]
=
getattr
(
obj_class
,
"RELATIVE_PYTHON_MODULE"
,
"nodes"
)
info
[
'category'
]
=
'sd'
info
[
'category'
]
=
'sd'
if
hasattr
(
obj_class
,
'OUTPUT_NODE'
)
and
obj_class
.
OUTPUT_NODE
==
True
:
if
hasattr
(
obj_class
,
'OUTPUT_NODE'
)
and
obj_class
.
OUTPUT_NODE
==
True
:
info
[
'output_node'
]
=
True
info
[
'output_node'
]
=
True
...
...
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