-
Notifications
You must be signed in to change notification settings - Fork 2
/
dev_nodes.py
260 lines (209 loc) · 7.02 KB
/
dev_nodes.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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
class ErrorRaiseNode:
@classmethod
def INPUT_TYPES(cls):
return {"required": {}}
RETURN_TYPES = ("IMAGE",)
FUNCTION = "raise_error"
CATEGORY = "DevTools"
DESCRIPTION = "Raise an error for development purposes"
def raise_error(self):
raise Exception("Error node was called!")
class ErrorRaiseNodeWithMessage:
@classmethod
def INPUT_TYPES(cls):
return {"required": {"message": ("STRING", {"multiline": True})}}
RETURN_TYPES = ()
OUTPUT_NODE = True
FUNCTION = "raise_error"
CATEGORY = "DevTools"
DESCRIPTION = "Raise an error with message for development purposes"
def raise_error(self, message: str):
raise Exception(message)
class ExperimentalNode:
@classmethod
def INPUT_TYPES(cls):
return {"required": {}}
RETURN_TYPES = ()
OUTPUT_NODE = True
FUNCTION = "experimental_function"
CATEGORY = "DevTools"
DESCRIPTION = "A experimental node"
EXPERIMENTAL = True
def experimental_function(self):
print("Experimental node was called!")
class DeprecatedNode:
@classmethod
def INPUT_TYPES(cls):
return {"required": {}}
RETURN_TYPES = ()
OUTPUT_NODE = True
FUNCTION = "deprecated_function"
CATEGORY = "DevTools"
DESCRIPTION = "A deprecated node"
DEPRECATED = True
def deprecated_function(self):
print("Deprecated node was called!")
class LongComboDropdown:
@classmethod
def INPUT_TYPES(cls):
return {"required": {"option": ([f"Option {i}" for i in range(1000 * 1000)],)}}
RETURN_TYPES = ()
OUTPUT_NODE = True
FUNCTION = "long_combo_dropdown"
CATEGORY = "DevTools"
DESCRIPTION = "A long combo dropdown"
def long_combo_dropdown(self, option: str):
print(option)
class NodeWithOptionalInput:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {"required_input": ("IMAGE",)},
"optional": {"optional_input": ("IMAGE", {"default": None})},
}
RETURN_TYPES = ("IMAGE",)
FUNCTION = "node_with_optional_input"
CATEGORY = "DevTools"
DESCRIPTION = "A node with an optional input"
def node_with_optional_input(self, required_input, optional_input=None):
print(
f"Calling node with required_input: {required_input} and optional_input: {optional_input}"
)
return (required_input,)
class NodeWithOnlyOptionalInput:
@classmethod
def INPUT_TYPES(s):
return {
"optional": {
"text": ("STRING", {"multiline": True, "dynamicPrompts": True}),
"clip": ("CLIP", {}),
}
}
RETURN_TYPES = ()
FUNCTION = "node_with_only_optional_input"
CATEGORY = "DevTools"
DESCRIPTION = "A node with only optional input"
def node_with_only_optional_input(self, clip=None, text=None):
pass
class NodeWithOutputList:
@classmethod
def INPUT_TYPES(cls):
return {"required": {}}
RETURN_TYPES = (
"INT",
"INT",
)
RETURN_NAMES = (
"INTEGER OUTPUT",
"INTEGER LIST OUTPUT",
)
OUTPUT_IS_LIST = (
False,
True,
)
FUNCTION = "node_with_output_list"
CATEGORY = "DevTools"
DESCRIPTION = "A node with an output list"
def node_with_output_list(self):
return (1, [1, 2, 3])
class NodeWithForceInput:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"int_input": ("INT", {"forceInput": True}),
"int_input_widget": ("INT", {"default": 1}),
},
"optional": {"float_input": ("FLOAT", {"forceInput": True})},
}
RETURN_TYPES = ()
OUTPUT_NODE = True
FUNCTION = "node_with_force_input"
CATEGORY = "DevTools"
DESCRIPTION = "A node with a forced input"
def node_with_force_input(
self, int_input: int, int_input_widget: int, float_input: float = 0.0
):
print(
f"int_input: {int_input}, int_input_widget: {int_input_widget}, float_input: {float_input}"
)
class NodeWithStringInput:
@classmethod
def INPUT_TYPES(cls):
return {"required": {"string_input": ("STRING",)}}
RETURN_TYPES = ()
FUNCTION = "node_with_string_input"
CATEGORY = "DevTools"
DESCRIPTION = "A node with a string input"
def node_with_string_input(self, string_input: str):
print(f"string_input: {string_input}")
class NodeWithUnionInput:
@classmethod
def INPUT_TYPES(cls):
return {
"optional": {
"string_or_int_input": ("STRING,INT",),
"string_input": ("STRING", {"forceInput": True}),
"int_input": ("INT", {"forceInput": True}),
}
}
RETURN_TYPES = ()
OUTPUT_NODE = True
FUNCTION = "node_with_union_input"
CATEGORY = "DevTools"
DESCRIPTION = "A node with a union input"
def node_with_union_input(
self,
string_or_int_input: str | int = "",
string_input: str = "",
int_input: int = 0,
):
print(
f"string_or_int_input: {string_or_int_input}, string_input: {string_input}, int_input: {int_input}"
)
return {
"ui": {
"text": string_or_int_input,
}
}
class SimpleSlider:
@classmethod
def INPUT_TYPES(cls):
return {
"required": {
"value": ("FLOAT", { "display": "slider", "default": 0.5, "min": 0.0, "max": 1.0, "step": 0.001 }),
},
}
RETURN_TYPES = ("FLOAT",)
FUNCTION = "execute"
CATEGORY = "DevTools"
def execute(self, value):
return (value,)
NODE_CLASS_MAPPINGS = {
"DevToolsErrorRaiseNode": ErrorRaiseNode,
"DevToolsErrorRaiseNodeWithMessage": ErrorRaiseNodeWithMessage,
"DevToolsExperimentalNode": ExperimentalNode,
"DevToolsDeprecatedNode": DeprecatedNode,
"DevToolsLongComboDropdown": LongComboDropdown,
"DevToolsNodeWithOptionalInput": NodeWithOptionalInput,
"DevToolsNodeWithOnlyOptionalInput": NodeWithOnlyOptionalInput,
"DevToolsNodeWithOutputList": NodeWithOutputList,
"DevToolsNodeWithForceInput": NodeWithForceInput,
"DevToolsNodeWithStringInput": NodeWithStringInput,
"DevToolsNodeWithUnionInput": NodeWithUnionInput,
"DevToolsSimpleSlider": SimpleSlider,
}
NODE_DISPLAY_NAME_MAPPINGS = {
"DevToolsErrorRaiseNode": "Raise Error",
"DevToolsErrorRaiseNodeWithMessage": "Raise Error with Message",
"DevToolsExperimentalNode": "Experimental Node",
"DevToolsDeprecatedNode": "Deprecated Node",
"DevToolsLongComboDropdown": "Long Combo Dropdown",
"DevToolsNodeWithOptionalInput": "Node With Optional Input",
"DevToolsNodeWithOnlyOptionalInput": "Node With Only Optional Input",
"DevToolsNodeWithOutputList": "Node With Output List",
"DevToolsNodeWithForceInput": "Node With Force Input",
"DevToolsNodeWithStringInput": "Node With String Input",
"DevToolsNodeWithUnionInput": "Node With Union Input",
"DevToolsSimpleSlider": "Simple Slider",
}