Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
33 changes: 33 additions & 0 deletions client/ayon_nuke/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
from ayon_core.pipeline.colorspace import (
get_current_context_imageio_config_preset
)
from ayon_core.pipeline.create import CreateContext
from ayon_core.resources import get_ayon_icon_filepath

from .gizmo_menu import GizmoMenu
Expand Down Expand Up @@ -1293,6 +1294,11 @@ def create_write_node(
# adding clear rendered button
add_button_clear_rendered(GN)

if data.get("render_on_farm", False):
requires_gpu_knob = nuke.Boolean_Knob("requires_gpu", "Requires GPU")
GN.addKnob(requires_gpu_knob)
requires_gpu_knob.setFlag(nuke.STARTLINE)

# set tile color
tile_color = next(
iter(
Expand All @@ -1311,6 +1317,33 @@ def create_write_node(
return GN


def group_node_knob_changed():
requires_gpu_knob = nuke.thisKnob()
if requires_gpu_knob.name() != "requires_gpu":
return

instance_id = get_node_data(nuke.thisNode(), INSTANCE_DATA_KNOB).get("instance_id")
if not instance_id:
return

with nuke.Root():
create_context = CreateContext(registered_host())
instance = create_context.instances_by_id.get(instance_id)
if not instance:
return

collect_opencue_layer_args = instance.publish_attributes.get("CollectOpenCueLayerArgs")
if not collect_opencue_layer_args:
return

requires_gpu = requires_gpu_knob.value()
if collect_opencue_layer_args.get("requires_gpu") == requires_gpu:
return

collect_opencue_layer_args["requires_gpu"] = requires_gpu
create_context.save_changes()


def set_node_knobs_from_settings(node, knob_settings, **kwargs):
"""Overriding knob values from settings

Expand Down
4 changes: 4 additions & 0 deletions client/ayon_nuke/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,6 +58,7 @@
dirmap_file_name_filter,
add_scripts_menu,
add_scripts_gizmo,
group_node_knob_changed,
get_node_data,
set_node_data,
MENU_LABEL,
Expand Down Expand Up @@ -196,6 +197,9 @@ def add_nuke_callbacks(project_settings: dict = None):
# Add dirmap for file paths.
nuke.addFilenameFilter(dirmap_file_name_filter)

# add callback for opencue requires gpu knob
nuke.addKnobChanged(group_node_knob_changed, nodeClass="Group")

log.info("Added Nuke callbacks ...")


Expand Down
11 changes: 11 additions & 0 deletions client/ayon_nuke/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -405,6 +405,17 @@ def update_instances(self, update_list):
# ensure was not deleted by super()
if self.create_context.get_instance_by_id(created_inst.id):
self._update_write_node_filepath(created_inst, changes)
requires_gpu = (
"publish_attributes" in (changes.changed_keys - changes.removed_keys)
and changes.new_value.get(
"publish_attributes", {}
).get("CollectOpenCueLayerArgs", {}).get("requires_gpu")
)
# Approach to avoiding the infinite loop of this bi-directional
# relationship is just to only set if different.
requires_gpu_knob = created_inst.transient_data["node"].knob("requires_gpu")
if isinstance(requires_gpu, bool) and requires_gpu_knob and requires_gpu_knob.value() != requires_gpu:
requires_gpu_knob.setValue(requires_gpu)

def _update_write_node_filepath(self, created_inst, changes):
"""Update instance node on context changes.
Expand Down
Loading