ComfyUI icon indicating copy to clipboard operation
ComfyUI copied to clipboard

Add python_module to node info

Open huchenlei opened this issue 1 year ago • 3 comments

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. https://github.com/Comfy-Org/ComfyUI_frontend/pull/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 avatar Jul 03 '24 15:07 huchenlei

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.

comfyanonymous avatar Jul 03 '24 23:07 comfyanonymous

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.

huchenlei avatar Jul 04 '24 01:07 huchenlei

@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 avatar Jul 08 '24 16:07 huchenlei