-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy path__init__.py
65 lines (54 loc) · 1.87 KB
/
__init__.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
"""
@title: cozy_ex_dynamic
@author: amorano
@category: Example
@reference: https://github.com/cozy-comfyui/cozy_ex_dynamic
@tags: dynamic, example, developer, script, mechanism, exemplar
@description: Example of a Node with Dynamic Inputs
@node list:
CozyDynamicNode
@version: 1.0.0
"""
from typing import Any, Dict, Tuple
# =============================================================================
# === GLOBAL ===
# =============================================================================
NODE_CLASS_MAPPINGS = {}
NODE_DISPLAY_NAME_MAPPINGS = {}
WEB_DIRECTORY = "./web"
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY"]
# =============================================================================
# === NODE ===
# =============================================================================
class DynamicNodeCozy:
"""
A class to represent a dynamic node in ComfyUI.
"""
RETURN_TYPES = ("IMAGE",)
RETURN_NAMES = ("IMAGE",)
FUNCTION = "run"
CATEGORY = "_EXAMPLES"
@classmethod
def INPUT_TYPES(s) -> Dict[str, dict]:
return {
"required": {},
"optional": {}
}
def run(self, **kw) -> Tuple[Any | None]:
# the dynamically created input data will be in the dictionary kwargs
#for k, v in kw.items():
# print(f'{k} => {v}')
# return the first value found or `None` if no inputs are defined
value = None
if len(values := kw.values()) > 0:
value = next(iter(values))
return (value,)
# =============================================================================
# === REGISTRATION ===
# =============================================================================
NODE_CLASS_MAPPINGS = {
"DynamicNodeCozy": DynamicNodeCozy,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"DynamicNodeCozy": "Dynamic Node (cozy)",
}