Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ValidateWaitForRender #64

Merged
merged 4 commits into from
Aug 8, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
63 changes: 63 additions & 0 deletions client/ayon_houdini/plugins/publish/validate_wait_for_render.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
# -*- 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 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 = [RepairAction]

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(
f"Skipping instance without instance node: {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)