Merge pull request #764 from ynput/enhancement/AY-5975_Maya-Manage---Set-VersionUpdate-to-latest-action-doesnt-work-for-Image-Product-using-UDIM

Chore: Make sure udim in representation is not a list
This commit is contained in:
Jakub Trllo 2024-07-10 15:47:25 +02:00 committed by GitHub
commit d15bdd494c
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 20 additions and 5 deletions

View file

@ -587,6 +587,21 @@ def switch_container(container, representation, loader_plugin=None):
return loader.switch(container, context)
def _fix_representation_context_compatibility(repre_context):
"""Helper function to fix representation context compatibility.
Args:
repre_context (dict): Representation context.
"""
# Auto-fix 'udim' being list of integers
# - This is a legacy issue for old representation entities,
# added 24/07/10
udim = repre_context.get("udim")
if isinstance(udim, list):
repre_context["udim"] = udim[0]
def get_representation_path_from_context(context):
"""Preparation wrapper using only context as a argument"""
from ayon_core.pipeline import get_current_project_name
@ -638,7 +653,9 @@ def get_representation_path_with_anatomy(repre_entity, anatomy):
try:
context = repre_entity["context"]
_fix_representation_context_compatibility(context)
context["root"] = anatomy.roots
path = StringTemplate.format_strict_template(template, context)
except TemplateUnsolved as exc:
@ -681,6 +698,9 @@ def get_representation_path(representation, root=None):
try:
context = representation["context"]
_fix_representation_context_compatibility(context)
context["root"] = root
path = StringTemplate.format_strict_template(
template, context

View file

@ -789,11 +789,6 @@ class IntegrateAsset(pyblish.api.InstancePlugin):
if value is not None:
repre_context[key] = value
# Explicitly store the full list even though template data might
# have a different value because it uses just a single udim tile
if repre.get("udim"):
repre_context["udim"] = repre.get("udim") # store list
# Use previous representation's id if there is a name match
existing = existing_repres_by_name.get(repre["name"].lower())
repre_id = None