forked from aws-deadline/deadline-cloud-samples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtemplate.yaml
More file actions
391 lines (369 loc) · 12 KB
/
Copy pathtemplate.yaml
File metadata and controls
391 lines (369 loc) · 12 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
specificationVersion: jobtemplate-2023-09
name: Maya Tiled Render
description: |
This job uses Maya, Arnold for Maya and ffmpeg to do tile rendering and assembly.
Tile rendering divides an image into evenly sized regions, and assembly stiches the tiles
back together.
As of 07/2024, this example requires modifications to the arnold render handler in the
Deadline Cloud Maya Adaptor to successfully run. It also requires Linux render workers to
execute the assembly step as it is a bash script.
It uses two conda channels to get software. Maya and Arnold is acquired from the
deadline-cloud channel accessible from Deadline Cloud service-managed fleets, and FFmpeg
is from the conda-forge community channel.
This job bundle has 2 steps:
1. Render the images as tiles using the modified Arnold render handler.
2. Uses ffmpeg to assemble the tiles into the whole image.
Next steps:
This job bundle could handle the tile rendering calculations that currently need to be added
to the Maya adaptor in the render step, leaving the Maya adaptor to simply handle region rendering.
Refer to https://github.com/mwiebe/deadline-cloud-samples/commit/ca4fa1162f504c92798536e1931b6b1c6df90285
for sample changes to this template.
parameterDefinitions:
# Render Parameters
- name: MayaSceneFile
type: PATH
objectType: FILE
dataFlow: IN
userInterface:
control: CHOOSE_INPUT_FILE
label: Maya Scene File
groupLabel: Maya Settings
fileFilters:
- label: Maya Scene Files
patterns:
- '*.mb'
- '*.ma'
- label: All Files
patterns:
- '*'
description: The Maya scene file to render.
- name: Frames
type: STRING
userInterface:
control: LINE_EDIT
label: Frames
groupLabel: Maya Settings
description: The frames to render. E.g. 1-3,8,11-15
default: '1'
minLength: 1
- name: RenderLayer
type: STRING
userInterface:
control: LINE_EDIT
label: Render Layer
groupLabel: Maya Settings
description: The name of the layer to render.
default: 'masterLayer'
- name: ProjectPath
type: PATH
objectType: DIRECTORY
dataFlow: NONE
userInterface:
control: CHOOSE_DIRECTORY
label: Project Path
groupLabel: Maya Settings
description: The Maya project path.
- name: OutputFilePath
type: PATH
objectType: DIRECTORY
dataFlow: OUT
userInterface:
control: CHOOSE_DIRECTORY
label: Output File Path
groupLabel: Maya Settings
description: The render output path.
- name: RenderSetupIncludeLights
type: STRING
userInterface:
control: CHECK_BOX
label: Include All Lights
groupLabel: Maya Settings
description: Include all lights in the render.
default: 'true'
allowedValues:
- 'true'
- 'false'
- name: StrictErrorChecking
type: STRING
userInterface:
control: CHECK_BOX
label: Strict Error Checking
groupLabel: Maya Settings
description: Fail when errors occur.
default: 'false'
allowedValues:
- 'true'
- 'false'
- name: OutputFilePrefix
type: STRING
userInterface:
control: LINE_EDIT
label: Output File Prefix
groupLabel: Maya Settings
description: The output filename prefix.
default: '<Scene>'
- name: ImageWidth
type: INT
userInterface:
control: SPIN_BOX
label: Image Width
groupLabel: Maya Settings
minValue: 1
description: The image width of the output.
- name: ImageHeight
type: INT
userInterface:
control: SPIN_BOX
label: Image Height
groupLabel: Maya Settings
minValue: 1
description: The image height of the output.
# Tile Render Parameters
- name: NumXTiles
type: INT
userInterface:
control: SPIN_BOX
label: Tiles across width
groupLabel: Tile Rendering Settings
minValue: 1
description: The number of tiles across the x axis.
- name: NumYTiles
type: INT
userInterface:
control: SPIN_BOX
label: Tiles across height
groupLabel: Tile Rendering Settings
minValue: 1
description: The number of tiles across the y axis.
# Arnold Renderer Settings
- name: ArnoldErrorOnLicenseFailure
type: STRING
userInterface:
control: CHECK_BOX
label: Error on License Failure
groupLabel: Arnold Renderer Settings
description: Whether to produce an error when there is an Arnold license failure.
default: 'false'
allowedValues:
- 'true'
- 'false'
# Override Parameters
- name: OverrideAdaptorWheels
type: PATH
objectType: DIRECTORY
dataFlow: IN
userInterface:
control: CHOOSE_DIRECTORY
label: Wheels directory
groupLabel: Override settings
description: A directory that contains wheels for openjd, deadline, and the overridden
adaptor.
- name: OverrideAdaptorName
type: STRING
userInterface:
control: LINE_EDIT
label: Adaptor Name
groupLabel: Override settings
description: The name of the adaptor to override, for example NukeAdaptor or MayaAdaptor.
default: maya-openjd
steps:
- name: tile render
parameterSpace:
taskParameterDefinitions:
- name: Frame
type: INT
range: '{{Param.Frames}}'
- name: Camera
type: STRING
range:
- RenderCam
- name: TileNumberX
type: INT
range: '1-{{Param.NumXTiles}}'
- name: TileNumberY
type: INT
range: '1-{{Param.NumYTiles}}'
stepEnvironments:
- name: Maya
description: Runs Maya in the background.
script:
embeddedFiles:
- name: initData
filename: init-data.yaml
type: TEXT
data: |
renderer: arnold
render_layer: '{{Param.RenderLayer}}'
scene_file: '{{Param.MayaSceneFile}}'
project_path: '{{Param.ProjectPath}}'
output_file_path: '{{Param.OutputFilePath}}'
render_setup_include_lights: {{Param.RenderSetupIncludeLights}}
strict_error_checking: {{Param.StrictErrorChecking}}
output_file_prefix: '{{Param.OutputFilePrefix}}'
image_width: {{Param.ImageWidth}}
image_height: {{Param.ImageHeight}}
error_on_arnold_license_fail: {{Param.ArnoldErrorOnLicenseFailure}}
actions:
onEnter:
command: maya-openjd
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: maya-openjd
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}}
camera: '{{Task.Param.Camera}}'
numXTiles: {{Param.NumXTiles}}
numYTiles: {{Param.NumYTiles}}
tileNumX: {{Task.Param.TileNumberX}}
tileNumY: {{Task.Param.TileNumberY}}
output_file_prefix: '{{Param.OutputFilePrefix}}'
actions:
onRun:
command: maya-openjd
args:
- daemon
- run
- --connection-file
- '{{ Session.WorkingDirectory }}/connection.json'
- --run-data
- file://{{ Task.File.runData }}
cancelation:
mode: NOTIFY_THEN_TERMINATE
- name: tile assembly
dependencies:
- dependsOn: tile render
script:
actions:
onRun:
command: bash
args: [ "{{Task.File.Encode}}"]
embeddedFiles:
- name: Encode
type: TEXT
runnable: True
data: |
#!/bin/env bash
set -xeuo pipefail
# ASSUMPTIONS:
# Output folder will either contain tiles, or folders with tiles, never both.
# No nested subdirectories (max one layer of subdirectories).
# Tiles are in correct sequential order given assembly goes left-right from top-bottom.
# Either the name.#.ext or name.ext Maya "Frame/Animation ext" render setting is used.
# Output tiles are pngs. Swap png with the desired file ext in the script as needed.
has_subdirs=true
FRAMES={{Param.Frames}}
startFrame=${FRAMES%-*}
endFrame=${FRAMES#*-}
# If there are sub-directories in the output path, iterate over each item in the output file path directory and call ffmpeg for the sub-directory
for item in "{{Param.OutputFilePath}}"/*; do
# Check if the item is a directory
if [ -d "$item" ]; then
if [[ "$startFrame" == "$endFrame" ]]; then
ffmpeg -y -pattern_type glob -i "/$item/*.png" -filter_complex tile={{Param.NumXTiles}}x{{Param.NumYTiles}} "/$item/output.png"
else
for frame in $(seq "$startFrame" "$endFrame"); do
ffmpeg -y -pattern_type glob -i "/$item/*$frame.png" -filter_complex tile={{Param.NumXTiles}}x{{Param.NumYTiles}} "/$item/output.$frame.png"
done
fi
else
has_subdirs=false
break
fi
done
if [ "$has_subdirs" = false ]; then
if [[ "$startFrame" == "$endFrame" ]]; then
ffmpeg -y -pattern_type glob -i "{{Param.OutputFilePath}}/*.png" -filter_complex tile={{Param.NumXTiles}}x{{Param.NumYTiles}} "{{Param.OutputFilePath}}/output.png"
else
for frame in $(seq "$startFrame" "$endFrame"); do
ffmpeg -y -pattern_type glob -i "{{Param.OutputFilePath}}/*$frame.png" -filter_complex tile={{Param.NumXTiles}}x{{Param.NumYTiles}} "{{Param.OutputFilePath}}/output.$frame.png"
done
fi
fi
jobEnvironments:
- name: OverrideAdaptor
description: |
Replaces the default Adaptor in the environment's PATH with one from the packages in the OverrideAdaptorWheels attached directory.
script:
actions:
onEnter:
command: '{{Env.File.Enter}}'
embeddedFiles:
- name: Enter
filename: override-adaptor-enter.sh
type: TEXT
runnable: true
data: |
#!/bin/env bash
set -euo pipefail
echo "The adaptor wheels that are attached to the job:"
ls '{{Param.OverrideAdaptorWheels}}'
echo ""
# Create a venv and activate it in this environment
echo "Creating Python venv for the {{Param.OverrideAdaptorName}} command"
/usr/local/bin/python3 -m venv '{{Session.WorkingDirectory}}/venv'
{{Env.File.InitialVars}}
. '{{Session.WorkingDirectory}}/venv/bin/activate'
{{Env.File.CaptureVars}}
echo ""
echo "Installing adaptor into the venv"
pip install '{{Param.OverrideAdaptorWheels}}'/openjd*.whl
pip install '{{Param.OverrideAdaptorWheels}}'/deadline*.whl
echo ""
if [ ! -f '{{Session.WorkingDirectory}}/venv/bin/{{Param.OverrideAdaptorName}}' ]; then
echo "The Override Adaptor {{Param.OverrideAdaptorName}} was not installed as expected."
exit 1
fi
- name: InitialVars
filename: initial-vars
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
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"openjd_env: {k}={v}")
for k in delete:
print(f"openjd_unset_env: {k}")