Skip to content

Commit

Permalink
revert copy_instance_data and move the PublishError to the `proce…
Browse files Browse the repository at this point in the history
…ss` method
  • Loading branch information
MustafaJafar committed Dec 5, 2024
1 parent ece72b3 commit 65249cc
Showing 1 changed file with 14 additions and 11 deletions.
25 changes: 14 additions & 11 deletions client/ayon_houdini/plugins/publish/collect_usd_layers.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,8 @@ def copy_instance_data(instance_src, instance_dest, attr):
in the source instance's data.
Raises:
PublishError: If the key does not exist on the source instance.
PublishError: If a parent key already exists on the destination
KeyError: If the key does not exist on the source instance.
AssertionError: If a parent key already exists on the destination
instance but is not of the correct type (= is not a dict)
"""
Expand All @@ -39,15 +39,12 @@ def copy_instance_data(instance_src, instance_dest, attr):
keys = attr.split(".")
for i, key in enumerate(keys):
if key not in src_data:
raise PublishError(
f"key '{key}' does not exist on the source instance."
)
break

src_value = src_data[key]
if i != len(key):
dest_data = dest_data.setdefault(key, {})
if not isinstance(dest_data, dict):
raise PublishError("Destination must be a dict.")
assert isinstance(dest_data, dict), "Destination must be a dict"
src_data = src_value
else:
# Last iteration - assign the value
Expand Down Expand Up @@ -159,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=f"{exc}"
)

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

0 comments on commit 65249cc

Please sign in to comment.