Skip to content

Add python_module to node info#3936

Merged
comfyanonymous merged 1 commit intoComfy-Org:masterfrom
huchenlei:moduleinfo
Jul 9, 2024
Merged

Add python_module to node info#3936
comfyanonymous merged 1 commit intoComfy-Org:masterfrom
huchenlei:moduleinfo

Conversation

@huchenlei
Copy link
Contributor

@huchenlei huchenlei commented Jul 3, 2024

This PR add node class's RELATIVE_PYTHON_MODULE to node def object returned by /object_info API endpoint. RELATIVE_PYTHON_MODULE is the relative python module path against the project root, e.g. custom_nodes.foo

This will help show the node belongs to which custom node pack in the redesigned node search box. Comfy-Org/ComfyUI_frontend#83

How to verify

  • cd tests-ui/
  • npm i
  • npm test:generate
  • Inspect tests-ui/data/object_info.json

Some examples:

Built-in node

		"name": "CheckpointLoaderSimple",
		"display_name": "Load Checkpoint",
		"description": "",
		"python_module": "nodes", <------
		"category": "loaders",
		"output_node": false

Custom node

		"name": "ResizeMask",
		"display_name": "ResizeMask",
		"description": "\nResizes the mask or batch of masks to the specified width and height.\n",
		"python_module": "custom_nodes.ComfyUI-KJNodes.nodes.nodes", <-----
		"category": "KJNodes/masking",
		"output_node": false

@huchenlei huchenlei requested a review from comfyanonymous as a code owner July 3, 2024 15:18
@comfyanonymous
Copy link
Member

image

I'm not sure if returning the full paths is a good idea, it might be better to return just the custom node name.

@huchenlei
Copy link
Contributor Author

huchenlei commented Jul 4, 2024

image

I'm not sure if returning the full paths is a good idea, it might be better to return just the custom node name.

The full path comes from the loading of modules with abs path here: https://github.com/comfyanonymous/ComfyUI/blob/24b969d3dace581ed3fb547eedfbdf502ad0f7e9/nodes.py#L1974-L2018

I will fix it so that we can have consistent __module__ format. I am also fine if we just attach custom node folder name.

Use more explicit name 'python_module'

Parse abs ath

Move parse to nodes.py
@huchenlei
Copy link
Contributor Author

huchenlei commented Jul 8, 2024

@comfyanonymous Can you take a look again? I have fixed module names passed to frontend to be relative module name against ComfyUI root.

The change does not affect current module loading.

Note: frontend visual
image

@huchenlei huchenlei changed the title Add __module__ to node info Add python_module to node info Jul 8, 2024
@comfyanonymous comfyanonymous merged commit 83f70a8 into Comfy-Org:master Jul 9, 2024
@huchenlei huchenlei deleted the moduleinfo branch July 9, 2024 21:49
csokun pushed a commit to csokun/ComfyUI that referenced this pull request Jul 10, 2024
Use more explicit name 'python_module'

Parse abs ath

Move parse to nodes.py
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants