-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathnodes.py
More file actions
204 lines (182 loc) · 6.17 KB
/
nodes.py
File metadata and controls
204 lines (182 loc) · 6.17 KB
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
import asyncio
import threading
from uuid import uuid4
from aiohttp import web
import nodes
from comfy.model_management import (
InterruptProcessingException,
throw_exception_if_processing_interrupted,
)
from comfy_api.latest import io
from server import PromptServer
pause_events: dict[str, threading.Event] = {}
class Pause(io.ComfyNode):
@classmethod
def define_schema(cls):
return io.Schema(
node_id="Pause",
category="utils",
display_name="Pause",
inputs=[
io.AnyType.Input("any", display_name="any"),
io.Boolean.Input(
"force_pause",
default=False,
tooltip="Force execution of the node",
optional=True,
),
],
outputs=[io.AnyType.Output("output", display_name="any")],
hidden=[io.Hidden.unique_id],
)
@classmethod
async def execute(cls, any, force_pause=False):
unique_id = cls.hidden.unique_id
event = threading.Event()
pause_events[unique_id] = event
PromptServer.instance.send_sync(
"entering_pause_loop", {"executionId": unique_id}
)
try:
while not event.is_set():
throw_exception_if_processing_interrupted()
await asyncio.sleep(0.01)
except InterruptProcessingException as e:
nodes.interrupt_processing()
raise e
finally:
del pause_events[unique_id]
PromptServer.instance.send_sync(
"leaving_pause_loop", {"executionId": unique_id}
)
return io.NodeOutput(any)
@classmethod
def fingerprint_inputs(cls, any, force_pause=False):
return str(uuid4()) if force_pause else hash(any)
@PromptServer.instance.routes.post("/async_pause/continue")
async def continue_execution(request: web.Request):
json_data = await request.json()
executionId = json_data.get("executionId")
if executionId in pause_events:
pause_events[executionId].set()
return web.Response(status=200)
class NotifyAudioOutput(io.ComfyNode):
@classmethod
def define_schema(cls):
return io.Schema(
node_id="NotifyAudioOutput",
category="utils",
display_name="Notify Audio",
is_output_node=True,
inputs=[
io.AnyType.Input("any", display_name="any"),
],
)
@classmethod
def execute(cls, any) -> io.NodeOutput:
return io.NodeOutput(ui={"frontend_on_executed_dummy_trigger": []})
class NotifyAudioPassthrough(io.ComfyNode):
@classmethod
def define_schema(cls):
return io.Schema(
node_id="NotifyAudioPassthrough",
category="utils",
display_name="Notify Audio (Passthrough)",
inputs=[
io.AnyType.Input("any", display_name="any"),
],
outputs=[
io.AnyType.Output("output", display_name="any"),
],
)
@classmethod
def execute(cls, any) -> io.NodeOutput:
return io.NodeOutput(any, ui={"frontend_on_executed_dummy_trigger": []})
class NotifyToastOutput(io.ComfyNode):
@classmethod
def define_schema(cls):
return io.Schema(
node_id="NotifyToastOutput",
display_name="Toast",
category="utils",
is_output_node=True,
inputs=[
io.AnyType.Input("any"),
io.String.Input(
"detail",
multiline=True,
tooltip="Detail message to display in toast",
placeholder="Toast message",
),
io.Combo.Input(
"severity",
options=[
"success",
"info",
"warn",
"error",
"secondary",
"contrast",
],
default="info",
tooltip="Message severity level",
),
io.Int.Input(
"life",
min=0,
default=3000,
max=1000000000,
display_name="life (ms)",
tooltip="Duration in milliseconds before auto-closing",
step=500,
),
],
)
@classmethod
def execute(cls, **kwargs) -> io.NodeOutput:
return io.NodeOutput(ui={"frontend_on_executed_dummy_trigger": []})
class NotifyToastPassthrough(io.ComfyNode):
@classmethod
def define_schema(cls):
return io.Schema(
node_id="NotifyToastPassthrough",
display_name="Toast (Passthrough)",
category="utils",
inputs=[
io.AnyType.Input("any"),
io.String.Input(
"detail",
multiline=True,
tooltip="Detail message to display in toast",
placeholder="Toast message",
),
io.Combo.Input(
"severity",
options=[
"success",
"info",
"warn",
"error",
"secondary",
"contrast",
],
default="info",
tooltip="Message severity level",
),
io.Int.Input(
"life",
min=0,
default=3000,
max=100000000,
display_name="life (ms)",
tooltip="Duration in milliseconds before auto-closing",
step=500,
),
],
outputs=[io.AnyType.Output("output", display_name="any")],
)
@classmethod
def execute(cls, **kwargs) -> io.NodeOutput:
return io.NodeOutput(
kwargs["any"], ui={"frontend_on_executed_dummy_trigger": []}
)