pydn / ComfyUI-to-Python-Extension

A powerful tool that translates ComfyUI workflows into executable Python code.
MIT License
842 stars 87 forks source link

Pass `prompt` argument to nodes that define it in their inputs #41

Open niqodea opened 4 months ago

niqodea commented 4 months ago

Hello! Thank you for the useful script.

I noticed that, when converting workflows containing efficiency nodes, the obtained script fails, unlike the original workflow on ComfyUI. The reason seems to be caused by the fact that these nodes take as input a prompt parameter in their API (ref), which in Comfy seems to be a special type of parameter containing the entire JSON workflow as a python dictionary. The efficiency nodes then use such information to perform optimizations and prune unused tensors.

When not passing prompt to these nodes, the default value None always causes a crash down the line. While it might be argued that the behavior is not a problem of this extension, it's also true that not passing prompt to nodes that accept it might lead to undesirable behavior. In this case, even when handling the lack of prompt gracefully, the efficiency nodes would probably not be able to carry out performance optimizations.

It would be great to update this extension to send prompt as input to the nodes that support it in the generated code.