BadCafeCode / execution-inversion-demo-comfyui

38 stars 5 forks source link

Loops do not repeat execution for leaf nodes (about expected behavior for ForLoop) #10

Open Shyryp opened 2 weeks ago

Shyryp commented 2 weeks ago

Expected Behavior I would expect that the final branches (leaf nodes (nodes without return pins)) in the loop body would also be re-executed with each loop, or I would expect to be able to control this somehow, but I haven't found such functionality.

Actual Behavior Currently, any leaf nodes in the node tree inside the loop body are not executed in subsequent loops (leaf nodes are executed only once). For example, in the screenshot below, you can see that the preview (on the left) of the very first image created by the loop is displayed, rather than the very last image that is displayed after the loop (on the right). While the loop is running, the image previews are not updated inside the loop body.

Screenshot with workflow with problem: image

Steps to Reproduce Here is a simple workflow that makes it easy to reproduce this issue: Leaf_Node_Problem_Example_Workflow.json

It would be interesting to know why it was decided to make the end nodes run once within a loop, rather than repeatedly - is there any problem with that?

I expect there will be a setting for ForLoop that will allow end nodes to be run in every loop, not just the first one. Or alternative ForLoop nodes that will run end nodes in every loop.

PrometheusDante commented 2 weeks ago

Yeah, it is a little inconvenient when outputs need to exist and lead someplace in order to execute each loop. I ended up forcing it through node grouping and the use of the impact pack's preview bridge to get an image preview. It also does not execute multiple times if there is no output after the For Loop Close, which I did not necessarily have. For example I built an auto-captioning workflow based on this and all it does is saved within the loop and nothing really has to come out the other end, so I just put in a dummy string output or something like that to make it execute. 😄

Shyryp commented 2 weeks ago

Да, это немного неудобно, когда выходы должны существовать и вести куда-то, чтобы выполнить каждый цикл. В итоге я пропустил его через группировку узлов и использование моста предварительного просмотра пакета Impact, чтобы получить предварительный просмотр изображения. Он также не выполняется несколько раз, если нет выходных данных после закрытия цикла For, что у меня не обязательно было. Например, я построил рабочий процесс автозаполнения субтитров на основе этого, и все, что он делает, это сохраняется в цикле, и на самом деле ничего не должно выходить с другого конца, поэтому я просто вставил фиктивный строковый вывод или что-то в этом роде, чтобы он выполнился. 😄

@PrometheusDante Yes, you can add a forced exit for all nodes, but I don't really want to modify nodes or use some third-party custom packages that create such exits for nodes. And I don't want to use a bunch of extra alternative node packages that have exits.

So it would be great to have the ability to run end nodes as an option for ForLoop and While.