Skip to content

Commit

Permalink
Adding test for cwd paths
Browse files Browse the repository at this point in the history
Signed-off-by: Esteban Papp <81431996+amznestebanpapp@users.noreply.github.com>
  • Loading branch information
amznestebanpapp committed Sep 8, 2023
1 parent 486eab7 commit 92a099d
Show file tree
Hide file tree
Showing 6 changed files with 301 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
assetReferences:
inputs:
directories: []
filenames:
- /normalized/job/bundle/dir/cwd-path.nk
outputs:
directories:
- /normalized/cwd
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
parameterValues:
- name: deadline:priority
value: 50
- name: deadline:targetTaskRunStatus
value: READY
- name: deadline:maxFailedTasksCount
value: 100
- name: deadline:maxRetriesPerTask
value: 5
- name: Frames
value: 1-100
- name: NukeScriptFile
value: /normalized/job/bundle/dir/cwd-path.nk
- name: ProxyMode
value: 'false'
- name: NukeVersion
value: 13.2v4
- name: RezPackages
value: nuke-13 deadline_cloud_for_nuke
227 changes: 227 additions & 0 deletions job_bundle_output_tests/cwd-path/expected_job_bundle/template.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,227 @@
specificationVersion: '2022-09-01'
name: cwd-path.nk
parameters:
- 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'
- name: NukeVersion
type: STRING
userInterface:
control: LINE_EDIT
label: Nuke Version
description: The version of Nuke.
- name: RezPackages
type: STRING
userInterface:
control: LINE_EDIT
label: Rez Packages
description: A space-separated list of Rez packages to install
default: nuke-13 deadline_cloud_for_nuke
environments:
- name: Rez
description: Initializes and destroys the Rez environment for the job.
script:
actions:
onEnter:
command: '{{ Env.File.Enter }}'
onExit:
command: '{{ Env.File.Exit }}'
embeddedFiles:
- name: Enter
filename: rez-enter.sh
type: TEXT
runnable: true
data: |
#!/bin/env bash
set -euo pipefail
if [ ! -z "{{Param.RezPackages}}" ]; then
echo "Rez Package List:"
echo " {{Param.RezPackages}}"
# Create the environment
/usr/local/bin/deadline-rez init \
-d "{{Session.WorkingDirectory}}" \
{{Param.RezPackages}}
# Capture the environment's vars
{{Env.File.InitialVars}}
. /usr/local/bin/deadline-rez activate \
-d "{{Session.WorkingDirectory}}"
{{Env.File.CaptureVars}}
else
echo "No Rez Packages, skipping environment creation."
fi
- name: Exit
filename: rez-exit.sh
type: TEXT
runnable: true
data: |
#!/bin/env bash
set -euo pipefail
if [ ! -z "{{Param.RezPackages}}" ]; then
echo "Rez Package List:"
echo " {{Param.RezPackages}}"
/usr/local/bin/deadline-rez destroy \
-d "{{ Session.WorkingDirectory }}"
else
echo "No Rez Packages, skipping environment teardown."
fi
- name: InitialVars
filename: initial-vars.sh
type: TEXT
runnable: true
data: |
#!/usr/bin/env python3
import os, json
envfile = "{{Session.WorkingDirectory}}/.envInitial"
with open(envfile, "w", encoding="utf8") as f:
json.dump(dict(os.environ), f)
- name: CaptureVars
filename: capture-vars.sh
type: TEXT
runnable: true
data: |
#!/usr/bin/env python3
import os, json, sys
envfile = "{{Session.WorkingDirectory}}/.envInitial"
if os.path.isfile(envfile):
with open(envfile, "r", encoding="utf8") as f:
before = json.load(f)
else:
print("No initial environment found, must run Env.File.CaptureVars script first")
sys.exit(1)
after = dict(os.environ)
put = {k: v for k, v in after.items() if v != before.get(k)}
delete = {k for k in before if k not in after}
for k, v in put.items():
print(f"updating {k}={v}")
print(f"openjobio_env: {k}={v}")
for k in delete:
print(f"openjobio_unset_env: {k}")
steps:
- name: Render
parameterSpace:
parameters:
- name: Frame
type: INT
range: '{{Param.Frames}}'
environments:
- 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}}'
version: '{{Param.NukeVersion}}'
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
onExit:
command: NukeAdaptor
args:
- daemon
- stop
- --connection-file
- '{{ Session.WorkingDirectory }}/connection.json'
cancelation:
mode: NOTIFY_THEN_TERMINATE
script:
embeddedFiles:
- name: runData
filename: run-data.yaml
type: TEXT
data: 'frame: {{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
42 changes: 42 additions & 0 deletions job_bundle_output_tests/cwd-path/scene/cwd-path.nk
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
#! D:/Programs/Nuke13.2v4/nuke-13.2.4.dll -nx
#write_info Write1 file:"output_%04d.exr" format:"2048 1556 1" chans:":rgba.red:rgba.green:rgba.blue:" framerange:"1 100" fps:"0" colorspace:"default (linear)" datatype:"16 bit half"
Root {
inputs 0
name C:/users/markw/deadline-clients/deadline-nuke/job_bundle_output_tests/cwd-path/cwd-path.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
barintensity {{curve x1 0 x10 1}}
name ColorBars1
xpos -444
ypos -375
}
set N737cd800 [stack 0]
Viewer {
frame_range 1-100
monitorOutOutputTransform rec709
name Viewer1
xpos -444
ypos -218
}
push $N737cd800
Write {
file output_####.exr
file_type exr
first_part rgba
version 1
name Write1
xpos -296
ypos -259
}
5 changes: 4 additions & 1 deletion src/deadline/nuke_submitter/assets.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,10 @@ def get_nuke_script_file() -> str:

def get_project_path() -> str:
"""This is the path Nuke uses for relative paths"""
return nuke.root().knob("project_directory").getEvaluatedValue()
project_path = nuke.root().knob("project_directory").getEvaluatedValue()
if not project_path:
project_path = os.getcwd()
return project_path


def get_scene_asset_references() -> FlatAssetReferences:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -228,6 +228,7 @@ def _run_job_bundle_output_test(test_dir: str, dcc_scene_file: str, report_fh, m
)
contents = contents.replace(tempdir, "/normalized/job/bundle/dir")
contents = contents.replace(tempdir.replace("\\", "/"), "/normalized/job/bundle/dir")
contents = contents.replace(os.getcwd(), "/normalized/cwd")
with open(full_filename, "w", encoding="utf8") as f:
f.write(contents)

Expand Down

0 comments on commit 92a099d

Please sign in to comment.