update
This commit is contained in:
@@ -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`
|
||||
|
||||
@@ -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"]
|
||||
@@ -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}"
|
||||
@@ -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"
|
||||
}
|
||||
Reference in New Issue
Block a user