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 | class HoudiniSubmitDeadline(
abstract_submit_deadline.AbstractSubmitDeadline,
AYONPyblishPluginMixin
):
"""Submit Render ROPs to Deadline.
Renders are submitted to a Deadline Web Service as
supplied via the environment variable AVALON_DEADLINE.
Target "local":
Even though this does *not* render locally this is seen as
a 'local' submission as it is the regular way of submitting
a Houdini render locally.
"""
label = "Submit Render to Deadline"
order = pyblish.api.IntegratorOrder
hosts = ["houdini"]
families = ["redshift_rop",
"arnold_rop",
"mantra_rop",
"karma_rop",
"vray_rop"]
targets = ["local"]
settings_category = "deadline"
# presets
export_priority = 50
export_chunk_size = 10
export_group = ""
export_limits = ""
export_machine_limit = 0
@classmethod
def get_attribute_defs(cls):
return [
NumberDef(
"export_priority",
label="Export Priority",
default=cls.export_priority,
decimals=0
),
NumberDef(
"export_chunk",
label="Export Frames Per Task",
default=cls.export_chunk_size,
decimals=0,
minimum=1,
maximum=1000
),
TextDef(
"export_group",
default=cls.export_group,
label="Export Group Name"
),
TextDef(
"export_limits",
default=cls.export_limits,
label="Export Limit Groups",
placeholder="value1,value2",
tooltip="Enter a comma separated list of limit groups."
),
NumberDef(
"export_machine_limit",
default=cls.export_machine_limit,
label="Export Machine Limit",
tooltip="maximum number of machines for this job."
),
]
def get_job_info(self, dependency_job_ids=None, job_info=None):
instance = self._instance
context = instance.context
# Whether Deadline render submission is being split in two
# (extract + render)
split_render_job = instance.data.get("splitRender")
# If there's some dependency job ids we can assume this is a render job
# and not an export job
is_export_job = True
if dependency_job_ids:
is_export_job = False
job_type = "[RENDER]"
if split_render_job and not is_export_job:
product_type = instance.data["productType"]
plugin = {
"usdrender": "HuskStandalone",
}.get(product_type)
if not plugin:
# Convert from product type to Deadline plugin name
# i.e., arnold_rop -> Arnold
plugin = product_type.replace("_rop", "").capitalize()
else:
plugin = "Houdini"
if split_render_job:
job_type = "[EXPORT IFD]"
job_info.Plugin = plugin
filepath = context.data["currentFile"]
filename = os.path.basename(filepath)
job_info.Name = "{} - {} {}".format(filename, instance.name, job_type)
job_info.BatchName = filename
if is_in_tests():
job_info.BatchName += datetime.now().strftime("%d%m%Y%H%M%S")
# Deadline requires integers in frame range
start = instance.data["frameStartHandle"]
end = instance.data["frameEndHandle"]
frames = "{start}-{end}x{step}".format(
start=int(start),
end=int(end),
step=int(instance.data["byFrameStep"]),
)
job_info.Frames = frames
# Make sure we make job frame dependent so render tasks pick up a soon
# as export tasks are done
if split_render_job and not is_export_job:
job_info.IsFrameDependent = bool(instance.data.get(
"splitRenderFrameDependent", True))
attribute_values = self.get_attr_values_from_data(instance.data)
if split_render_job and is_export_job:
job_info.Priority = attribute_values.get(
"export_priority", self.export_priority
)
job_info.ChunkSize = attribute_values.get(
"export_chunk", self.export_chunk_size
)
job_info.Group = attribute_values.get(
"export_group", self.export_group
)
job_info.LimitGroups = attribute_values.get(
"export_limits", self.export_limits
)
job_info.MachineLimit = attribute_values.get(
"export_machine_limit", self.export_machine_limit
)
# TODO change to expectedFiles??
for i, filepath in enumerate(instance.data["files"]):
dirname = os.path.dirname(filepath)
fname = os.path.basename(filepath)
job_info.OutputDirectory += dirname.replace("\\", "/")
job_info.OutputFilename += fname
# Add dependencies if given
if dependency_job_ids:
job_info.JobDependencies = dependency_job_ids
return job_info
def get_plugin_info(self, job_type=None):
# Not all hosts can import this module.
import hou
instance = self._instance
context = instance.context
hou_major_minor = hou.applicationVersionString().rsplit(".", 1)[0]
# Output driver to render
if job_type == "render":
product_type = instance.data.get("productType")
if product_type == "arnold_rop":
plugin_info = ArnoldRenderDeadlinePluginInfo(
InputFile=instance.data["ifdFile"]
)
elif product_type == "mantra_rop":
plugin_info = MantraRenderDeadlinePluginInfo(
SceneFile=instance.data["ifdFile"],
Version=hou_major_minor,
)
elif product_type == "vray_rop":
plugin_info = VrayRenderPluginInfo(
InputFilename=instance.data["ifdFile"],
)
elif product_type == "redshift_rop":
plugin_info = RedshiftRenderPluginInfo(
SceneFile=instance.data["ifdFile"]
)
# Note: To use different versions of Redshift on Deadline
# set the `REDSHIFT_VERSION` env variable in the Tools
# settings in the AYON Application plugin. You will also
# need to set that version in `Redshift.param` file
# of the Redshift Deadline plugin:
# [Redshift_Executable_*]
# where * is the version number.
if os.getenv("REDSHIFT_VERSION"):
plugin_info.Version = os.getenv("REDSHIFT_VERSION")
else:
self.log.warning((
"REDSHIFT_VERSION env variable is not set"
" - using version configured in Deadline"
))
elif product_type == "usdrender":
plugin_info = self._get_husk_standalone_plugin_info(
instance, hou_major_minor)
else:
self.log.error(
"Product type '%s' not supported yet to split render job",
product_type
)
return
else:
driver = hou.node(instance.data["instance_node"])
plugin_info = DeadlinePluginInfo(
SceneFile=context.data["currentFile"],
OutputDriver=driver.path(),
Version=hou_major_minor,
IgnoreInputs=True
)
return asdict(plugin_info)
def process(self, instance):
if not instance.data["farm"]:
self.log.debug("Render on farm is disabled. "
"Skipping deadline submission.")
return
super(HoudiniSubmitDeadline, self).process(instance)
# TODO: Avoid the need for this logic here, needed for submit publish
# Store output dir for unified publisher (filesequence)
output_dir = os.path.dirname(instance.data["files"][0])
instance.data["outputDir"] = output_dir
def _get_husk_standalone_plugin_info(self, instance, hou_major_minor):
# Not all hosts can import this module.
import hou
# Supply additional parameters from the USD Render ROP
# to the Husk Standalone Render Plug-in
rop_node = hou.node(instance.data["instance_node"])
snapshot_interval = -1
if rop_node.evalParm("dosnapshot"):
snapshot_interval = rop_node.evalParm("snapshotinterval")
restart_delegate = 0
if rop_node.evalParm("husk_restartdelegate"):
restart_delegate = rop_node.evalParm("husk_restartdelegateframes")
rendersettings = (
rop_node.evalParm("rendersettings")
or "/Render/rendersettings"
)
return HuskStandalonePluginInfo(
SceneFile=instance.data["ifdFile"],
Renderer=rop_node.evalParm("renderer"),
RenderSettings=rendersettings,
Purpose=rop_node.evalParm("husk_purpose"),
Complexity=rop_node.evalParm("husk_complexity"),
Snapshot=snapshot_interval,
PreRender=rop_node.evalParm("husk_prerender"),
PreFrame=rop_node.evalParm("husk_preframe"),
PostFrame=rop_node.evalParm("husk_postframe"),
PostRender=rop_node.evalParm("husk_postrender"),
RestartDelegate=restart_delegate,
Version=hou_major_minor
)
|