This commit is contained in:
develephant
2026-03-08 11:41:58 -05:00
parent 1022f58c2a
commit e04d81db0b
4 changed files with 81 additions and 0 deletions
+11
View File
@@ -1,2 +1,13 @@
# comfyui-node-template
A simple ComfyUI node development starter template.
## Set-up
```py
uv init
```
## Node placement
Custom node directory goes in `comfyui/custom_nodes`
+5
View File
@@ -0,0 +1,5 @@
# mappings for the ComfyUI node.
from .nodes import NODE_CLASS_MAPPINGS, NODE_DISPLAY_NAME_MAPPINGS
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS"]
+9
View File
@@ -0,0 +1,9 @@
# An external class to process the `execute`
class MyExecuteClass:
def __init__(self):
pass
def run(self, toggle):
return f"run output {toggle}"
+56
View File
@@ -0,0 +1,56 @@
# ComfyUI node
from .execute import MyExecuteClass
class MyComfyNode:
# runs on load only
def __init__(self):
self.execute_class = MyExecuteClass()
# node inputs, if any.
@classmethod
def INPUT_TYPES(cls):
return {"required": {
"prefix": ("STRING", {"default": "", "tooltip": "a prefix"}),
"slider_float": ("FLOAT", {"default": 20.0, "min": 1.0, "max": 99.0, "step": 0.5}),
"slider_int": ("INT", {"default": 5, "min": 1, "max": 20 }),
"toggle": ("BOOLEAN", {"default": False, "tooltip": "toggle me"}),
}}
#return {} #no inputs
# node title (visible title)
TITLE = "My ComfyUI Node"
# not a trailing comma, is tuple.
RETURN_TYPES = ("STRING",)
RETURN_NAMES = ("output",)
# function to run on "execute"
FUNCTION = "execute"
# does node have an "output"
OUTPUT_NODE = True
# node metadata
CATEGORY = "category/MyComfyNode"
DESCRIPTION = "My ComfyUI Node"
# the node structure has changed
def IS_CHANGED():
return float("nan") #force cache refresh
# run the node execute method
def execute(self):
result = self.execute_class.run(self.toggle)
# return tuple
return (result,)
# node mappings (see also __init__.py)
NODE_CLASS_MAPPINGS = {
"MyComfyNode": MyComfyNode,
}
# name mappings
NODE_DISPLAY_NAME_MAPPINGS = {
"MyComfyNode": "My ComfyUI Node"
}