From 321e9ff96c8a859370affa26e9ed784f526b9ce7 Mon Sep 17 00:00:00 2001 From: Jakub Trllo Date: Mon, 4 Mar 2024 15:53:49 +0100 Subject: [PATCH] hiero use folder and task entities --- client/ayon_core/hosts/hiero/api/lib.py | 2 +- client/ayon_core/hosts/hiero/api/plugin.py | 33 +++++++------------ .../hosts/hiero/plugins/load/load_effects.py | 8 ++--- .../publish/collect_frame_tag_instances.py | 5 +-- .../plugins/publish/precollect_instances.py | 12 +++---- 5 files changed, 24 insertions(+), 36 deletions(-) diff --git a/client/ayon_core/hosts/hiero/api/lib.py b/client/ayon_core/hosts/hiero/api/lib.py index abf3690f9e..c46269b532 100644 --- a/client/ayon_core/hosts/hiero/api/lib.py +++ b/client/ayon_core/hosts/hiero/api/lib.py @@ -588,7 +588,7 @@ def imprint(track_item, data=None): Examples: data = { - 'asset': 'sq020sh0280', + 'folderPath': '/shots/sq020sh0280', 'productType': 'render', 'productName': 'productMain' } diff --git a/client/ayon_core/hosts/hiero/api/plugin.py b/client/ayon_core/hosts/hiero/api/plugin.py index 51601a7ee0..d2c0310f1e 100644 --- a/client/ayon_core/hosts/hiero/api/plugin.py +++ b/client/ayon_core/hosts/hiero/api/plugin.py @@ -409,8 +409,9 @@ class ClipLoader: "Cannot Load selected data, look into database " "or call your supervisor") - # inject asset data to representation dict - self._get_asset_data() + # inject folder data to representation dict + folder_entity = self.context["folder"] + self.data["folderAttributes"] = folder_entity["attrib"] log.info("__init__ self.data: `{}`".format(pformat(self.data))) log.info("__init__ options: `{}`".format(pformat(options))) @@ -424,7 +425,7 @@ class ClipLoader: self.active_sequence = lib.get_current_sequence(new=True) self.active_sequence.setFramerate( hiero.core.TimeBase.fromString( - str(self.data["assetData"]["fps"]))) + str(self.data["folderAttributes"]["fps"]))) else: self.active_sequence = lib.get_current_sequence() @@ -447,7 +448,7 @@ class ClipLoader: # create name repr = self.context["representation"] repr_cntx = repr["context"] - asset = str(repr_cntx["asset"]) + folder_name = str(repr_cntx["asset"]) product_name = str(repr_cntx["subset"]) representation = str(repr_cntx["representation"]) self.data["clip_name"] = self.clip_name_template.format(**repr_cntx) @@ -470,7 +471,7 @@ class ClipLoader: hierarchy = str("/".join(( "Loader", repr_cntx["hierarchy"].replace("\\", "/"), - asset + folder_name ))) self.data["binPath"] = hierarchy @@ -487,16 +488,6 @@ class ClipLoader: file = file.replace(frame, "#" * padding) self.data["path"] = file - def _get_asset_data(self): - """ Get all available asset data - - joint `data` key with asset.data dict into the representation - - """ - - asset_doc = self.context["asset"] - self.data["assetData"] = asset_doc["data"] - def _make_track_item(self, source_bin_item, audio=False): """ Create track item with """ @@ -533,9 +524,9 @@ class ClipLoader: self.handle_start = self.data["versionData"].get("handleStart") self.handle_end = self.data["versionData"].get("handleEnd") if self.handle_start is None: - self.handle_start = self.data["assetData"]["handleStart"] + self.handle_start = self.data["folderAttributes"]["handleStart"] if self.handle_end is None: - self.handle_end = self.data["assetData"]["handleEnd"] + self.handle_end = self.data["folderAttributes"]["handleEnd"] self.handle_start = int(self.handle_start) self.handle_end = int(self.handle_end) @@ -552,11 +543,11 @@ class ClipLoader: last_timeline_out = int(last_track_item.timelineOut()) + 1 self.timeline_in = last_timeline_out self.timeline_out = last_timeline_out + int( - self.data["assetData"]["clipOut"] - - self.data["assetData"]["clipIn"]) + self.data["folderAttributes"]["clipOut"] + - self.data["folderAttributes"]["clipIn"]) else: - self.timeline_in = int(self.data["assetData"]["clipIn"]) - self.timeline_out = int(self.data["assetData"]["clipOut"]) + self.timeline_in = int(self.data["folderAttributes"]["clipIn"]) + self.timeline_out = int(self.data["folderAttributes"]["clipOut"]) log.debug("__ self.timeline_in: {}".format(self.timeline_in)) log.debug("__ self.timeline_out: {}".format(self.timeline_out)) diff --git a/client/ayon_core/hosts/hiero/plugins/load/load_effects.py b/client/ayon_core/hosts/hiero/plugins/load/load_effects.py index c72f1bdc64..c6ac20bb04 100644 --- a/client/ayon_core/hosts/hiero/plugins/load/load_effects.py +++ b/client/ayon_core/hosts/hiero/plugins/load/load_effects.py @@ -35,7 +35,7 @@ class LoadEffects(load.LoaderPlugin): Arguments: context (dict): context of version name (str): name of the version - namespace (str): asset name + namespace (str): Folder name. data (dict): compulsory attribute > not used Returns: @@ -46,10 +46,10 @@ class LoadEffects(load.LoaderPlugin): active_sequence, "Loaded_{}".format(name)) # get main variables - namespace = namespace or context["asset"]["name"] + namespace = namespace or context["folder"]["name"] object_name = "{}_{}".format(name, namespace) - clip_in = context["asset"]["data"]["clipIn"] - clip_out = context["asset"]["data"]["clipOut"] + clip_in = context["folder"]["attrib"]["clipIn"] + clip_out = context["folder"]["attrib"]["clipOut"] data_imprint = { "objectName": object_name, diff --git a/client/ayon_core/hosts/hiero/plugins/publish/collect_frame_tag_instances.py b/client/ayon_core/hosts/hiero/plugins/publish/collect_frame_tag_instances.py index d73b5d4667..0e5d849b78 100644 --- a/client/ayon_core/hosts/hiero/plugins/publish/collect_frame_tag_instances.py +++ b/client/ayon_core/hosts/hiero/plugins/publish/collect_frame_tag_instances.py @@ -5,8 +5,6 @@ import json import pyblish.api -from ayon_core.client import get_asset_name_identifier - class CollectFrameTagInstances(pyblish.api.ContextPlugin): """Collect frames from tags. @@ -104,8 +102,7 @@ class CollectFrameTagInstances(pyblish.api.ContextPlugin): # first collect all available product tag frames product_data = {} - context_asset_doc = context.data["assetEntity"] - context_folder_path = get_asset_name_identifier(context_asset_doc) + context_folder_path = context.data["folderEntity"]["path"] for tag_data in sequence_tags: frame = int(tag_data["start"]) diff --git a/client/ayon_core/hosts/hiero/plugins/publish/precollect_instances.py b/client/ayon_core/hosts/hiero/plugins/publish/precollect_instances.py index 911b96c280..d921f37934 100644 --- a/client/ayon_core/hosts/hiero/plugins/publish/precollect_instances.py +++ b/client/ayon_core/hosts/hiero/plugins/publish/precollect_instances.py @@ -85,7 +85,7 @@ class PrecollectInstances(pyblish.api.ContextPlugin): if k not in ("id", "applieswhole", "label") }) - asset, asset_name = self._get_asset_data(tag_data) + asset, asset_name = self._get_folder_data(tag_data) product_name = tag_data.get("productName") if product_name is None: @@ -242,13 +242,13 @@ class PrecollectInstances(pyblish.api.ContextPlugin): self.log.debug( "_ instance.data: {}".format(pformat(instance.data))) - def _get_asset_data(self, data): + def _get_folder_data(self, data): folder_path = data.pop("folderPath", None) if data.get("asset_name"): - asset_name = data["asset_name"] + folder_name = data["asset_name"] else: - asset_name = data["asset"] + folder_name = data["asset"] # backward compatibility for clip tags # which are missing folderPath key @@ -257,10 +257,10 @@ class PrecollectInstances(pyblish.api.ContextPlugin): hierarchy_path = data["hierarchy"] folder_path = "/{}/{}".format( hierarchy_path, - asset_name + folder_name ) - return folder_path, asset_name + return folder_path, folder_name def create_audio_instance(self, context, **data): product_name = "audioMain"