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

Use PublishError along publishing #190

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
21 commits
Select commit Hold shift + click to select a range
1ddddab
refactor `RuntimeError` to `PublishError`
MustafaJafar Dec 4, 2024
ee0745b
refactor `assert` to `PublishError`
MustafaJafar Dec 4, 2024
47cd409
remove redundant `message` argument
MustafaJafar Dec 4, 2024
4502143
better error message in `SaveCurrentScene`
MustafaJafar Dec 4, 2024
6c891cf
add error description in `SaveCurrentScene`
MustafaJafar Dec 4, 2024
fea6de3
refactor some errors to `PublishError`
MustafaJafar Dec 4, 2024
84be3d4
Use `PublishError` to the caller functions in publish plugins for `re…
MustafaJafar Dec 5, 2024
ece72b3
Move the `PublishError` to the collector
MustafaJafar Dec 5, 2024
65249cc
revert `copy_instance_data` and move the `PublishError` to the `proce…
MustafaJafar Dec 5, 2024
bde4ab3
replace `●` with regular dash `-`
MustafaJafar Dec 5, 2024
0363a57
move `evalParmNoFrame` to `HoudiniInstancePlugin`
MustafaJafar Dec 5, 2024
bb44614
Use `PublishValidationError` instead and use better log message
MustafaJafar Dec 6, 2024
452f73e
remove redundant validator
MustafaJafar Dec 6, 2024
ce5a314
Move `publishError` to the caller publish plugin
MustafaJafar Dec 6, 2024
6de4af0
Move the `PublishError` to `HoudiniInstancePlugin`
MustafaJafar Dec 6, 2024
33c2bb3
revert changes in `get_top_referenced_parm`
MustafaJafar Dec 6, 2024
15dbe43
Implement `PublishError` when calling colorspace function.
MustafaJafar Dec 6, 2024
a03e49b
refactor `f{exc}` to `str(exc)`
MustafaJafar Dec 9, 2024
8bb8bf7
add missing argument
MustafaJafar Dec 9, 2024
107012c
refactor `HoudiniInstancePlugin.evalParmNoFrame` to `HoudiniInstanceP…
MustafaJafar Dec 9, 2024
d92689e
Fix `eval_parm_no_frame` call
MustafaJafar Dec 9, 2024
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
8 changes: 5 additions & 3 deletions client/ayon_houdini/api/lib.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ def get_output_parameter(node):
elif node_type == "vray_renderer":
return node.parm("SettingsOutput_img_file_path")

raise TypeError("Node type '%s' not supported" % node_type)
raise TypeError(f"Node type '{node_type}' is not supported")


def get_lops_rop_context_options(
Expand Down Expand Up @@ -140,7 +140,8 @@ def get_lops_rop_context_options(
end: float = ropnode.evalParm("f2")
inc: float = ropnode.evalParm("f3")
else:
raise ValueError("Unsupported trange value: %s" % trange)
raise ValueError(f"Unsupported trange value: {trange}"
f" for rop node: {ropnode.path()}")
rop_context_options["ropcook"] = 1.0
rop_context_options["ropstart"] = start
rop_context_options["ropend"] = end
Expand All @@ -160,7 +161,8 @@ def get_lops_rop_context_options(
elif option_type == "float":
value: float = ropnode.evalParm(f"optionfloatvalue{i}")
else:
raise ValueError(f"Unsupported option type: {option_type}")
raise ValueError(f"Unsupported option type: {option_type}"
f" on rop node: '{ropnode.path()}'")
rop_context_options[name] = value

return rop_context_options
Expand Down
48 changes: 45 additions & 3 deletions client/ayon_houdini/api/plugin.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,13 +16,27 @@
AYON_INSTANCE_ID,
AVALON_INSTANCE_ID,
load,
publish
publish,
PublishError
)
from ayon_core.lib import BoolDef

from .lib import imprint, read, lsattr, add_self_publish_button, render_rop
from .usd import get_ayon_entity_uri_from_representation_context
from .lib import (
imprint,
read,
lsattr,
add_self_publish_button,
render_rop,
evalParmNoFrame,
get_output_parameter
)

from .usd import get_ayon_entity_uri_from_representation_context
from .colorspace import (
get_color_management_preferences,
get_scene_linear_colorspace,
ARenderProduct
)

SETTINGS_CATEGORY = "houdini"

Expand Down Expand Up @@ -334,6 +348,34 @@ class HoudiniInstancePlugin(pyblish.api.InstancePlugin):
hosts = ["houdini"]
settings_category = SETTINGS_CATEGORY

def eval_parm_no_frame(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=str(exc)
)

def get_output_parameter(self, node):
try:
return get_output_parameter(node)
except Exception as exc:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically we should only be capturing the TypeError here. Right?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes. if the node.parm(...) didn't failed. and I think it won't fail.

raise PublishError(
f"Node type '{node}' is not supported",
detail=str(exc)
)

def get_scene_linear_colorspace(self):
try:
return get_scene_linear_colorspace()
except Exception as exc:
raise PublishError(
"Failed to get scene linear colorspace.",
detail=str(exc)
)



class HoudiniContextPlugin(pyblish.api.ContextPlugin):
"""Base class for Houdini context publish plugins."""
Expand Down
7 changes: 3 additions & 4 deletions client/ayon_houdini/plugins/publish/collect_arnold_rop.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import pyblish.api

from ayon_houdini.api import plugin
from ayon_houdini.api.lib import evalParmNoFrame


class CollectArnoldROPRenderProducts(plugin.HoudiniInstancePlugin):
Expand All @@ -28,13 +27,13 @@ def process(self, instance):

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

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

export_prefix = None
export_products = []
if instance.data["splitRender"]:
export_prefix = evalParmNoFrame(
export_prefix = self.eval_parm_no_frame(
rop, "ar_ass_file", pad_character="0"
)
beauty_export_product = self.get_render_product_name(
Expand Down Expand Up @@ -74,7 +73,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.eval_parm_no_frame(rop, "ar_aov_label{}".format(index))

# NOTE:
# we don't collect the actual AOV path but rather assume
Expand Down
7 changes: 2 additions & 5 deletions client/ayon_houdini/plugins/publish/collect_cache_farm.py
Original file line number Diff line number Diff line change
@@ -1,10 +1,7 @@
import os
import hou
import pyblish.api
from ayon_houdini.api import (
lib,
plugin
)
from ayon_houdini.api import plugin


class CollectFarmCacheFamily(plugin.HoudiniInstancePlugin):
Expand Down Expand Up @@ -44,7 +41,7 @@ def process(self, instance):
# and CollectKarmaROPRenderProducts
# Collect expected files
ropnode = hou.node(instance.data["instance_node"])
output_parm = lib.get_output_parameter(ropnode)
output_parm = self.get_output_parameter(ropnode)
expected_filepath = output_parm.eval()

files = instance.data.setdefault("files", list())
Expand Down
4 changes: 2 additions & 2 deletions client/ayon_houdini/plugins/publish/collect_frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import hou # noqa
import clique
import pyblish.api
from ayon_houdini.api import lib, plugin
from ayon_houdini.api import plugin


class CollectFrames(plugin.HoudiniInstancePlugin):
Expand All @@ -27,7 +27,7 @@ def process(self, instance):

# Evaluate the file name at the first frame.
ropnode = hou.node(instance.data["instance_node"])
output_parm = lib.get_output_parameter(ropnode)
output_parm = self.get_output_parameter(ropnode)
output = output_parm.evalAtFrame(start_frame)
file_name = os.path.basename(output)

Expand Down
3 changes: 1 addition & 2 deletions client/ayon_houdini/plugins/publish/collect_karma_rop.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import hou
import pyblish.api

from ayon_houdini.api.lib import evalParmNoFrame
from ayon_houdini.api import plugin


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

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

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

# Default beauty AOV
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
ColormanagedPyblishPluginMixin
)
from ayon_houdini.api import plugin
from ayon_houdini.api.colorspace import get_scene_linear_colorspace


class CollectLocalRenderInstances(plugin.HoudiniInstancePlugin,
Expand Down Expand Up @@ -87,7 +86,7 @@ def process(self, instance):
# would need to be detected in a renderer-specific way and the
# majority of production scenarios these would not be overridden.
# TODO: Support renderer-specific explicit colorspace overrides
colorspace = get_scene_linear_colorspace()
colorspace = self.get_scene_linear_colorspace()

for aov_name, aov_filepaths in expected_files.items():
dynamic_data = {}
Expand Down
7 changes: 3 additions & 4 deletions client/ayon_houdini/plugins/publish/collect_mantra_rop.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import hou
import pyblish.api

from ayon_houdini.api.lib import evalParmNoFrame
from ayon_houdini.api import plugin


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

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

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

export_prefix = None
export_products = []
if instance.data["splitRender"]:
export_prefix = evalParmNoFrame(
export_prefix = self.eval_parm_no_frame(
rop, "soho_diskfile", pad_character="0"
)
beauty_export_product = self.get_render_product_name(
Expand Down Expand Up @@ -74,7 +73,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.eval_parm_no_frame(rop, aov_name)
aov_product = self.get_render_product_name(
prefix=aov_prefix, suffix=None
)
Expand Down
6 changes: 3 additions & 3 deletions client/ayon_houdini/plugins/publish/collect_output_node.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import pyblish.api
from ayon_core.pipeline.publish import KnownPublishError
from ayon_core.pipeline.publish import PublishError
from ayon_houdini.api import plugin


Expand Down Expand Up @@ -67,8 +67,8 @@ def process(self, instance):
out_node = node.parm("startnode").evalAsNode()

else:
raise KnownPublishError(
"ROP node type '{}' is not supported.".format(node_type)
raise PublishError(
f"ROP node type '{node_type}' is not supported."
)

if not out_node:
Expand Down
7 changes: 3 additions & 4 deletions client/ayon_houdini/plugins/publish/collect_redshift_rop.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,6 @@
import hou
import pyblish.api

from ayon_houdini.api.lib import evalParmNoFrame
from ayon_houdini.api import plugin


Expand All @@ -27,12 +26,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.eval_parm_no_frame(rop, "RS_outputFileNamePrefix")
beauty_suffix = rop.evalParm("RS_outputBeautyAOVSuffix")

export_products = []
if instance.data["splitRender"]:
export_prefix = evalParmNoFrame(
export_prefix = self.eval_parm_no_frame(
rop, "RS_archive_file", pad_character="0"
)
beauty_export_product = self.get_render_product_name(
Expand Down Expand Up @@ -80,7 +79,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.eval_parm_no_frame(rop, f"RS_aovCustomPrefix_{i}")
if not aov_prefix:
aov_prefix = default_prefix

Expand Down
26 changes: 22 additions & 4 deletions client/ayon_houdini/plugins/publish/collect_render_colorspace.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
from ayon_houdini.api import plugin, colorspace
from ayon_core.pipeline import PublishError
from ayon_houdini.api import plugin
from ayon_houdini.api.colorspace import (
ARenderProduct,
get_color_management_preferences
)

import pyblish.api

Expand Down Expand Up @@ -32,14 +37,27 @@ def process(self, instance):
"Skipping collecting of render colorspace.")
return
aov_name = list(expected_files[0].keys())
render_products_data = colorspace.ARenderProduct(aov_name)
try:
render_products_data = ARenderProduct(aov_name)
except Exception as exc:
raise PublishError(
"Failed to get render products with colorspace.",
detail=str(exc)
)
instance.data["renderProducts"] = render_products_data

# Required data for `create_instances_for_aov`
colorspace_data = colorspace.get_color_management_preferences()
try:
colorspace_data = get_color_management_preferences()
except Exception as exc:
raise PublishError(
"Failed to get color management preferences.",
detail=str(exc)
)

instance.data["colorspaceConfig"] = colorspace_data["config"]
instance.data["colorspaceDisplay"] = colorspace_data["display"]
instance.data["colorspaceView"] = colorspace_data["view"]

# Used in `create_skeleton_instance()`
instance.data["colorspace"] = colorspace.get_scene_linear_colorspace()
instance.data["colorspace"] = self.get_scene_linear_colorspace()
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

import pyblish.api

from ayon_core.pipeline.publish import PublishError
from ayon_houdini.api import plugin
from ayon_houdini.api.usd import (
get_usd_render_rop_rendersettings
Expand Down Expand Up @@ -107,10 +108,10 @@ def replace(match):
filename = os.path.join(dirname, filename_base)
filename = filename.replace("\\", "/")

assert "#" in filename, (
"Couldn't resolve render product name "
"with frame number: %s" % name
)
if "#" not in filename:
raise PublishError(
f"Couldn't resolve render product name with frame number: {name}"
)

filenames.append(filename)

Expand Down
25 changes: 20 additions & 5 deletions client/ayon_houdini/plugins/publish/collect_usd_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import pyblish.api

from ayon_core.pipeline.create import get_product_name
from ayon_core.pipeline.publish import PublishError
from ayon_houdini.api import plugin
import ayon_houdini.api.usd as usdlib

Expand Down Expand Up @@ -71,7 +72,15 @@ def process(self, instance):
rop_node = hou.node(instance.data["instance_node"])

save_layers = []
for layer in usdlib.get_configured_save_layers(rop_node):
try:
layers = usdlib.get_configured_save_layers(rop_node)
except Exception as exc:
raise PublishError(
f"Failed to get USD layers on rop node '{rop_node}'",
detail=str(exc)
)

for layer in layers:

info = layer.rootPrims.get("HoudiniLayerInfo")
save_path = info.customData.get("HoudiniSavePath")
Expand Down Expand Up @@ -147,10 +156,16 @@ def process(self, instance):

# Inherit "use handles" from the source instance
# TODO: Do we want to maybe copy full `publish_attributes` instead?
copy_instance_data(
instance, layer_inst,
attr="publish_attributes.CollectRopFrameRange.use_handles"
)
try:
copy_instance_data(
instance, layer_inst,
attr="publish_attributes.CollectRopFrameRange.use_handles"
)
except Exception as exc:
raise PublishError(
"Failed to copy instance data.",
detail=str(exc)
)

# Allow this subset to be grouped into a USD Layer on creation
layer_inst.data["productGroup"] = (
Expand Down
Loading
Loading