From b06a7108b64246dc022f3a4472b896d53e2311aa Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 16 Jun 2023 22:22:08 +0800 Subject: [PATCH 01/19] add collector to tray publisher for getting frame range data --- .../publish/collect_anatomy_frame_range.py | 33 +++++++++++++++++++ .../project_settings/traypublisher.json | 5 +++ .../schema_project_traypublisher.json | 4 +++ 3 files changed, 42 insertions(+) create mode 100644 openpype/plugins/publish/collect_anatomy_frame_range.py diff --git a/openpype/plugins/publish/collect_anatomy_frame_range.py b/openpype/plugins/publish/collect_anatomy_frame_range.py new file mode 100644 index 0000000000..71a5dcfeb0 --- /dev/null +++ b/openpype/plugins/publish/collect_anatomy_frame_range.py @@ -0,0 +1,33 @@ +import pyblish.api + + +class CollectAnatomyFrameRange(pyblish.api.InstancePlugin): + """Collect Frame Range specific Anatomy data. + + Plugin is running for all instances on context even not active instances. + """ + + order = pyblish.api.CollectorOrder + 0.491 + label = "Collect Anatomy Frame Range" + hosts = ["traypublisher"] + + def process(self, instance): + self.log.info("Collecting Anatomy frame range.") + asset_doc = instance.data.get("assetEntity") + if not asset_doc: + self.log.info("Missing required data..") + return + + asset_data = asset_doc["data"] + for key in ( + "fps", + "frameStart", + "frameEnd", + "handleStart", + "handleEnd" + ): + if key not in instance.data and key in asset_data: + value = asset_data[key] + instance.data[key] = value + + self.log.info("Anatomy frame range collection finished.") diff --git a/openpype/settings/defaults/project_settings/traypublisher.json b/openpype/settings/defaults/project_settings/traypublisher.json index 3a42c93515..4ad492c77b 100644 --- a/openpype/settings/defaults/project_settings/traypublisher.json +++ b/openpype/settings/defaults/project_settings/traypublisher.json @@ -318,6 +318,11 @@ } }, "publish": { + "CollectAnatomyFrameRange": { + "enabled": true, + "optional": true, + "active": true + }, "ValidateFrameRange": { "enabled": true, "optional": true, diff --git a/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json b/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json index 3703d82856..44442a07d4 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json @@ -343,6 +343,10 @@ "type": "schema_template", "name": "template_validate_plugin", "template_data": [ + { + "key": "CollectAnatomyFrameRange", + "label": "Collect Anatomy frame range" + }, { "key": "ValidateFrameRange", "label": "Validate frame range" From dae7ed439a47012010b0804cb6708f2660ac61e1 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 16 Jun 2023 22:51:06 +0800 Subject: [PATCH 02/19] add the related families --- openpype/plugins/publish/collect_anatomy_frame_range.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/openpype/plugins/publish/collect_anatomy_frame_range.py b/openpype/plugins/publish/collect_anatomy_frame_range.py index 71a5dcfeb0..134e7b6f72 100644 --- a/openpype/plugins/publish/collect_anatomy_frame_range.py +++ b/openpype/plugins/publish/collect_anatomy_frame_range.py @@ -9,6 +9,9 @@ class CollectAnatomyFrameRange(pyblish.api.InstancePlugin): order = pyblish.api.CollectorOrder + 0.491 label = "Collect Anatomy Frame Range" + families = ["plate", "pointcache", + "vdbcache","online", + "render"] hosts = ["traypublisher"] def process(self, instance): From bbfe1566864d6ace9b29c97ab14b8586fcb89f5d Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Fri, 16 Jun 2023 22:52:11 +0800 Subject: [PATCH 03/19] hound fix --- openpype/plugins/publish/collect_anatomy_frame_range.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/plugins/publish/collect_anatomy_frame_range.py b/openpype/plugins/publish/collect_anatomy_frame_range.py index 134e7b6f72..05a3fa1a76 100644 --- a/openpype/plugins/publish/collect_anatomy_frame_range.py +++ b/openpype/plugins/publish/collect_anatomy_frame_range.py @@ -10,7 +10,7 @@ class CollectAnatomyFrameRange(pyblish.api.InstancePlugin): order = pyblish.api.CollectorOrder + 0.491 label = "Collect Anatomy Frame Range" families = ["plate", "pointcache", - "vdbcache","online", + "vdbcache", "online", "render"] hosts = ["traypublisher"] From 64d24f26bb6c99638eace695ec84677c790371eb Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Mon, 19 Jun 2023 18:21:01 +0800 Subject: [PATCH 04/19] roy and oscar's comments --- .../plugins/publish/collect_anatomy_frame_range.py | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/openpype/plugins/publish/collect_anatomy_frame_range.py b/openpype/plugins/publish/collect_anatomy_frame_range.py index 05a3fa1a76..f59b381a5f 100644 --- a/openpype/plugins/publish/collect_anatomy_frame_range.py +++ b/openpype/plugins/publish/collect_anatomy_frame_range.py @@ -15,13 +15,15 @@ class CollectAnatomyFrameRange(pyblish.api.InstancePlugin): hosts = ["traypublisher"] def process(self, instance): - self.log.info("Collecting Anatomy frame range.") + self.log.debug("Collecting Anatomy frame range.") asset_doc = instance.data.get("assetEntity") if not asset_doc: - self.log.info("Missing required data..") + self.log.debug("Instance has no asset entity set." + " Skipping collecting frame range data.") return asset_data = asset_doc["data"] + key_sets = [] for key in ( "fps", "frameStart", @@ -30,7 +32,8 @@ class CollectAnatomyFrameRange(pyblish.api.InstancePlugin): "handleEnd" ): if key not in instance.data and key in asset_data: - value = asset_data[key] - instance.data[key] = value + instance.data[key] = asset_data[key] + key_sets.append(key) - self.log.info("Anatomy frame range collection finished.") + self.log.debug(f"Anatomy frame range data {key_sets} " + "has been collected from asset entity.") From dff197941e629ed21ed43e6b673c7aa0102e1381 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Mon, 19 Jun 2023 19:39:04 +0800 Subject: [PATCH 05/19] roy's comment --- openpype/plugins/publish/collect_anatomy_frame_range.py | 1 - 1 file changed, 1 deletion(-) diff --git a/openpype/plugins/publish/collect_anatomy_frame_range.py b/openpype/plugins/publish/collect_anatomy_frame_range.py index f59b381a5f..2da21d55e2 100644 --- a/openpype/plugins/publish/collect_anatomy_frame_range.py +++ b/openpype/plugins/publish/collect_anatomy_frame_range.py @@ -15,7 +15,6 @@ class CollectAnatomyFrameRange(pyblish.api.InstancePlugin): hosts = ["traypublisher"] def process(self, instance): - self.log.debug("Collecting Anatomy frame range.") asset_doc = instance.data.get("assetEntity") if not asset_doc: self.log.debug("Instance has no asset entity set." From a57c6b58cc2d1c63e3d8b9a752e79001b266c028 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Mon, 19 Jun 2023 20:11:25 +0800 Subject: [PATCH 06/19] roy's comment on docstring --- openpype/plugins/publish/collect_anatomy_frame_range.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/plugins/publish/collect_anatomy_frame_range.py b/openpype/plugins/publish/collect_anatomy_frame_range.py index 2da21d55e2..381b927e63 100644 --- a/openpype/plugins/publish/collect_anatomy_frame_range.py +++ b/openpype/plugins/publish/collect_anatomy_frame_range.py @@ -2,9 +2,9 @@ import pyblish.api class CollectAnatomyFrameRange(pyblish.api.InstancePlugin): - """Collect Frame Range specific Anatomy data. + """Collect Frame Range data. - Plugin is running for all instances on context even not active instances. + Plugin is running for all instances even not active ones. """ order = pyblish.api.CollectorOrder + 0.491 From a9181fe26e612616a9405517b0a600b300772880 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Mon, 19 Jun 2023 20:43:26 +0800 Subject: [PATCH 07/19] rename the plugin --- ...ect_anatomy_frame_range.py => collect_frame_range_data.py} | 4 +--- .../settings/defaults/project_settings/traypublisher.json | 2 +- .../schemas/projects_schema/schema_project_traypublisher.json | 4 ++-- 3 files changed, 4 insertions(+), 6 deletions(-) rename openpype/plugins/publish/{collect_anatomy_frame_range.py => collect_frame_range_data.py} (91%) diff --git a/openpype/plugins/publish/collect_anatomy_frame_range.py b/openpype/plugins/publish/collect_frame_range_data.py similarity index 91% rename from openpype/plugins/publish/collect_anatomy_frame_range.py rename to openpype/plugins/publish/collect_frame_range_data.py index 381b927e63..9110439645 100644 --- a/openpype/plugins/publish/collect_anatomy_frame_range.py +++ b/openpype/plugins/publish/collect_frame_range_data.py @@ -2,9 +2,7 @@ import pyblish.api class CollectAnatomyFrameRange(pyblish.api.InstancePlugin): - """Collect Frame Range data. - - Plugin is running for all instances even not active ones. + """Collect Frame Range data. """ order = pyblish.api.CollectorOrder + 0.491 diff --git a/openpype/settings/defaults/project_settings/traypublisher.json b/openpype/settings/defaults/project_settings/traypublisher.json index 1f1c7115be..b7a01e584b 100644 --- a/openpype/settings/defaults/project_settings/traypublisher.json +++ b/openpype/settings/defaults/project_settings/traypublisher.json @@ -329,7 +329,7 @@ } }, "publish": { - "CollectAnatomyFrameRange": { + "CollectFrameRangeData": { "enabled": true, "optional": true, "active": true diff --git a/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json b/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json index 53b060d3ca..9e3a1b703e 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json @@ -350,8 +350,8 @@ "name": "template_validate_plugin", "template_data": [ { - "key": "CollectAnatomyFrameRange", - "label": "Collect Anatomy frame range" + "key": "CollectFrameRangeData", + "label": "Collect frame range data" }, { "key": "ValidateFrameRange", From 87ddaa1756861977ed3f3796026719c83b7edde9 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Mon, 19 Jun 2023 20:51:23 +0800 Subject: [PATCH 08/19] refactor the collector --- openpype/plugins/publish/collect_frame_range_data.py | 4 ++-- .../schemas/projects_schema/schema_project_traypublisher.json | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/openpype/plugins/publish/collect_frame_range_data.py b/openpype/plugins/publish/collect_frame_range_data.py index 9110439645..ff773d4c59 100644 --- a/openpype/plugins/publish/collect_frame_range_data.py +++ b/openpype/plugins/publish/collect_frame_range_data.py @@ -1,12 +1,12 @@ import pyblish.api -class CollectAnatomyFrameRange(pyblish.api.InstancePlugin): +class CollectFrameRangeData(pyblish.api.InstancePlugin): """Collect Frame Range data. """ order = pyblish.api.CollectorOrder + 0.491 - label = "Collect Anatomy Frame Range" + label = "Collect Frame Range from Asset Entity" families = ["plate", "pointcache", "vdbcache", "online", "render"] diff --git a/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json b/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json index 9e3a1b703e..4a54c6b4b4 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json @@ -351,7 +351,7 @@ "template_data": [ { "key": "CollectFrameRangeData", - "label": "Collect frame range data" + "label": "Collect frame range from asset entity" }, { "key": "ValidateFrameRange", From 1bce2eae7012c2153e93aad4da56b8211e75cfa7 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 21 Jun 2023 15:59:40 +0800 Subject: [PATCH 09/19] get the frameStart and frameEnd from the representation data --- .../publish/collect_frame_range_data.py | 42 +++++++++++++++++-- 1 file changed, 39 insertions(+), 3 deletions(-) diff --git a/openpype/plugins/publish/collect_frame_range_data.py b/openpype/plugins/publish/collect_frame_range_data.py index ff773d4c59..211870fa9d 100644 --- a/openpype/plugins/publish/collect_frame_range_data.py +++ b/openpype/plugins/publish/collect_frame_range_data.py @@ -1,4 +1,5 @@ import pyblish.api +import clique class CollectFrameRangeData(pyblish.api.InstancePlugin): @@ -11,15 +12,50 @@ class CollectFrameRangeData(pyblish.api.InstancePlugin): "vdbcache", "online", "render"] hosts = ["traypublisher"] + img_extensions = ["exr", "dpx", "jpg", "jpeg", "png", "tiff", "tga", + "gif", "svg"] + video_extensions = ["avi", "mov", "mp4"] def process(self, instance): + repres = instance.data.get("representations") + asset_data = None asset_doc = instance.data.get("assetEntity") if not asset_doc: self.log.debug("Instance has no asset entity set." - " Skipping collecting frame range data.") + " Skipping collecting frame range data.") return + if repres: + first_repre = repres[0] + ext = first_repre["ext"].replace(".", "") + if not ext or ext.lower() not in self.img_extensions: + self.log.warning(f"Cannot find file extension " + " in representation data") + return + if ext in self.video_extensions: + self.log.info("Collecting frame range data" + " not supported for video extensions") + return + + files = first_repre["files"] + repres_file = clique.assemble( + files, minimum_items=1)[0][0] + repres_frames = [frames for frames in repres_file.indexes] + last_frame = len(repres_frames) - 1 + entity_data = asset_doc["data"] + asset_data = { + "fps": entity_data["fps"], + "frameStart": repres_frames[0], + "frameEnd": repres_frames[last_frame], + "handleStart": entity_data["handleStart"], + "handleEnd": entity_data["handleEnd"] + } + + else: + self.log.info("No representation data.. " + "\nUse Asset Entity data instead") + + asset_data = asset_doc["data"] - asset_data = asset_doc["data"] key_sets = [] for key in ( "fps", @@ -32,5 +68,5 @@ class CollectFrameRangeData(pyblish.api.InstancePlugin): instance.data[key] = asset_data[key] key_sets.append(key) - self.log.debug(f"Anatomy frame range data {key_sets} " + self.log.debug(f"Frame range data {key_sets} " "has been collected from asset entity.") From 7971a9901d584450c91ac01c3d9b90224f59e523 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 21 Jun 2023 16:01:00 +0800 Subject: [PATCH 10/19] hound fix --- openpype/plugins/publish/collect_frame_range_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/plugins/publish/collect_frame_range_data.py b/openpype/plugins/publish/collect_frame_range_data.py index 211870fa9d..65198ba314 100644 --- a/openpype/plugins/publish/collect_frame_range_data.py +++ b/openpype/plugins/publish/collect_frame_range_data.py @@ -22,7 +22,7 @@ class CollectFrameRangeData(pyblish.api.InstancePlugin): asset_doc = instance.data.get("assetEntity") if not asset_doc: self.log.debug("Instance has no asset entity set." - " Skipping collecting frame range data.") + " Skipping collecting frame range data.") return if repres: first_repre = repres[0] From 6ddf12e79a48f30a96e2002142b942dcdcb24e80 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Mon, 26 Jun 2023 18:05:40 +0800 Subject: [PATCH 11/19] fabia's comment & add just frame range data from representation --- .../plugins/publish/collect_frame_range_data.py | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/openpype/plugins/publish/collect_frame_range_data.py b/openpype/plugins/publish/collect_frame_range_data.py index 65198ba314..90dfd3e0a8 100644 --- a/openpype/plugins/publish/collect_frame_range_data.py +++ b/openpype/plugins/publish/collect_frame_range_data.py @@ -7,7 +7,7 @@ class CollectFrameRangeData(pyblish.api.InstancePlugin): """ order = pyblish.api.CollectorOrder + 0.491 - label = "Collect Frame Range from Asset Entity" + label = "Collect Frame Range Data" families = ["plate", "pointcache", "vdbcache", "online", "render"] @@ -19,11 +19,6 @@ class CollectFrameRangeData(pyblish.api.InstancePlugin): def process(self, instance): repres = instance.data.get("representations") asset_data = None - asset_doc = instance.data.get("assetEntity") - if not asset_doc: - self.log.debug("Instance has no asset entity set." - " Skipping collecting frame range data.") - return if repres: first_repre = repres[0] ext = first_repre["ext"].replace(".", "") @@ -41,19 +36,19 @@ class CollectFrameRangeData(pyblish.api.InstancePlugin): files, minimum_items=1)[0][0] repres_frames = [frames for frames in repres_file.indexes] last_frame = len(repres_frames) - 1 - entity_data = asset_doc["data"] asset_data = { - "fps": entity_data["fps"], "frameStart": repres_frames[0], "frameEnd": repres_frames[last_frame], - "handleStart": entity_data["handleStart"], - "handleEnd": entity_data["handleEnd"] } else: self.log.info("No representation data.. " "\nUse Asset Entity data instead") - + asset_doc = instance.data.get("assetEntity") + if instance.data.get("frameStart") is not None or not asset_doc: + self.log.debug("Instance has no asset entity set." + " Skipping collecting frame range data.") + return asset_data = asset_doc["data"] key_sets = [] From ce37b597f2a24bb71660bd8a345ab6c1edf198b4 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Mon, 26 Jun 2023 18:06:22 +0800 Subject: [PATCH 12/19] hound fix --- openpype/plugins/publish/collect_frame_range_data.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/openpype/plugins/publish/collect_frame_range_data.py b/openpype/plugins/publish/collect_frame_range_data.py index 90dfd3e0a8..9129a7f0f5 100644 --- a/openpype/plugins/publish/collect_frame_range_data.py +++ b/openpype/plugins/publish/collect_frame_range_data.py @@ -45,7 +45,7 @@ class CollectFrameRangeData(pyblish.api.InstancePlugin): self.log.info("No representation data.. " "\nUse Asset Entity data instead") asset_doc = instance.data.get("assetEntity") - if instance.data.get("frameStart") is not None or not asset_doc: + if instance.data.get("frameStart") is not None or not asset_doc: self.log.debug("Instance has no asset entity set." " Skipping collecting frame range data.") return From ef812bff3dc7134eb1242516a23df70fc36f6d7e Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 5 Jul 2023 22:55:30 +0800 Subject: [PATCH 13/19] roy's comment --- openpype/pipeline/delivery.py | 4 +- .../publish/collect_frame_range_data.py | 58 ++++++++++++------- 2 files changed, 41 insertions(+), 21 deletions(-) diff --git a/openpype/pipeline/delivery.py b/openpype/pipeline/delivery.py index 500f54040a..53f3d45e14 100644 --- a/openpype/pipeline/delivery.py +++ b/openpype/pipeline/delivery.py @@ -157,6 +157,8 @@ def deliver_single_file( delivery_path = delivery_path.replace("..", ".") # Make sure path is valid for all platforms delivery_path = os.path.normpath(delivery_path.replace("\\", "/")) + # Remove newlines from the end of the string to avoid OSError during copy + delivery_path = delivery_path.rstrip() delivery_folder = os.path.dirname(delivery_path) if not os.path.exists(delivery_folder): @@ -305,4 +307,4 @@ def deliver_sequence( _copy_file(src, dst) uploaded += 1 - return report_items, uploaded + return report_items, uploaded \ No newline at end of file diff --git a/openpype/plugins/publish/collect_frame_range_data.py b/openpype/plugins/publish/collect_frame_range_data.py index 9129a7f0f5..ceea530676 100644 --- a/openpype/plugins/publish/collect_frame_range_data.py +++ b/openpype/plugins/publish/collect_frame_range_data.py @@ -1,8 +1,12 @@ import pyblish.api import clique +from openpype.pipeline import publish +from openpype.lib import BoolDef +from openpype.lib.transcoding import IMAGE_EXTENSIONS -class CollectFrameRangeData(pyblish.api.InstancePlugin): +class CollectFrameRangeData(pyblish.api.InstancePlugin, + publish.OpenPypePyblishPluginMixin): """Collect Frame Range data. """ @@ -12,44 +16,50 @@ class CollectFrameRangeData(pyblish.api.InstancePlugin): "vdbcache", "online", "render"] hosts = ["traypublisher"] - img_extensions = ["exr", "dpx", "jpg", "jpeg", "png", "tiff", "tga", - "gif", "svg"] - video_extensions = ["avi", "mov", "mp4"] def process(self, instance): repres = instance.data.get("representations") asset_data = None if repres: first_repre = repres[0] - ext = first_repre["ext"].replace(".", "") - if not ext or ext.lower() not in self.img_extensions: - self.log.warning(f"Cannot find file extension " + ext = ".{}".format(first_repre["ext"]) + if "ext" not in first_repre: + self.log.warning(f"Cannot find file extension" " in representation data") return - if ext in self.video_extensions: + if ext not in IMAGE_EXTENSIONS: self.log.info("Collecting frame range data" - " not supported for video extensions") + " only supported for image extensions") return files = first_repre["files"] - repres_file = clique.assemble( - files, minimum_items=1)[0][0] - repres_frames = [frames for frames in repres_file.indexes] - last_frame = len(repres_frames) - 1 + repres_files, remainder = clique.assemble(files) + repres_frames = list() + for repres_file in repres_files: + repres_frames = list(repres_file.indexes) asset_data = { "frameStart": repres_frames[0], - "frameEnd": repres_frames[last_frame], + "frameEnd": repres_frames[-1], } else: - self.log.info("No representation data.. " - "\nUse Asset Entity data instead") + self.log.info( + "No representation data.. Use Asset Entity data instead") asset_doc = instance.data.get("assetEntity") - if instance.data.get("frameStart") is not None or not asset_doc: - self.log.debug("Instance has no asset entity set." - " Skipping collecting frame range data.") + + attr_values = self.get_attr_values_from_data(instance.data) + if attr_values.get("setAssetFrameRange", True): + if instance.data.get("frameStart") is not None or not asset_doc: + self.log.debug("Instance has no asset entity set." + " Skipping collecting frame range data.") + return + self.log.debug( + "Falling back to collect frame range" + " data from asset entity set.") + asset_data = asset_doc["data"] + else: + self.log.debug("Skipping collecting frame range data.") return - asset_data = asset_doc["data"] key_sets = [] for key in ( @@ -65,3 +75,11 @@ class CollectFrameRangeData(pyblish.api.InstancePlugin): self.log.debug(f"Frame range data {key_sets} " "has been collected from asset entity.") + + @classmethod + def get_attribute_defs(cls): + return [ + BoolDef("setAssetFrameRange", + label="Set Asset Frame Range", + default=False), + ] From fed1d096e81a84f8e32656f3af7f0ce98ce6b433 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 5 Jul 2023 22:59:19 +0800 Subject: [PATCH 14/19] hound fix --- openpype/plugins/publish/collect_frame_range_data.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/openpype/plugins/publish/collect_frame_range_data.py b/openpype/plugins/publish/collect_frame_range_data.py index ceea530676..efa240e503 100644 --- a/openpype/plugins/publish/collect_frame_range_data.py +++ b/openpype/plugins/publish/collect_frame_range_data.py @@ -49,9 +49,9 @@ class CollectFrameRangeData(pyblish.api.InstancePlugin, attr_values = self.get_attr_values_from_data(instance.data) if attr_values.get("setAssetFrameRange", True): - if instance.data.get("frameStart") is not None or not asset_doc: + if instance.data.get("frameStart") is not None or not asset_doc: # noqa self.log.debug("Instance has no asset entity set." - " Skipping collecting frame range data.") + " Skipping collecting frame range data.") return self.log.debug( "Falling back to collect frame range" From 32eb96c2c6e103f58a577ce10ef6ae373245aec6 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Wed, 5 Jul 2023 23:01:48 +0800 Subject: [PATCH 15/19] restore the unrelated code --- openpype/pipeline/delivery.py | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/openpype/pipeline/delivery.py b/openpype/pipeline/delivery.py index 53f3d45e14..500f54040a 100644 --- a/openpype/pipeline/delivery.py +++ b/openpype/pipeline/delivery.py @@ -157,8 +157,6 @@ def deliver_single_file( delivery_path = delivery_path.replace("..", ".") # Make sure path is valid for all platforms delivery_path = os.path.normpath(delivery_path.replace("\\", "/")) - # Remove newlines from the end of the string to avoid OSError during copy - delivery_path = delivery_path.rstrip() delivery_folder = os.path.dirname(delivery_path) if not os.path.exists(delivery_folder): @@ -307,4 +305,4 @@ def deliver_sequence( _copy_file(src, dst) uploaded += 1 - return report_items, uploaded \ No newline at end of file + return report_items, uploaded From 5b735c70f5400ad034b2bf9bcf686175ef3881af Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 6 Jul 2023 12:48:06 +0800 Subject: [PATCH 16/19] roy's comment --- .../publish/collect_frame_range_data.py | 26 +++++++++---------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/openpype/plugins/publish/collect_frame_range_data.py b/openpype/plugins/publish/collect_frame_range_data.py index efa240e503..c25aacd7f3 100644 --- a/openpype/plugins/publish/collect_frame_range_data.py +++ b/openpype/plugins/publish/collect_frame_range_data.py @@ -2,7 +2,6 @@ import pyblish.api import clique from openpype.pipeline import publish from openpype.lib import BoolDef -from openpype.lib.transcoding import IMAGE_EXTENSIONS class CollectFrameRangeData(pyblish.api.InstancePlugin, @@ -22,21 +21,22 @@ class CollectFrameRangeData(pyblish.api.InstancePlugin, asset_data = None if repres: first_repre = repres[0] - ext = ".{}".format(first_repre["ext"]) if "ext" not in first_repre: - self.log.warning(f"Cannot find file extension" + self.log.warning("Cannot find file extension" " in representation data") return - if ext not in IMAGE_EXTENSIONS: - self.log.info("Collecting frame range data" - " only supported for image extensions") - return files = first_repre["files"] - repres_files, remainder = clique.assemble(files) - repres_frames = list() - for repres_file in repres_files: - repres_frames = list(repres_file.indexes) + collections, remainder = clique.assemble(files) + if not collections: + # No sequences detected and we can't retrieve + # frame range + self.log.debug( + "No sequences detected in the representation data." + " Skipping collecting frame range data.") + return + collection = collections[0] + repres_frames = list(collection.indexes) asset_data = { "frameStart": repres_frames[0], "frameEnd": repres_frames[-1], @@ -44,7 +44,7 @@ class CollectFrameRangeData(pyblish.api.InstancePlugin, else: self.log.info( - "No representation data.. Use Asset Entity data instead") + "No representation data. Using Asset Entity data instead") asset_doc = instance.data.get("assetEntity") attr_values = self.get_attr_values_from_data(instance.data) @@ -55,7 +55,7 @@ class CollectFrameRangeData(pyblish.api.InstancePlugin, return self.log.debug( "Falling back to collect frame range" - " data from asset entity set.") + " data from set asset entity.") asset_data = asset_doc["data"] else: self.log.debug("Skipping collecting frame range data.") From 803236c9c59d5ce660bb1e8fcd6e883055fe49be Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 6 Jul 2023 17:52:58 +0800 Subject: [PATCH 17/19] adding frame collector and optional frame data from asset entity collector --- .../collect_frame_range_asset_entity.py | 39 +++++++++ .../publish/collect_frame_range_data.py | 85 ------------------- .../publish/collect_sequence_frame_data.py | 48 +++++++++++ .../project_settings/traypublisher.json | 2 +- .../schema_project_traypublisher.json | 2 +- 5 files changed, 89 insertions(+), 87 deletions(-) create mode 100644 openpype/plugins/publish/collect_frame_range_asset_entity.py delete mode 100644 openpype/plugins/publish/collect_frame_range_data.py create mode 100644 openpype/plugins/publish/collect_sequence_frame_data.py diff --git a/openpype/plugins/publish/collect_frame_range_asset_entity.py b/openpype/plugins/publish/collect_frame_range_asset_entity.py new file mode 100644 index 0000000000..2f7570466c --- /dev/null +++ b/openpype/plugins/publish/collect_frame_range_asset_entity.py @@ -0,0 +1,39 @@ +import pyblish.api +from openpype.pipeline import OptionalPyblishPluginMixin + + +class CollectFrameDataFromAssetEntity(pyblish.api.InstancePlugin, + OptionalPyblishPluginMixin): + """Collect Frame Range data From Asset Entity + """ + + order = pyblish.api.CollectorOrder + 0.3 + label = "Collect Frame Data From Asset Entity" + families = ["plate", "pointcache", + "vdbcache", "online", + "render"] + hosts = ["traypublisher"] + optional = True + + def process(self, instance): + if not self.is_active(instance.data): + return + missing_keys = [] + for key in ( + "fps", + "frameStart", + "frameEnd", + "handleStart", + "handleEnd" + ): + if key not in instance.data: + missing_keys.append(key) + key_sets = [] + for key in missing_keys: + asset_data = instance.data["assetEntity"]["data"] + if key in asset_data: + instance.data[key] = asset_data[key] + key_sets.append(key) + if key_sets: + self.log.debug(f"Frame range data {key_sets} " + "has been collected from asset entity.") diff --git a/openpype/plugins/publish/collect_frame_range_data.py b/openpype/plugins/publish/collect_frame_range_data.py deleted file mode 100644 index c25aacd7f3..0000000000 --- a/openpype/plugins/publish/collect_frame_range_data.py +++ /dev/null @@ -1,85 +0,0 @@ -import pyblish.api -import clique -from openpype.pipeline import publish -from openpype.lib import BoolDef - - -class CollectFrameRangeData(pyblish.api.InstancePlugin, - publish.OpenPypePyblishPluginMixin): - """Collect Frame Range data. - """ - - order = pyblish.api.CollectorOrder + 0.491 - label = "Collect Frame Range Data" - families = ["plate", "pointcache", - "vdbcache", "online", - "render"] - hosts = ["traypublisher"] - - def process(self, instance): - repres = instance.data.get("representations") - asset_data = None - if repres: - first_repre = repres[0] - if "ext" not in first_repre: - self.log.warning("Cannot find file extension" - " in representation data") - return - - files = first_repre["files"] - collections, remainder = clique.assemble(files) - if not collections: - # No sequences detected and we can't retrieve - # frame range - self.log.debug( - "No sequences detected in the representation data." - " Skipping collecting frame range data.") - return - collection = collections[0] - repres_frames = list(collection.indexes) - asset_data = { - "frameStart": repres_frames[0], - "frameEnd": repres_frames[-1], - } - - else: - self.log.info( - "No representation data. Using Asset Entity data instead") - asset_doc = instance.data.get("assetEntity") - - attr_values = self.get_attr_values_from_data(instance.data) - if attr_values.get("setAssetFrameRange", True): - if instance.data.get("frameStart") is not None or not asset_doc: # noqa - self.log.debug("Instance has no asset entity set." - " Skipping collecting frame range data.") - return - self.log.debug( - "Falling back to collect frame range" - " data from set asset entity.") - asset_data = asset_doc["data"] - else: - self.log.debug("Skipping collecting frame range data.") - return - - key_sets = [] - for key in ( - "fps", - "frameStart", - "frameEnd", - "handleStart", - "handleEnd" - ): - if key not in instance.data and key in asset_data: - instance.data[key] = asset_data[key] - key_sets.append(key) - - self.log.debug(f"Frame range data {key_sets} " - "has been collected from asset entity.") - - @classmethod - def get_attribute_defs(cls): - return [ - BoolDef("setAssetFrameRange", - label="Set Asset Frame Range", - default=False), - ] diff --git a/openpype/plugins/publish/collect_sequence_frame_data.py b/openpype/plugins/publish/collect_sequence_frame_data.py new file mode 100644 index 0000000000..5b5c427d9e --- /dev/null +++ b/openpype/plugins/publish/collect_sequence_frame_data.py @@ -0,0 +1,48 @@ +import pyblish.api +import clique + + +class CollectSequenceFrameData(pyblish.api.InstancePlugin): + """Collect Sequence Frame Data + """ + + order = pyblish.api.CollectorOrder + 0.2 + label = "Collect Sequence Frame Data" + families = ["plate", "pointcache", + "vdbcache", "online", + "render"] + hosts = ["traypublisher"] + + def process(self, instance): + frame_data = self.get_frame_data_from_repre_sequence(instance) + for key, value in frame_data.items(): + if key not in instance.data : + instance.data[key] = value + self.log.debug(f"Frame range data {key} has been collected ") + + + def get_frame_data_from_repre_sequence(self, instance): + repres = instance.data.get("representations") + if repres: + first_repre = repres[0] + if "ext" not in first_repre: + self.log.warning("Cannot find file extension" + " in representation data") + return + + files = first_repre["files"] + collections, remainder = clique.assemble(files) + if not collections: + # No sequences detected and we can't retrieve + # frame range + self.log.debug( + "No sequences detected in the representation data." + " Skipping collecting frame range data.") + return + collection = collections[0] + repres_frames = list(collection.indexes) + + return { + "frameStart": repres_frames[0], + "frameEnd": repres_frames[-1], + } diff --git a/openpype/settings/defaults/project_settings/traypublisher.json b/openpype/settings/defaults/project_settings/traypublisher.json index b7a01e584b..dda958ebcd 100644 --- a/openpype/settings/defaults/project_settings/traypublisher.json +++ b/openpype/settings/defaults/project_settings/traypublisher.json @@ -329,7 +329,7 @@ } }, "publish": { - "CollectFrameRangeData": { + "CollectFrameDataFromAssetEntity": { "enabled": true, "optional": true, "active": true diff --git a/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json b/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json index 4a54c6b4b4..184fc657be 100644 --- a/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json +++ b/openpype/settings/entities/schemas/projects_schema/schema_project_traypublisher.json @@ -350,7 +350,7 @@ "name": "template_validate_plugin", "template_data": [ { - "key": "CollectFrameRangeData", + "key": "CollectFrameDataFromAssetEntity", "label": "Collect frame range from asset entity" }, { From e9c9be0b57750f1fd81c8e70938bf4f6319b2e92 Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 6 Jul 2023 17:54:18 +0800 Subject: [PATCH 18/19] hound shut --- openpype/plugins/publish/collect_frame_range_asset_entity.py | 2 +- openpype/plugins/publish/collect_sequence_frame_data.py | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/openpype/plugins/publish/collect_frame_range_asset_entity.py b/openpype/plugins/publish/collect_frame_range_asset_entity.py index 2f7570466c..67e7444173 100644 --- a/openpype/plugins/publish/collect_frame_range_asset_entity.py +++ b/openpype/plugins/publish/collect_frame_range_asset_entity.py @@ -3,7 +3,7 @@ from openpype.pipeline import OptionalPyblishPluginMixin class CollectFrameDataFromAssetEntity(pyblish.api.InstancePlugin, - OptionalPyblishPluginMixin): + OptionalPyblishPluginMixin): """Collect Frame Range data From Asset Entity """ diff --git a/openpype/plugins/publish/collect_sequence_frame_data.py b/openpype/plugins/publish/collect_sequence_frame_data.py index 5b5c427d9e..0b6c69bd5f 100644 --- a/openpype/plugins/publish/collect_sequence_frame_data.py +++ b/openpype/plugins/publish/collect_sequence_frame_data.py @@ -16,11 +16,10 @@ class CollectSequenceFrameData(pyblish.api.InstancePlugin): def process(self, instance): frame_data = self.get_frame_data_from_repre_sequence(instance) for key, value in frame_data.items(): - if key not in instance.data : + if key not in instance.data: instance.data[key] = value self.log.debug(f"Frame range data {key} has been collected ") - def get_frame_data_from_repre_sequence(self, instance): repres = instance.data.get("representations") if repres: From 00070efac77ec8fe92057f23961397c025a9351e Mon Sep 17 00:00:00 2001 From: Kayla Man Date: Thu, 6 Jul 2023 18:41:38 +0800 Subject: [PATCH 19/19] docstrings update and roy's comment --- .../publish/collect_frame_range_asset_entity.py | 11 +++++++---- .../plugins/publish/collect_sequence_frame_data.py | 8 +++++++- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/openpype/plugins/publish/collect_frame_range_asset_entity.py b/openpype/plugins/publish/collect_frame_range_asset_entity.py index 67e7444173..ce744e2daf 100644 --- a/openpype/plugins/publish/collect_frame_range_asset_entity.py +++ b/openpype/plugins/publish/collect_frame_range_asset_entity.py @@ -5,6 +5,9 @@ from openpype.pipeline import OptionalPyblishPluginMixin class CollectFrameDataFromAssetEntity(pyblish.api.InstancePlugin, OptionalPyblishPluginMixin): """Collect Frame Range data From Asset Entity + + Frame range data will only be collected if the keys + are not yet collected for the instance. """ order = pyblish.api.CollectorOrder + 0.3 @@ -28,12 +31,12 @@ class CollectFrameDataFromAssetEntity(pyblish.api.InstancePlugin, ): if key not in instance.data: missing_keys.append(key) - key_sets = [] + keys_set = [] for key in missing_keys: asset_data = instance.data["assetEntity"]["data"] if key in asset_data: instance.data[key] = asset_data[key] - key_sets.append(key) - if key_sets: - self.log.debug(f"Frame range data {key_sets} " + keys_set.append(key) + if keys_set: + self.log.debug(f"Frame range data {keys_set} " "has been collected from asset entity.") diff --git a/openpype/plugins/publish/collect_sequence_frame_data.py b/openpype/plugins/publish/collect_sequence_frame_data.py index 0b6c69bd5f..c200b245e9 100644 --- a/openpype/plugins/publish/collect_sequence_frame_data.py +++ b/openpype/plugins/publish/collect_sequence_frame_data.py @@ -4,6 +4,9 @@ import clique class CollectSequenceFrameData(pyblish.api.InstancePlugin): """Collect Sequence Frame Data + If the representation includes files with frame numbers, + then set `frameStart` and `frameEnd` for the instance to the + start and end frame respectively """ order = pyblish.api.CollectorOrder + 0.2 @@ -15,10 +18,13 @@ class CollectSequenceFrameData(pyblish.api.InstancePlugin): def process(self, instance): frame_data = self.get_frame_data_from_repre_sequence(instance) + if not frame_data: + # if no dict data skip collecting the frame range data + return for key, value in frame_data.items(): if key not in instance.data: instance.data[key] = value - self.log.debug(f"Frame range data {key} has been collected ") + self.log.debug(f"Collected Frame range data '{key}':{value} ") def get_frame_data_from_repre_sequence(self, instance): repres = instance.data.get("representations")