From 72e980b1e493c185794900ff59dfcb9e888f838a Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Mon, 11 Dec 2023 12:58:38 +0100 Subject: [PATCH 1/4] keys in hierarchyContext are always names --- .../standalonepublisher/plugins/publish/collect_hierarchy.py | 4 ++-- .../traypublisher/plugins/publish/collect_shot_instances.py | 4 ++-- openpype/plugins/publish/collect_hierarchy.py | 5 +++-- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/openpype/hosts/standalonepublisher/plugins/publish/collect_hierarchy.py b/openpype/hosts/standalonepublisher/plugins/publish/collect_hierarchy.py index 9109bf67266..eb06875601e 100644 --- a/openpype/hosts/standalonepublisher/plugins/publish/collect_hierarchy.py +++ b/openpype/hosts/standalonepublisher/plugins/publish/collect_hierarchy.py @@ -257,8 +257,6 @@ def process(self, context): if 'shot' not in instance.data.get('family', ''): continue - name = instance.data["asset"] - # get handles handle_start = int(instance.data["handleStart"]) handle_end = int(instance.data["handleEnd"]) @@ -286,6 +284,8 @@ def process(self, context): parents = instance.data.get('parents', []) self.log.debug(f"parents: {pformat(parents)}") + # Split by '/' for AYON where asset is a path + name = instance.data["asset"].split("/")[-1] actual = {name: in_info} for parent in reversed(parents): diff --git a/openpype/hosts/traypublisher/plugins/publish/collect_shot_instances.py b/openpype/hosts/traypublisher/plugins/publish/collect_shot_instances.py index e00ac64244a..b99b634da17 100644 --- a/openpype/hosts/traypublisher/plugins/publish/collect_shot_instances.py +++ b/openpype/hosts/traypublisher/plugins/publish/collect_shot_instances.py @@ -155,8 +155,6 @@ def _solve_hierarchy_context(self, instance): else {} ) - asset_name = instance.data["asset"] - # get handles handle_start = int(instance.data["handleStart"]) handle_end = int(instance.data["handleEnd"]) @@ -177,6 +175,8 @@ def _solve_hierarchy_context(self, instance): parents = instance.data.get('parents', []) + # Split by '/' for AYON where asset is a path + asset_name = instance.data["asset"].split("/")[-1] actual = {asset_name: in_info} for parent in reversed(parents): diff --git a/openpype/plugins/publish/collect_hierarchy.py b/openpype/plugins/publish/collect_hierarchy.py index b5fd1e4bb97..32f10ba4c8a 100644 --- a/openpype/plugins/publish/collect_hierarchy.py +++ b/openpype/plugins/publish/collect_hierarchy.py @@ -61,8 +61,9 @@ def process(self, context): "resolutionHeight": instance.data["resolutionHeight"], "pixelAspect": instance.data["pixelAspect"] } - - actual = {instance.data["asset"]: shot_data} + # Split by '/' for AYON where asset is a path + name = instance.data["asset"].split("/")[-1] + actual = {name: shot_data} for parent in reversed(instance.data["parents"]): next_dict = {} From 8a3a318480699e3f12866e0783973338c6bbfc05 Mon Sep 17 00:00:00 2001 From: iLLiCiTiT Date: Mon, 11 Dec 2023 12:59:18 +0100 Subject: [PATCH 2/4] modify extract hierarchy to ayon to work with names --- .../publish/extract_hierarchy_to_ayon.py | 23 +++++++++++-------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/openpype/plugins/publish/extract_hierarchy_to_ayon.py b/openpype/plugins/publish/extract_hierarchy_to_ayon.py index ef69369d673..8f791a60938 100644 --- a/openpype/plugins/publish/extract_hierarchy_to_ayon.py +++ b/openpype/plugins/publish/extract_hierarchy_to_ayon.py @@ -223,23 +223,24 @@ def _filter_hierarchy(self, context): valid_ids = set() hierarchy_queue = collections.deque() - hierarchy_queue.append((project_id, project_children_context)) + hierarchy_queue.append((project_id, "", project_children_context)) while hierarchy_queue: queue_item = hierarchy_queue.popleft() - parent_id, children_context = queue_item + parent_id, parent_path, children_context = queue_item if not children_context: continue - for asset, asset_info in children_context.items(): + for folder_name, folder_info in children_context.items(): + folder_path = "{}/{}".format(parent_path, folder_name) if ( - asset not in active_folder_paths - and not asset_info.get("childs") + folder_path not in active_folder_paths + and not folder_info.get("childs") ): continue - asset_name = asset.split("/")[-1] + item_id = uuid.uuid4().hex - new_item = copy.deepcopy(asset_info) - new_item["name"] = asset_name + new_item = copy.deepcopy(folder_info) + new_item["name"] = folder_name new_item["children"] = [] new_children_context = new_item.pop("childs", None) tasks = new_item.pop("tasks", {}) @@ -253,9 +254,11 @@ def _filter_hierarchy(self, context): items_by_id[item_id] = new_item parent_id_by_item_id[item_id] = parent_id - if asset in active_folder_paths: + if folder_path in active_folder_paths: valid_ids.add(item_id) - hierarchy_queue.append((item_id, new_children_context)) + hierarchy_queue.append( + (item_id, folder_path, new_children_context) + ) if not valid_ids: return None From ac49ab3803a993238eb77ed0eb04731bdeba8d52 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Tue, 12 Dec 2023 12:53:31 +0100 Subject: [PATCH 3/4] fill template data for editorial --- openpype/plugins/publish/collect_resources_path.py | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/openpype/plugins/publish/collect_resources_path.py b/openpype/plugins/publish/collect_resources_path.py index 0f29fec0547..9298ffe10c5 100644 --- a/openpype/plugins/publish/collect_resources_path.py +++ b/openpype/plugins/publish/collect_resources_path.py @@ -68,7 +68,6 @@ class CollectResourcesPath(pyblish.api.InstancePlugin): ] def process(self, instance): - anatomy = instance.context.data["anatomy"] template_data = copy.deepcopy(instance.data["anatomyData"]) @@ -86,6 +85,18 @@ def process(self, instance): "hierarchy": instance.data["hierarchy"] }) + # Add fill keys for editorial publishing creating new entity + # TODO handle in editorial plugin + if ( + instance.data.get("newAssetPublishing") + and "asset" not in template_data + ): + asset_name = instance.data["asset"].split("/")[-1] + template_data["asset"] = asset_name + template_data["folder"] = { + "name": asset_name + } + publish_templates = anatomy.templates_obj["publish"] if "folder" in publish_templates: publish_folder = publish_templates["folder"].format_strict( From 476921ce7ad3207e414a129c20de55fb22cd7006 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Tue, 12 Dec 2023 13:55:41 +0100 Subject: [PATCH 4/4] move hierarchy key fill under 'newAssetPublishing' condition --- .../plugins/publish/collect_resources_path.py | 25 ++++++++----------- 1 file changed, 10 insertions(+), 15 deletions(-) diff --git a/openpype/plugins/publish/collect_resources_path.py b/openpype/plugins/publish/collect_resources_path.py index 9298ffe10c5..af0ef17789d 100644 --- a/openpype/plugins/publish/collect_resources_path.py +++ b/openpype/plugins/publish/collect_resources_path.py @@ -79,23 +79,18 @@ def process(self, instance): "representation": "TEMP" }) - # For the first time publish - if instance.data.get("hierarchy"): - template_data.update({ - "hierarchy": instance.data["hierarchy"] - }) - # Add fill keys for editorial publishing creating new entity # TODO handle in editorial plugin - if ( - instance.data.get("newAssetPublishing") - and "asset" not in template_data - ): - asset_name = instance.data["asset"].split("/")[-1] - template_data["asset"] = asset_name - template_data["folder"] = { - "name": asset_name - } + if instance.data.get("newAssetPublishing"): + if "hierarchy" not in instance.data: + template_data["hierarchy"] = instance.data["hierarchy"] + + if "asset" not in template_data: + asset_name = instance.data["asset"].split("/")[-1] + template_data["asset"] = asset_name + template_data["folder"] = { + "name": asset_name + } publish_templates = anatomy.templates_obj["publish"] if "folder" in publish_templates: