Skip to content

Commit

Permalink
Merge pull request #352 from yolain/execution-inversion
Browse files Browse the repository at this point in the history
Fix can not get total when convert it to input on loops nodes
  • Loading branch information
yolain authored Aug 26, 2024
2 parents ffb0bf5 + e514bc1 commit 9b05d46
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
15 changes: 12 additions & 3 deletions py/logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -685,14 +685,15 @@ def __init__(self):
def INPUT_TYPES(cls):
return {
"required": {
"total": ("INT", {"default": 1, "min": 0, "max": 100000, "step": 1}),
"total": ("INT", {"default": 1, "min": 1, "max": 100000, "step": 1}),
},
"optional": {
"initial_value%d" % i: (AlwaysEqualProxy("*"),) for i in range(1, MAX_FLOW_NUM)
},
"hidden": {
"initial_value0": (AlwaysEqualProxy("*"),),
"prompt": "PROMPT",
"extra_pnginfo": "EXTRA_PNGINFO",
"unique_id": "UNIQUE_ID"
}
}
Expand All @@ -703,9 +704,13 @@ def INPUT_TYPES(cls):

CATEGORY = "EasyUse/Logic/For Loop"

def for_loop_start(self, total, prompt=None, unique_id=None, **kwargs):
def for_loop_start(self, total, prompt=None, extra_pnginfo=None, unique_id=None, **kwargs):
graph = GraphBuilder()
i = 0
unique_id = unique_id.split('.')[len(unique_id.split('.'))-1] if "." in unique_id else unique_id
node = next((x for x in extra_pnginfo['workflow']['nodes'] if x['id'] == int(unique_id)), None)
if node:
node['properties']['total'] = total
if "initial_value0" in kwargs:
i = kwargs["initial_value0"]
initial_values = {("initial_value%d" % num): kwargs.get("initial_value%d" % num, None) for num in range(1, MAX_FLOW_NUM)}
Expand Down Expand Up @@ -744,7 +749,11 @@ def for_loop_end(self, flow, prompt=None, extra_pnginfo=None, my_unique_id=None,
total = None
if extra_pnginfo:
node = next((x for x in extra_pnginfo['workflow']['nodes'] if x['id'] == int(while_open)), None)
total = node['widgets_values'][0] if "widgets_values" in node else None
if node:
if 'properties' in node and 'total' in node['properties']:
total = node['properties']['total']
else:
total = node['widgets_values'][0] if "widgets_values" in node else None
if total is None:
raise Exception("Unable to get parameters for the start of the loop")
sub = graph.node("easy mathInt", operation="add", a=[while_open, 1], b=1)
Expand Down
1 change: 1 addition & 0 deletions web_version/v2/assets/extensions-DK7x7jQd.js

Large diffs are not rendered by default.

1 change: 0 additions & 1 deletion web_version/v2/assets/extensions-DjHfjjgA.js

This file was deleted.

2 changes: 1 addition & 1 deletion web_version/v2/easyuse.js

Large diffs are not rendered by default.

0 comments on commit 9b05d46

Please sign in to comment.