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

Chore: Make sure udim in representation is not a list #764

20 changes: 20 additions & 0 deletions client/ayon_core/pipeline/load/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down Expand Up @@ -681,6 +698,9 @@ def path_from_representation():

try:
context = representation["context"]

_fix_representation_context_compatibility(context)

context["root"] = root
path = StringTemplate.format_strict_template(
template, context
Expand Down
5 changes: 0 additions & 5 deletions client/ayon_core/plugins/publish/integrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -789,11 +789,6 @@ def prepare_representation(
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
Expand Down