generated from ynput/ayon-addon-template
-
Notifications
You must be signed in to change notification settings - Fork 10
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
93e9810
commit 2f25119
Showing
1 changed file
with
68 additions
and
0 deletions.
There are no files selected for viewing
68 changes: 68 additions & 0 deletions
68
client/ayon_houdini/plugins/publish/validate_wait_for_render.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
# -*- coding: utf-8 -*- | ||
import hou | ||
|
||
import pyblish.api | ||
from ayon_core.pipeline import PublishValidationError | ||
from ayon_core.pipeline.publish import RepairAction | ||
|
||
from ayon_houdini.api import plugin | ||
|
||
|
||
class EnableWaitForRender(RepairAction): | ||
label = "Enable WaitForRendertoComplete" | ||
icon = "mdi.pencil-plus-outline" | ||
|
||
|
||
class ValidateWaitForRender(plugin.HoudiniInstancePlugin): | ||
"""Validate `WaitForRendertoComplete` is enabled. | ||
Disabling `WaitForRendertoComplete` cause the local render to fail | ||
as the publish execution continues while the render may not be finished yet. | ||
""" | ||
|
||
order = pyblish.api.ValidatorOrder | ||
families = ["usdrender"] | ||
label = "Validate Wait For Render to Complete" | ||
actions = [EnableWaitForRender] | ||
|
||
def process(self, instance): | ||
|
||
if not instance.data.get("instance_node"): | ||
# Ignore instances without an instance node | ||
# e.g. in memory bootstrap instances | ||
self.log.debug( | ||
"Skipping instance without instance node: {}".format(instance) | ||
) | ||
return | ||
|
||
if instance.data["creator_attributes"].get("render_target") != "local": | ||
# This validator should work only with local render target. | ||
self.log.debug( | ||
"Skipping Validator, Render target is not 'Local machine rendering'" | ||
) | ||
return | ||
|
||
invalid = self.get_invalid(instance) | ||
if invalid: | ||
rop = invalid[0] | ||
raise PublishValidationError( | ||
("ROP node '{}' has 'Wait For Render to Complete' parm disabled." | ||
"Please, enable it.".format(rop.path())), | ||
title=self.label | ||
) | ||
|
||
@classmethod | ||
def get_invalid(cls, instance): | ||
|
||
rop = hou.node(instance.data["instance_node"]) | ||
if not rop.evalParm("soho_foreground"): | ||
return [rop] | ||
|
||
@classmethod | ||
def repair(cls, instance): | ||
"""Enable WaitForRendertoComplete. """ | ||
|
||
rop = hou.node(instance.data["instance_node"]) | ||
rop.parm("soho_foreground").set(True) | ||
|