From f207c396495ae65969848291f58f82c9d83f478f Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Mon, 26 Feb 2024 14:45:06 +0100 Subject: [PATCH] Refactor tag data handling for backward compatibility. - Update product_name and product_type handling - Add error logging for missing values --- client/ayon_core/hosts/resolve/api/plugin.py | 1 - .../plugins/publish/precollect_instances.py | 26 ++++++++++++++++++- 2 files changed, 25 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/hosts/resolve/api/plugin.py b/client/ayon_core/hosts/resolve/api/plugin.py index 607bf58afd..0c63dead32 100644 --- a/client/ayon_core/hosts/resolve/api/plugin.py +++ b/client/ayon_core/hosts/resolve/api/plugin.py @@ -630,7 +630,6 @@ class PublishClip: self.track_name = str(track_name).replace(" ", "_") self.track_index = int(timeline_item_data["track"]["index"]) - # adding tag.family into tag if kwargs.get("avalon"): self.tag_data.update(kwargs["avalon"]) diff --git a/client/ayon_core/hosts/resolve/plugins/publish/precollect_instances.py b/client/ayon_core/hosts/resolve/plugins/publish/precollect_instances.py index 3154e0c3e5..b1374859e3 100644 --- a/client/ayon_core/hosts/resolve/plugins/publish/precollect_instances.py +++ b/client/ayon_core/hosts/resolve/plugins/publish/precollect_instances.py @@ -64,7 +64,28 @@ class PrecollectInstances(pyblish.api.ContextPlugin): }) asset = tag_data["folder_path"] - product_name = tag_data["productName"] + + # TODO: remove backward compatibility + product_name = tag_data.get("productName") + if product_name is None: + # backward compatibility: subset -> productName + product_name = tag_data.get("subset") + + # backward compatibility: product_name should not be missing + if not product_name: + self.log.error( + "Product name is not defined for: {}".format(asset)) + + # TODO: remove backward compatibility + product_type = tag_data.get("productType") + if product_type is None: + # backward compatibility: family -> productType + product_type = tag_data.get("family") + + # backward compatibility: product_type should not be missing + if not product_type: + self.log.error( + "Product type is not defined for: {}".format(asset)) data.update({ "name": "{}_{}".format(asset, product_name), @@ -77,6 +98,9 @@ class PrecollectInstances(pyblish.api.ContextPlugin): "handleEnd": handle_end, "newAssetPublishing": True, "families": ["clip"], + "productType": product_type, + "productName": product_name, + "family": product_type }) # otio clip data