vinavfx / ComfyUI-for-Nuke

API to be able to use ComfyUI nodes within nuke, only using the ComfyUI server
GNU General Public License v3.0
187 stars 17 forks source link

Command Line rendering with Nuke and ComfyUI ? #33

Open juergster opened 2 days ago

juergster commented 2 days ago

Would like to be able to run the ComfyUI/Nuke workflows via a command line but am not an expert when it comes to trying to call anything other then a Write node. The Nuke script works as expected through the GUI.

Running the following command (on Linux):

Nuke14.0 -t render_test.py

The render_test.py script looks like this:

import nuke

nuke.scriptOpen('./Nuke_comfy_basic.nk')

nuke.toNode('QueuePrompt').setSelected(True)
group_node = nuke.toNode('QueuePrompt')

if group_node:
    force_animation = group_node.knob('force_animation').value()
    if force_animation:
        print("Force animation is enabled. Submitting animation...")
        comfyui.queue_prompt.animation_submit()
    else:
        print("Submitting regular request...")
        comfyui.queue_prompt.submit()
else:
    print("Group node 'QueuePrompt' not found!")

Not sure what I'm missing here. Getting this error:

Nuke 14.1v4, 64 bit, built Feb  6 2024.
Copyright (c) 2024 The Foundry Visionmongers Ltd.  All Rights Reserved.

Submitting regular request...
Traceback (most recent call last):
  File "render_test.py", line 15, in <module>
    comfyui.queue_prompt.submit()
  File "/home/admin/.nuke/nuke_comfyui/src/queue_prompt.py", line 194, in submit
    data, input_node_changed = extract_data(frame)
  File "/home/admin/.nuke/nuke_comfyui/src/nodes.py", line 21, in extract_data
    output_node = get_input(queue_prompt_node, 0)
  File "/home/admin/.nuke/nuke_comfyui/src/nodes.py", line 385, in get_input
    inode = node.input(i)
AttributeError: invalid
invalid
LucidiousMinux commented 1 day ago

Is running the comfyui.queue_prompt.submit() in the context of group_node? feels like we'd need to drill down from the nuke obj to the actual comfyUI instance/node from the loaded .nk