Replies: 2 comments 10 replies
-
This is a good guideline. Many developers creating custom nodes often start without prior experience in Python, myself included. Even with some experience now, I'm currently struggling to correct the buttons I initially misaligned. |
Beta Was this translation helpful? Give feedback.
-
it may not cost money or disk but it can be expensive in terms of time. from a development perspective, it's much easier to have everything in one repo since convenience functions can be reused, infrastructure can be reused, etc. also, even with most of my installed extensions basically being node packs i still have a lot of extensions installed. if every node was split out into a separate extension, it would be overwhelming to manage from a user perspective as well. a better solution is to make one's extensions play nicely with other extensions. of course there are definitely cases for splitting stuff up logically, but it's not always possible or convenient and a lot of people just build collections of nodes that they think are useful and don't necessarily have a direct relationship. splitting those up would be impractical from both a development and a user perspective. |
Beta Was this translation helpful? Give feedback.
-
After spending an entire week getting out of the comfort zone of AUTOMATIC1111 extensions and trying to make some sense out of those popular custom nodes and reducing the amount of errors I came across, I finally decide that this is the time to document all the common bad design/implementation decisions regarding custom nodes, which will cause chaos and user misery all over the board.
While those are based on real user experience, all assertions here represent only my own opinion. Always take it with a grain of salt. This is not a completed list.
1. Non-Git and non-Folder compliant nodes
It is exactly a year since ComfyUI has become a thing now and there are still new nodes that requires copying a specific file to the folder, and ComfyUI-Manager is still providing support for such things, even when the node is hosted on GitHub.
ltdrdata/ComfyUI-Manager@a2c545b#diff-ca83200897149cebdfa21e3a4df3d00d4273d6812ba3adc21a2c1bb713dce484R3666-R3676
https://github.com/biegert/ComfyUI-CLIPSeg
Such nodes brings great difficulties when it comes to version upgrade and dependency management, and should be made compliant or removed ASAP.
2. Using common name for nodes
When developing nodes, please ensure that the name in
NODE_CLASS_MAPPINGS
is unique. One of the best way to do this is to prefix it with your name or project name or whatever you like, but please make it distinct so users won't have to guess which node they should install from a list where there is a ton of naming conflicts, while they are not necessarily compatible with each other.3. Bundling nodes that has no relationship between
Please group your nodes and only bundle nodes in a same folder / repository if they have direct relationship, so users will not have to face all those conflicts that come wholesale when what they only want is a single node. Creating multiple repositories costs no money nor disk.
E.g. all those powerful node packs, such as:
https://github.com/shadowcz007/comfyui-mixlab-nodes
https://github.com/omar92/ComfyUI-QualityOfLifeSuit_Omar92
https://github.com/CYBERLOOM-INC/ComfyUI-nodes-hnmr
https://github.com/flyingshutter/As_ComfyUI_CustomNodes
https://github.com/AlekPet/ComfyUI_Custom_Nodes_AlekPet
4. Referencing external packages without listing them out in requirements
It is your responsibility to list out all requirements that you use in your nodes. This is not a thing that should be covered by either ComfyUI-Manager or ComfyUI itself. And the
pip
entries in index really should never be there in the first place.https://github.com/ningxiaoxiao/comfyui-NDI/blob/e0c3d208623eb9c5388ec1613aad72d9eba4561c/__init__.py#L13
https://github.com/ltdrdata/ComfyUI-Manager/blob/8077765d47ffd9317f34f642c5fd87baadb9814b/custom-node-list.json#L3269
5. Trying to use
pip
in an unsupported wayIt is important to know that the only officially supported way to invoke
pip
is throughpython -m pip
. It is neitherpip
norimport pip
. Thepip
orpip.exe
could simply not be there and you risk installing some packages into a different environment rather than that you are running on.Always combine
sys.executable
and-m pip
.https://github.com/shadowcz007/comfyui-mixlab-nodes/blob/3572368f16d13f0f496f2530757edc40eca8ec2e/__init__.py#L73-L74
https://github.com/shadowcz007/comfyui-mixlab-nodes/blob/3572368f16d13f0f496f2530757edc40eca8ec2e/install.bat#L16
6. Assuming users are all using
python_embeded
I can no longer find any custom nodes doing this. Cool.
7. Specifying torch in the requirements
Just stop bothering with them.
https://github.com/biegert/ComfyUI-CLIPSeg/blob/7f38951269888407de45fb934958c30c27704fdb/requirements.txt#L9-L14
https://github.com/mav-rik/facerestore_cf/blob/2b5d727ed658e0b3feb14a620d67dad1b1bcb0ab/requirements.txt#L3-L4
8. Using unix utils
Honestly, why?
The only thing reliable in a Python environment is Python.
https://github.com/thecooltechguy/ComfyUI-Stable-Video-Diffusion/blob/2b2891c8046ade10d32f59d0178a500fd925de4c/prestartup_script.py#L20
9. Polluting global module tree
If you want to refer to SGM, that's great. But please please please vendor it inside your own namespace and don't let it out, especially when you are dealing with a trimmed version of it. It can be a big surprise for you and others.
https://github.com/chaojie/ComfyUI-MotionCtrl-SVD/blob/566fbdd8767ff293808e903288cde3bef8c6df68/nodes.py#L10-L12
10. Copying things out of the folder
We have
WEB_DIRECTORY
for ages now. Just don't do this. Andatexit
is not at all reliable.https://github.com/AIGODLIKE/AIGODLIKE-ComfyUI-Translation/blob/eee96d109f59c75f519fcec973995cfef0398972/__init__.py#L126-L143
11. Doing weird things to ComfyUI internals
If you want to do something to the core ComfyUI functionality, put it into a separated node. I am not expecting my ComfyUI starts to listen to an HTTPS port when installing new nodes.
https://github.com/shadowcz007/comfyui-mixlab-nodes/blob/3572368f16d13f0f496f2530757edc40eca8ec2e/__init__.py#L383-L430
12. Use strict version specifiers
https://github.com/WASasquatch/was-node-suite-comfyui/blob/main/requirements.txt#L20
You ends up with this funny looking dependency resolution:
Extra reading: https://pip.pypa.io/en/stable/user_guide/#changes-to-the-pip-dependency-resolver-in-20-3-2020
13. Require
onnxruntime
It is worth noting that, installing
onnxruntime
on top ofonnxruntime-gpu
will make the runtime lose the GPU acceleration functionality.https://github.com/pythongosssss/ComfyUI-WD14-Tagger/blob/6b47b34cd61086215a3247c92884f733cd1e58b9/requirements.txt#L1
14. Meaningless folder / repository name
It creates madness when trying to figure out what the custom node is for from the folder name.
A good name should precisely describe the main functionality of the node. If you find it is hard to come up with such name, then you have a problem with section 3.
https://github.com/ltdrdata/ComfyUI-Impact-Pack
https://github.com/shadowcz007/comfyui-mixlab-nodes
https://github.com/WASasquatch/was-node-suite-comfyui
https://github.com/FizzleDorf/ComfyUI_FizzNodes
https://github.com/rgthree/rgthree-comfy
https://github.com/AlekPet/ComfyUI_Custom_Nodes_AlekPet
https://github.com/blepping/ComfyUI-bleh
Some good examples:
https://github.com/WASasquatch/FreeU_Advanced
https://github.com/Kaharos94/ComfyUI-Saveaswebp
https://github.com/city96/SD-Latent-Upscaler
15. Wrong dependency names in requirements.txt
This seems to be far more widespread than I originally think. This is harmful because it defeats any reasonable dependency analysis, and this is dangerous because any one can register virus under these unoccupied names and soon your node will help the baddies just like how LLMVISION did its thing.
https://github.com/chrisfreilich/virtuoso-nodes/blob/c1c23c07b50f16d669fd8cabce96970c35c2b583/requirements.txt#L6
https://github.com/jags111/ComfyUI_Jags_VectorMagic/blob/8c6cd6b3f5800d9c67e2a2b0978cec5232b2b8ed/requirements.txt#L11-L12
To be continued...
Beta Was this translation helpful? Give feedback.
All reactions