From e6398c919ae7faa099f007ad2195732958ac0f9a Mon Sep 17 00:00:00 2001 From: Haejung <11812352+diane-hj@users.noreply.github.com> Date: Wed, 21 Aug 2024 13:42:59 -0700 Subject: [PATCH] fix: Update frame range when write node is selected (#161) Signed-off-by: Haejung Choi Co-authored-by: Haejung Choi --- .../expected_job_bundle/asset_references.yaml | 9 ++ .../expected_job_bundle/parameter_values.yaml | 17 +++ .../frame/expected_job_bundle/template.yaml | 128 ++++++++++++++++++ .../scene/frame.deadline_render_settings.json | 17 +++ job_bundle_output_tests/frame/scene/frame.nk | 78 +++++++++++ .../deadline_submitter_for_nuke.py | 32 +++-- 6 files changed, 272 insertions(+), 9 deletions(-) create mode 100644 job_bundle_output_tests/frame/expected_job_bundle/asset_references.yaml create mode 100644 job_bundle_output_tests/frame/expected_job_bundle/parameter_values.yaml create mode 100644 job_bundle_output_tests/frame/expected_job_bundle/template.yaml create mode 100644 job_bundle_output_tests/frame/scene/frame.deadline_render_settings.json create mode 100644 job_bundle_output_tests/frame/scene/frame.nk diff --git a/job_bundle_output_tests/frame/expected_job_bundle/asset_references.yaml b/job_bundle_output_tests/frame/expected_job_bundle/asset_references.yaml new file mode 100644 index 0000000..c0e2034 --- /dev/null +++ b/job_bundle_output_tests/frame/expected_job_bundle/asset_references.yaml @@ -0,0 +1,9 @@ +assetReferences: + inputs: + directories: [] + filenames: + - /normalized/job/bundle/dir/frame.nk + outputs: + directories: + - /normalized/cwd + referencedPaths: [] diff --git a/job_bundle_output_tests/frame/expected_job_bundle/parameter_values.yaml b/job_bundle_output_tests/frame/expected_job_bundle/parameter_values.yaml new file mode 100644 index 0000000..e4c9560 --- /dev/null +++ b/job_bundle_output_tests/frame/expected_job_bundle/parameter_values.yaml @@ -0,0 +1,17 @@ +parameterValues: +- name: Frames + value: 3-7 +- name: NukeScriptFile + value: /normalized/job/bundle/dir/frame.nk +- name: WriteNode + value: Write1 +- name: ProxyMode + value: 'false' +- name: deadline:targetTaskRunStatus + value: READY +- name: deadline:maxFailedTasksCount + value: 20 +- name: deadline:maxRetriesPerTask + value: 5 +- name: deadline:priority + value: 50 diff --git a/job_bundle_output_tests/frame/expected_job_bundle/template.yaml b/job_bundle_output_tests/frame/expected_job_bundle/template.yaml new file mode 100644 index 0000000..0976b79 --- /dev/null +++ b/job_bundle_output_tests/frame/expected_job_bundle/template.yaml @@ -0,0 +1,128 @@ +specificationVersion: jobtemplate-2023-09 +name: frame.nk +parameterDefinitions: +- name: NukeScriptFile + type: PATH + objectType: FILE + dataFlow: IN + userInterface: + control: CHOOSE_INPUT_FILE + label: Nuke Script File + fileFilters: + - label: Nuke Script Files + patterns: + - '*.nk' + - label: All Files + patterns: + - '*' + description: The Nuke script file to render. +- name: Frames + type: STRING + description: The frames to render. E.g. 1-3,8,11-15 + minLength: 1 +- name: WriteNode + type: STRING + userInterface: + control: DROPDOWN_LIST + label: Write Node + description: Which write node to render ('All Write Nodes' for all of them) + default: All Write Nodes + allowedValues: + - All Write Nodes + - Write1 +- name: View + type: STRING + userInterface: + control: DROPDOWN_LIST + description: Which view to render ('All Views' for all of them) + default: All Views + allowedValues: + - All Views + - main +- name: ProxyMode + type: STRING + userInterface: + control: CHECK_BOX + label: Proxy Mode + description: Render in Proxy Mode. + default: 'false' + allowedValues: + - 'true' + - 'false' +- name: ContinueOnError + type: STRING + userInterface: + control: CHECK_BOX + label: Continue On Error + description: Continue processing when errors occur. + default: 'false' + allowedValues: + - 'true' + - 'false' +steps: +- name: Render + parameterSpace: + taskParameterDefinitions: + - name: Frame + type: INT + range: '{{Param.Frames}}' + stepEnvironments: + - name: Nuke + description: Runs Nuke in the background with a script file loaded. + script: + embeddedFiles: + - name: initData + filename: init-data.yaml + type: TEXT + data: | + continue_on_error: {{Param.ContinueOnError}} + proxy: {{Param.ProxyMode}} + script_file: '{{Param.NukeScriptFile}}' + write_nodes: + - '{{Param.WriteNode}}' + views: + - '{{Param.View}}' + actions: + onEnter: + command: NukeAdaptor + args: + - daemon + - start + - --path-mapping-rules + - file://{{Session.PathMappingRulesFile}} + - --connection-file + - '{{Session.WorkingDirectory}}/connection.json' + - --init-data + - file://{{ Env.File.initData }} + cancelation: + mode: NOTIFY_THEN_TERMINATE + timeout: 86400 + onExit: + command: NukeAdaptor + args: + - daemon + - stop + - --connection-file + - '{{ Session.WorkingDirectory }}/connection.json' + cancelation: + mode: NOTIFY_THEN_TERMINATE + timeout: 3600 + script: + embeddedFiles: + - name: runData + filename: run-data.yaml + type: TEXT + data: 'frameRange: "{{Task.Param.Frame}}"' + actions: + onRun: + command: NukeAdaptor + args: + - daemon + - run + - --connection-file + - '{{Session.WorkingDirectory}}/connection.json' + - --run-data + - file://{{ Task.File.runData }} + cancelation: + mode: NOTIFY_THEN_TERMINATE + timeout: 518400 diff --git a/job_bundle_output_tests/frame/scene/frame.deadline_render_settings.json b/job_bundle_output_tests/frame/scene/frame.deadline_render_settings.json new file mode 100644 index 0000000..b7bfbdc --- /dev/null +++ b/job_bundle_output_tests/frame/scene/frame.deadline_render_settings.json @@ -0,0 +1,17 @@ +{ + "name": "frame.nk", + "description": "", + "override_frame_range": false, + "frame_list": "1-100", + "write_node_selection": "Write1", + "view_selection": "", + "is_proxy_mode": false, + "input_filenames": [], + "input_directories": [], + "output_directories": [], + "timeouts_enabled": true, + "on_run_timeout_seconds": 518400, + "on_enter_timeout_seconds": 86400, + "on_exit_timeout_seconds": 3600, + "include_adaptor_wheels": false +} \ No newline at end of file diff --git a/job_bundle_output_tests/frame/scene/frame.nk b/job_bundle_output_tests/frame/scene/frame.nk new file mode 100644 index 0000000..f75a04f --- /dev/null +++ b/job_bundle_output_tests/frame/scene/frame.nk @@ -0,0 +1,78 @@ +#! /Applications/Nuke15.0v4/Nuke15.0v4.app/Contents/MacOS/libnuke-15.0.4.dylib -nx +#write_info Write1 file:"ColorBars.png" format:"2048 1556 1" chans:":rgba.red:rgba.green:rgba.blue:" framerange:"1 100" fps:"0" colorspace:"default (sRGB)" datatype:"8 bit" transfer:"unknown" views:"main" colorManagement:"Nuke" +version 15.0 v4 +define_window_layout_xml { + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +} +Root { + inputs 0 + name /Users/chaejung/Desktop/submitter/deadline-cloud-for-nuke/job_bundle_output_tests/frame/scene/frame.nk + format "2048 1556 0 0 2048 1556 1 2K_Super_35(full-ap)" + proxy_type scale + proxy_format "1024 778 0 0 1024 778 1 1K_Super_35(full-ap)" + colorManagement Nuke + workingSpaceLUT linear + monitorLut sRGB + monitorOutLUT rec709 + int8Lut sRGB + int16Lut sRGB + logLut Cineon + floatLut linear +} +ColorBars { + inputs 0 + name ColorBars1 + xpos -195 + ypos -157 +} +Write { + file ColorBars.png + file_type png + first 3 + last 7 + use_limit true + checkHashOnRead false + ocioColorspace scene_linear + display default + view sRGB + name Write1 + selected true + xpos -195 + ypos -83 +} +Viewer { + frame_range 1-100 + monitorOutNDISenderName "Nuke - frame - Viewer1" + monitorOutOutputTransform rec709 + name Viewer1 + xpos -195 + ypos -57 +} diff --git a/src/deadline/nuke_submitter/deadline_submitter_for_nuke.py b/src/deadline/nuke_submitter/deadline_submitter_for_nuke.py index ed60bfb..c44f2c1 100644 --- a/src/deadline/nuke_submitter/deadline_submitter_for_nuke.py +++ b/src/deadline/nuke_submitter/deadline_submitter_for_nuke.py @@ -146,15 +146,13 @@ def _get_job_template(settings: RenderSubmitterUISettings) -> dict[str, Any]: # Determine whether this is a movie render. If it is, we want to ensure that the entire Nuke # evaluation is placed on one task. - write_node, _ = _get_write_node(settings) + write_node, write_node_name = _get_write_node(settings) movie_render = "file_type" in write_node.knobs() and write_node["file_type"].value() in [ "mov", "mxf", ] if movie_render: - frame_list = ( - settings.frame_list if settings.override_frame_range else str(write_node.frameRange()) - ) + frame_list = _get_frame_list(settings, write_node, write_node_name) match = re.match(r"(\d+)-(\d+)", frame_list) if not match: raise DeadlineOperationError( @@ -181,11 +179,9 @@ def _get_parameter_values( write_node, write_node_name = _get_write_node(settings) # Set the Frames parameter value - if settings.override_frame_range: - frame_list = settings.frame_list - else: - frame_list = str(write_node.frameRange()) - parameter_values.append({"name": "Frames", "value": frame_list}) + parameter_values.append( + {"name": "Frames", "value": _get_frame_list(settings, write_node, write_node_name)} + ) # Set the Nuke script file value parameter_values.append({"name": "NukeScriptFile", "value": get_nuke_script_file()}) @@ -247,6 +243,24 @@ def _get_parameter_values( return parameter_values +def _get_frame_list( + settings: RenderSubmitterUISettings, + write_node: Node, + write_node_name: Optional[str], +) -> str: + # Set the Frames parameter value + if settings.override_frame_range: + frame_list = settings.frame_list + else: + # frame range from project setting + frame_list = str(nuke.root().frameRange()) + if write_node_name and write_node.knob("use_limit").value(): + first_frame = int(write_node.knob("first").value()) + last_frame = int(write_node.knob("last").value()) + frame_list = f"{first_frame}-{last_frame}" + return frame_list + + def show_nuke_render_submitter(parent, f=Qt.WindowFlags()) -> "SubmitJobToDeadlineDialog": global g_submitter_dialog