Skip to content

Commit 76408d3

Browse files
committed
debug
1 parent 16279f2 commit 76408d3

1 file changed

Lines changed: 26 additions & 8 deletions

File tree

src/bizyair/commands/processors/prompt_processor.py

Lines changed: 26 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,10 @@
22
import json
33
import pprint
44
from collections import deque
5+
from dataclasses import dataclass
56
from typing import Any, Dict, List
67

8+
import nodes
79
from bizyair.common import client, get_api_key
810
from bizyair.common.caching import BizyAirTaskCache, CacheConfig
911
from bizyair.common.env_var import (
@@ -32,7 +34,14 @@ def is_link(obj):
3234
return True
3335

3436

35-
from dataclasses import dataclass
37+
def workflow_api_check(prompt: Dict[str, Dict[str, Any]]):
38+
for x in prompt:
39+
inputs: Dict[str, Any] = prompt[x].get("inputs", {})
40+
for k, v in inputs.items():
41+
if is_link(v):
42+
assert (
43+
v[0] in prompt
44+
), f"The previous node with ID {v[0]} in {prompt[x]}.{k} is not present in the prompt"
3645

3746

3847
class SearchServiceRouter(Processor):
@@ -155,10 +164,8 @@ def process(
155164
extra_pnginfo = hidden["extra_pnginfo"]
156165
workflow = extra_pnginfo["workflow"]
157166
links = workflow["links"]
158-
159167
queue = deque([int(unique_id)])
160168
visited = set()
161-
162169
last_node_id = int(unique_id)
163170
# TODO refine
164171
if pre_prompt[unique_id]["class_type"] != "InitFluxLoRATraining":
@@ -174,6 +181,19 @@ def process(
174181
if node_id in visited:
175182
continue
176183

184+
# if str(node_id) in hidden["prompt"]:
185+
# for v in hidden["prompt"][str(node_id)].get('inputs', {}).values():
186+
# if is_link(v):
187+
# # TODO exec
188+
# class_type = hidden["prompt"][str(node_id)]["class_type"]
189+
# class_def = nodes.NODE_CLASS_MAPPINGS[class_type]
190+
# data_type = class_def.RETURN_TYPES[v[1]]
191+
# if is_send_request_datatype(data_type):
192+
# continue
193+
# upstream_node_id = int(v[0])
194+
# if upstream_node_id not in visited:
195+
# queue.append(upstream_node_id)
196+
177197
visited.add(node_id)
178198
# https://docs.comfy.org/essentials/javascript_objects_and_hijacking#workflow
179199
for link in links:
@@ -188,8 +208,6 @@ def process(
188208
# TODO refine
189209
continue
190210
elif data_type == "*":
191-
import nodes
192-
193211
class_type = hidden["prompt"][str(upstream_node_id)]["class_type"]
194212
class_def = nodes.NODE_CLASS_MAPPINGS[class_type]
195213
data_type = class_def.RETURN_TYPES[link[2]]
@@ -199,11 +217,11 @@ def process(
199217
continue
200218

201219
if upstream_node_id == node_id and downstream_node_id not in visited:
202-
print(f"add {downstream_node_id=}")
220+
print(f"add {downstream_node_id=} ")
203221
queue.append(downstream_node_id)
204222

205223
elif downstream_node_id == node_id and upstream_node_id not in visited:
206-
print(f"add {upstream_node_id=}")
224+
print(f"add {upstream_node_id=} ")
207225
queue.append(upstream_node_id)
208226

209227
if BIZYAIR_DEBUG:
@@ -215,9 +233,9 @@ def process(
215233
"last_node_id": last_node_id,
216234
}
217235
)
218-
# dict_keys(['139', '141', '142', '138', '143', '150'])
219236

220237
# TODO remove hidden keys
238+
workflow_api_check(pre_prompt)
221239
return pre_prompt
222240

223241
def validate_input(

0 commit comments

Comments
 (0)