Skip to content

Commit

Permalink
Use PublishError to the caller functions in publish plugins for `re…
Browse files Browse the repository at this point in the history
…nder_rop` and `evalParmNoFarm`
  • Loading branch information
MustafaJafar committed Dec 5, 2024
1 parent fea6de3 commit 84be3d4
Show file tree
Hide file tree
Showing 10 changed files with 104 additions and 28 deletions.
17 changes: 6 additions & 11 deletions client/ayon_houdini/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,11 +289,9 @@ def render_rop(ropnode, frame_range=None):
# The hou.Error is not inherited from a Python Exception class,
# so we explicitly capture the houdini error, otherwise pyblish
# will remain hanging.
raise PublishError(
"Render failed or interrupted",
description=f"An Error occurred while rendering {ropnode.path()}",
detail=f"{exc}"
)
import traceback
traceback.print_exc()
raise RuntimeError("Render failed: {0}".format(exc))


def imprint(node, data, update=False):
Expand Down Expand Up @@ -676,8 +674,7 @@ def get_top_referenced_parm(parm):
def evalParmNoFrame(node, parm, pad_character="#"):

parameter = node.parm(parm)
if not parameter:
raise PublishError(f"Parameter does not exist: {node}.{parm}")
assert parameter, "Parameter does not exist: %s.%s" % (node, parm)

# If the parameter has a parameter reference, then get that
# parameter instead as otherwise `unexpandedString()` fails.
Expand All @@ -687,10 +684,8 @@ def evalParmNoFrame(node, parm, pad_character="#"):
try:
raw = parameter.unexpandedString()
except hou.Error as exc:
raise PublishError(
f"Failed: {parameter}",
detail=f"{exc}"
)
print("Failed: %s" % parameter)
raise RuntimeError(exc)

def replace(match):
padding = 1
Expand Down
16 changes: 13 additions & 3 deletions client/ayon_houdini/plugins/publish/collect_arnold_rop.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import hou
import pyblish.api

from ayon_core.pipeline import PublishError
from ayon_houdini.api import plugin
from ayon_houdini.api.lib import evalParmNoFrame

Expand All @@ -28,13 +29,13 @@ def process(self, instance):

rop = hou.node(instance.data.get("instance_node"))

default_prefix = evalParmNoFrame(rop, "ar_picture")
default_prefix = self.evalParmNoFrame(rop, "ar_picture")
render_products = []

export_prefix = None
export_products = []
if instance.data["splitRender"]:
export_prefix = evalParmNoFrame(
export_prefix = self.evalParmNoFrame(
rop, "ar_ass_file", pad_character="0"
)
beauty_export_product = self.get_render_product_name(
Expand Down Expand Up @@ -74,7 +75,7 @@ def process(self, instance):
if rop.evalParm("ar_aov_exr_enable_layer_name{}".format(index)):
label = rop.evalParm("ar_aov_exr_layer_name{}".format(index))
else:
label = evalParmNoFrame(rop, "ar_aov_label{}".format(index))
label = self.evalParmNoFrame(rop, "ar_aov_label{}".format(index))

# NOTE:
# we don't collect the actual AOV path but rather assume
Expand Down Expand Up @@ -160,3 +161,12 @@ def replace(match):
os.path.join(dir, (file % i)).replace("\\", "/"))

return expected_files

def evalParmNoFrame(self, rop, parm, **kwargs):
try:
return evalParmNoFrame(rop, parm, **kwargs)
except Exception as exc:
raise PublishError(
f"Failed evaluating parameter '{parm}' on Rop node: {rop.path()}",
detail=f"{exc}"
)
9 changes: 8 additions & 1 deletion client/ayon_houdini/plugins/publish/collect_karma_rop.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import hou
import pyblish.api

from ayon_core.pipeline import PublishError
from ayon_houdini.api.lib import evalParmNoFrame
from ayon_houdini.api import plugin

Expand All @@ -28,7 +29,13 @@ def process(self, instance):

rop = hou.node(instance.data.get("instance_node"))

default_prefix = evalParmNoFrame(rop, "picture")
try:
default_prefix = evalParmNoFrame(rop, "picture")
except Exception as exc:
raise PublishError(
f"Failed evaluating parameter 'picture' on Rop node: {rop.path()}",
detail=f"{exc}"
)
render_products = []

# Default beauty AOV
Expand Down
16 changes: 13 additions & 3 deletions client/ayon_houdini/plugins/publish/collect_mantra_rop.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import hou
import pyblish.api

from ayon_core.pipeline import PublishError
from ayon_houdini.api.lib import evalParmNoFrame
from ayon_houdini.api import plugin

Expand All @@ -28,13 +29,13 @@ def process(self, instance):

rop = hou.node(instance.data.get("instance_node"))

default_prefix = evalParmNoFrame(rop, "vm_picture")
default_prefix = self.evalParmNoFrame(rop, "vm_picture")
render_products = []

export_prefix = None
export_products = []
if instance.data["splitRender"]:
export_prefix = evalParmNoFrame(
export_prefix = self.evalParmNoFrame(
rop, "soho_diskfile", pad_character="0"
)
beauty_export_product = self.get_render_product_name(
Expand Down Expand Up @@ -74,7 +75,7 @@ def process(self, instance):
aov_enabled = rop.evalParm(aov_boolean)
has_aov_path = rop.evalParm(aov_name)
if has_aov_path and aov_enabled == 1:
aov_prefix = evalParmNoFrame(rop, aov_name)
aov_prefix = self.evalParmNoFrame(rop, aov_name)
aov_product = self.get_render_product_name(
prefix=aov_prefix, suffix=None
)
Expand Down Expand Up @@ -137,3 +138,12 @@ def replace(match):
os.path.join(dir, (file % i)).replace("\\", "/"))

return expected_files

def evalParmNoFrame(self, rop, parm, **kwargs):
try:
return evalParmNoFrame(rop, parm, **kwargs)
except Exception as exc:
raise PublishError(
f"Failed evaluating parameter '{parm}' on Rop node: {rop.path()}",
detail=f"{exc}"
)
16 changes: 13 additions & 3 deletions client/ayon_houdini/plugins/publish/collect_redshift_rop.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import hou
import pyblish.api

from ayon_core.pipeline import PublishError
from ayon_houdini.api.lib import evalParmNoFrame
from ayon_houdini.api import plugin

Expand All @@ -27,12 +28,12 @@ class CollectRedshiftROPRenderProducts(plugin.HoudiniInstancePlugin):
def process(self, instance):
rop = hou.node(instance.data.get("instance_node"))

default_prefix = evalParmNoFrame(rop, "RS_outputFileNamePrefix")
default_prefix = self.evalParmNoFrame(rop, "RS_outputFileNamePrefix")
beauty_suffix = rop.evalParm("RS_outputBeautyAOVSuffix")

export_products = []
if instance.data["splitRender"]:
export_prefix = evalParmNoFrame(
export_prefix = self.evalParmNoFrame(
rop, "RS_archive_file", pad_character="0"
)
beauty_export_product = self.get_render_product_name(
Expand Down Expand Up @@ -80,7 +81,7 @@ def process(self, instance):
continue

aov_suffix = rop.evalParm(f"RS_aovSuffix_{i}")
aov_prefix = evalParmNoFrame(rop, f"RS_aovCustomPrefix_{i}")
aov_prefix = self.evalParmNoFrame(rop, f"RS_aovCustomPrefix_{i}")
if not aov_prefix:
aov_prefix = default_prefix

Expand Down Expand Up @@ -163,3 +164,12 @@ def replace(match):
os.path.join(dir, (file % i)).replace("\\", "/"))

return expected_files

def evalParmNoFrame(self, rop, parm, **kwargs):
try:
return evalParmNoFrame(rop, parm, **kwargs)
except Exception as exc:
raise PublishError(
f"Failed evaluating parameter '{parm}' on Rop node: {rop.path()}",
detail=f"{exc}"
)
14 changes: 12 additions & 2 deletions client/ayon_houdini/plugins/publish/collect_usd_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import hou
import pyblish.api

from ayon_core.pipeline import PublishError
from ayon_houdini.api import plugin
from ayon_houdini.api.lib import evalParmNoFrame

Expand Down Expand Up @@ -31,7 +32,7 @@ def process(self, instance):

if instance.data["splitRender"]:
# USD file output
lop_output = evalParmNoFrame(
lop_output = self.evalParmNoFrame(
rop, "lopoutput", pad_character="#"
)

Expand All @@ -40,7 +41,7 @@ def process(self, instance):
# TODO: It is possible for a user to disable this
# TODO: When enabled I think only the basename of the `lopoutput`
# parm is preserved, any parent folders defined are likely ignored
folder = evalParmNoFrame(
folder = self.evalParmNoFrame(
rop, "savetodirectory_directory", pad_character="#"
)

Expand Down Expand Up @@ -68,3 +69,12 @@ def replace_to_f(match):

# stub required data for Submit Publish Job publish plug-in
instance.data["attachTo"] = []

def evalParmNoFrame(self, rop, parm, **kwargs):
try:
return evalParmNoFrame(rop, parm, **kwargs)
except Exception as exc:
raise PublishError(
f"Failed evaluating parameter '{parm}' on Rop node: {rop.path()}",
detail=f"{exc}"
)
14 changes: 12 additions & 2 deletions client/ayon_houdini/plugins/publish/collect_vray_rop.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import hou
import pyblish.api

from ayon_core.pipeline import PublishError
from ayon_houdini.api.lib import evalParmNoFrame
from ayon_houdini.api import plugin

Expand All @@ -28,14 +29,14 @@ def process(self, instance):

rop = hou.node(instance.data.get("instance_node"))

default_prefix = evalParmNoFrame(rop, "SettingsOutput_img_file_path")
default_prefix = self.evalParmNoFrame(rop, "SettingsOutput_img_file_path")
render_products = []
# TODO: add render elements if render element

export_prefix = None
export_products = []
if instance.data["splitRender"]:
export_prefix = evalParmNoFrame(
export_prefix = self.evalParmNoFrame(
rop, "render_export_filepath", pad_character="0"
)
beauty_export_product = self.get_render_product_name(
Expand Down Expand Up @@ -132,3 +133,12 @@ def replace(match):
os.path.join(dir, (file % i)).replace("\\", "/"))

return expected_files

def evalParmNoFrame(self, rop, parm, **kwargs):
try:
return evalParmNoFrame(rop, parm, **kwargs)
except Exception as exc:
raise PublishError(
f"Failed evaluating parameter '{parm}' on Rop node: {rop.path()}",
detail=f"{exc}"
)
9 changes: 8 additions & 1 deletion client/ayon_houdini/plugins/publish/extract_render.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,14 @@ def process(self, instance):
# previously rendered version. This situation breaks the publishing.
# because There will be missing frames as ROP nodes typically cannot render different
# frame ranges for each AOV; they always use the same frame range for all AOVs.
self.render_rop(instance)
try:
self.render_rop(instance)
except Exception as e:
raise PublishError(
"Render failed or interrupted",
description=f"An Error occurred while rendering {rop_node.path()}",
detail=f"{e}"
)

# `ExpectedFiles` is a list that includes one dict.
expected_files = instance.data["expectedFiles"][0]
Expand Down
12 changes: 11 additions & 1 deletion client/ayon_houdini/plugins/publish/extract_rop.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,17 @@ def process(self, instance: pyblish.api.Instance):
# This key might be absent because render targets are not yet implemented
# for all product types that use this plugin.
if creator_attribute.get("render_target", "local") == "local":
self.render_rop(instance)
try:
self.render_rop(instance)
except Exception as e:
import hou
rop_node = hou.node(instance.data["instance_node"])
raise PublishError(
"Render failed or interrupted",
description=f"An Error occurred while rendering {rop_node.path()}",
detail=f"{e}"
)

self.validate_expected_frames(instance)

# In some cases representation name is not the the extension
Expand Down
9 changes: 8 additions & 1 deletion client/ayon_houdini/plugins/publish/extract_usd.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,14 @@ def process(self, instance):
mapping.update(instance_mapping)

with remap_paths(ropnode, mapping):
render_rop(ropnode)
try:
render_rop(ropnode)
except Exception as e:
raise PublishError(
"Render failed or interrupted",
description=f"An Error occurred while rendering {ropnode.path()}",
detail=f"{e}"
)

if not os.path.exists(output):
PublishError(f"Output does not exist: {output}")
Expand Down

0 comments on commit 84be3d4

Please sign in to comment.