Comfy-Org / Comfy-Org/ComfyUI

[Feature request] Make namespaces for custom nodes standard

Open
#8,805 1 comment 0 reactions 0 assignees View on GitHub
Feature v3
Dominant language
Python
Stars
133k
Forks
15.7k
Avg merge
1d 7h
Merged PRs (30d)
158

Description

### TL;DR

Let's standardize machine names of nodes to always have a namespace - to solve node-name clashes.

### Feature Idea

I'm new to coding custom nodes, but from what I see, there are no restrictions in the machine name of a node - i.e, a node's key in `NODE_CLASS_MAPPINGS` and `NODE_DISPLAY_NAME_MAPPINGS` dictionaries. It seems that you could use spaces, punctuation and even emojis as the internal node name. People still adhere to PascalCase, but it's nothing more than a convention.

If so, why don't we solve the issue of clashing/conflicting nodes once and for all by standardizing namespaces? Why don't we ALWAYS use a node's namespace in it's internal name which is supposed to be unique anyway?

Here's the idea in detail:
- Each node HAS TO have a namespace - so it's full internal name would always be registered as `NodePackName.NodeName`
- If a node doesn't have it's namespace specified, it's added automatically, from the registered machine name of it's pack from `pyproject.toml`. So it would become something like: `comfyui_ultimatesdupscale.UltimateSDUpscale` - ugly, but still preventing name clashes.
- It would be logical to also allow sub- and sub-sub-namespaces, so there could be any level of nested parts with multiple delimiters. Like: `HugePackFamily.OptionalSubPack.NodeName` (Impact Pack, I'm looking at you 😉)
- For the existing workspaces, where there are no namespaces yet, an easy migration can be done for those nodes which didn't have clashes (simply check all keys with `string.endswith(f".{node_name}")`, and if only one match found, claim that this is the node's full name now).
- For the users however, namespaces are always stripped, unless there are multiple nodes with the same name in different namespaces.
- If there are, auto-attach the namespace to the visible node title on node creation - in parenthesis, maybe (but I'd argue, square brackets should be better since many nodes already use parenthesis in their name).
- Explicitly adding namespaces in the chosen format becomes an official recommendation for devs. Old workflows would still work... but as other devs start relying on namespace system, the chance of some bugs would slowly grow.
- Node devs need a way to update their namespace (aka register a rename for the node's full machine name). 99% of the time it won't be used, but the mere existence of it would prevent anxiety from locking down to a specific spelling. Another dictionary (like `NODE_PAST_NAMESPACES`) seems an obvious way to me: as it's keys, the current namespace; as a value - a list/tuple or a string (auto-converted to a tuple with one string) of previous namespaces / full names.
- Dot as a namespace delimiter is just a suggestion.

### Existing Solutions

Some people already use something-like-but-not-actually namespaces by prefixing their nodes. Without native namespace support, those machine names are bulky, though.

### Other

_No response_

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.