From 863c6f51871f089acfba690ee58ac4af95a14a21 Mon Sep 17 00:00:00 2001 From: "robin@ynput.io" Date: Tue, 12 Nov 2024 16:04:25 -0500 Subject: [PATCH 1/8] Allow CSV ingest to create new shots. --- .../plugins/publish/collect_hierarchy.py | 18 +++++++++++------- .../publish/extract_hierarchy_to_ayon.py | 2 +- 2 files changed, 12 insertions(+), 8 deletions(-) diff --git a/client/ayon_core/plugins/publish/collect_hierarchy.py b/client/ayon_core/plugins/publish/collect_hierarchy.py index 2ae3cc67f3..e4b4dd408f 100644 --- a/client/ayon_core/plugins/publish/collect_hierarchy.py +++ b/client/ayon_core/plugins/publish/collect_hierarchy.py @@ -13,8 +13,8 @@ class CollectHierarchy(pyblish.api.ContextPlugin): label = "Collect Hierarchy" order = pyblish.api.CollectorOrder - 0.076 - families = ["shot"] - hosts = ["resolve", "hiero", "flame"] + families = ["shot", "csv_ingest_shot"] + hosts = ["resolve", "hiero", "flame", "traypublisher"] def process(self, context): project_name = context.data["projectName"] @@ -38,8 +38,9 @@ def process(self, context): ): continue - # exclude if not masterLayer True - if not instance.data.get("heroTrack"): + # exclude if not CSV ingest shot and not masterLayer True + if ("csv_ingest_shot" not in families and + not instance.data.get("heroTrack")): continue shot_data = { @@ -49,7 +50,10 @@ def process(self, context): "folder_type": "Shot", "tasks": instance.data.get("tasks") or {}, "comments": instance.data.get("comments", []), - "attributes": { + } + + if "csv_ingest_shot" not in families: + shot_data["attributes"] = { "handleStart": instance.data["handleStart"], "handleEnd": instance.data["handleEnd"], "frameStart": instance.data["frameStart"], @@ -60,8 +64,8 @@ def process(self, context): "resolutionWidth": instance.data["resolutionWidth"], "resolutionHeight": instance.data["resolutionHeight"], "pixelAspect": instance.data["pixelAspect"], - }, - } + } + # Split by '/' for AYON where asset is a path name = instance.data["folderPath"].split("/")[-1] actual = {name: shot_data} diff --git a/client/ayon_core/plugins/publish/extract_hierarchy_to_ayon.py b/client/ayon_core/plugins/publish/extract_hierarchy_to_ayon.py index a169affc66..390ce36126 100644 --- a/client/ayon_core/plugins/publish/extract_hierarchy_to_ayon.py +++ b/client/ayon_core/plugins/publish/extract_hierarchy_to_ayon.py @@ -22,7 +22,7 @@ class ExtractHierarchyToAYON(pyblish.api.ContextPlugin): order = pyblish.api.ExtractorOrder - 0.01 label = "Extract Hierarchy To AYON" - families = ["clip", "shot"] + families = ["clip", "shot", "csv_ingest_shot"] def process(self, context): if not context.data.get("hierarchyContext"): From f6547264fbcbd293036a4e23059e2774114c441c Mon Sep 17 00:00:00 2001 From: "robin@ynput.io" Date: Tue, 12 Nov 2024 16:30:55 -0500 Subject: [PATCH 2/8] Fix lint. --- client/ayon_core/plugins/publish/collect_hierarchy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/plugins/publish/collect_hierarchy.py b/client/ayon_core/plugins/publish/collect_hierarchy.py index e4b4dd408f..3340430345 100644 --- a/client/ayon_core/plugins/publish/collect_hierarchy.py +++ b/client/ayon_core/plugins/publish/collect_hierarchy.py @@ -64,7 +64,7 @@ def process(self, context): "resolutionWidth": instance.data["resolutionWidth"], "resolutionHeight": instance.data["resolutionHeight"], "pixelAspect": instance.data["pixelAspect"], - } + } # Split by '/' for AYON where asset is a path name = instance.data["folderPath"].split("/")[-1] From d2229fbb156bd9f74fc31b0a1c30d1b648f6d727 Mon Sep 17 00:00:00 2001 From: Robin De Lillo Date: Mon, 18 Nov 2024 08:16:02 -0500 Subject: [PATCH 3/8] Apply suggestions from code review Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/plugins/publish/collect_hierarchy.py | 11 +++++++---- .../plugins/publish/extract_hierarchy_to_ayon.py | 1 - 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/client/ayon_core/plugins/publish/collect_hierarchy.py b/client/ayon_core/plugins/publish/collect_hierarchy.py index 3340430345..531b6a1d76 100644 --- a/client/ayon_core/plugins/publish/collect_hierarchy.py +++ b/client/ayon_core/plugins/publish/collect_hierarchy.py @@ -13,7 +13,6 @@ class CollectHierarchy(pyblish.api.ContextPlugin): label = "Collect Hierarchy" order = pyblish.api.CollectorOrder - 0.076 - families = ["shot", "csv_ingest_shot"] hosts = ["resolve", "hiero", "flame", "traypublisher"] def process(self, context): @@ -38,9 +37,12 @@ def process(self, context): ): continue - # exclude if not CSV ingest shot and not masterLayer True - if ("csv_ingest_shot" not in families and - not instance.data.get("heroTrack")): + # Skip if is not a hero track + # - skip check for traypubliser CSV ingest + if ( + not instance.data.get("heroTrack") + and "csv_ingest_shot" not in families + ): continue shot_data = { @@ -52,6 +54,7 @@ def process(self, context): "comments": instance.data.get("comments", []), } + # TODO Fill in reason why we don't set attributes for csv_ingest_shot if "csv_ingest_shot" not in families: shot_data["attributes"] = { "handleStart": instance.data["handleStart"], diff --git a/client/ayon_core/plugins/publish/extract_hierarchy_to_ayon.py b/client/ayon_core/plugins/publish/extract_hierarchy_to_ayon.py index 390ce36126..25467fd94f 100644 --- a/client/ayon_core/plugins/publish/extract_hierarchy_to_ayon.py +++ b/client/ayon_core/plugins/publish/extract_hierarchy_to_ayon.py @@ -22,7 +22,6 @@ class ExtractHierarchyToAYON(pyblish.api.ContextPlugin): order = pyblish.api.ExtractorOrder - 0.01 label = "Extract Hierarchy To AYON" - families = ["clip", "shot", "csv_ingest_shot"] def process(self, context): if not context.data.get("hierarchyContext"): From 4a4377b489c643f6a4a60edebfcf7b9c59c4079b Mon Sep 17 00:00:00 2001 From: "robin@ynput.io" Date: Mon, 18 Nov 2024 13:38:21 -0500 Subject: [PATCH 4/8] Rework to avoid csv_ingest_shot family. --- .../plugins/publish/collect_hierarchy.py | 51 ++++++++++--------- .../publish/collect_otio_frame_ranges.py | 4 ++ 2 files changed, 32 insertions(+), 23 deletions(-) diff --git a/client/ayon_core/plugins/publish/collect_hierarchy.py b/client/ayon_core/plugins/publish/collect_hierarchy.py index 531b6a1d76..5e3be3d86d 100644 --- a/client/ayon_core/plugins/publish/collect_hierarchy.py +++ b/client/ayon_core/plugins/publish/collect_hierarchy.py @@ -31,18 +31,14 @@ def process(self, context): product_type = instance.data["productType"] families = instance.data["families"] - # exclude other families then self.families with intersection - if not set(self.families).intersection( - set(families + [product_type]) - ): + # exclude other families then "shot" with intersection + if "shot" not in (families + [product_type]): + self.log.debug("Skipping not a shot: {}".format(families)) continue # Skip if is not a hero track - # - skip check for traypubliser CSV ingest - if ( - not instance.data.get("heroTrack") - and "csv_ingest_shot" not in families - ): + if not instance.data.get("heroTrack"): + self.log.debug("Skipping not a shot from hero track") continue shot_data = { @@ -54,20 +50,29 @@ def process(self, context): "comments": instance.data.get("comments", []), } - # TODO Fill in reason why we don't set attributes for csv_ingest_shot - if "csv_ingest_shot" not in families: - shot_data["attributes"] = { - "handleStart": instance.data["handleStart"], - "handleEnd": instance.data["handleEnd"], - "frameStart": instance.data["frameStart"], - "frameEnd": instance.data["frameEnd"], - "clipIn": instance.data["clipIn"], - "clipOut": instance.data["clipOut"], - "fps": instance.data["fps"], - "resolutionWidth": instance.data["resolutionWidth"], - "resolutionHeight": instance.data["resolutionHeight"], - "pixelAspect": instance.data["pixelAspect"], - } + shot_data["attributes"] = {} + SHOT_ATTRS = ( + "handleStart", + "handleEnd", + "frameStart", + "frameEnd", + "clipIn", + "clipOut", + "fps", + "resolutionWidth", + "resolutionHeight", + "pixelAspect", + ) + for shot_attr in SHOT_ATTRS: + if shot_attr not in instance.data: + # Shot attribute might not be defined (e.g. CSV ingest) + self.log.debug( + "%s shot attribute is not defined for instance.", + shot_attr + ) + continue + + shot_data["attributes"][shot_attr] = instance.data[shot_attr] # Split by '/' for AYON where asset is a path name = instance.data["folderPath"].split("/")[-1] diff --git a/client/ayon_core/plugins/publish/collect_otio_frame_ranges.py b/client/ayon_core/plugins/publish/collect_otio_frame_ranges.py index d1c8d03212..62b4cefec6 100644 --- a/client/ayon_core/plugins/publish/collect_otio_frame_ranges.py +++ b/client/ayon_core/plugins/publish/collect_otio_frame_ranges.py @@ -29,6 +29,10 @@ def process(self, instance): otio_range_with_handles ) + if not instance.data.get("otioClip"): + self.log.debug("Skipping collect OTIO frame range.") + return + # get basic variables otio_clip = instance.data["otioClip"] workfile_start = instance.data["workfileFrameStart"] From ff56393da87def3555cbebacb9d6907e27c2f523 Mon Sep 17 00:00:00 2001 From: "robin@ynput.io" Date: Mon, 18 Nov 2024 13:40:09 -0500 Subject: [PATCH 5/8] Fix linting. --- client/ayon_core/plugins/publish/collect_hierarchy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/plugins/publish/collect_hierarchy.py b/client/ayon_core/plugins/publish/collect_hierarchy.py index 5e3be3d86d..4c606fdc10 100644 --- a/client/ayon_core/plugins/publish/collect_hierarchy.py +++ b/client/ayon_core/plugins/publish/collect_hierarchy.py @@ -61,7 +61,7 @@ def process(self, context): "fps", "resolutionWidth", "resolutionHeight", - "pixelAspect", + "pixelAspect", ) for shot_attr in SHOT_ATTRS: if shot_attr not in instance.data: From 83cc964ca041a95d6af426c39ec7b92ee7706bc5 Mon Sep 17 00:00:00 2001 From: Robin De Lillo Date: Tue, 19 Nov 2024 08:07:52 -0500 Subject: [PATCH 6/8] Apply suggestions from code review Co-authored-by: Jakub Trllo <43494761+iLLiCiTiT@users.noreply.github.com> --- client/ayon_core/plugins/publish/collect_hierarchy.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/client/ayon_core/plugins/publish/collect_hierarchy.py b/client/ayon_core/plugins/publish/collect_hierarchy.py index 4c606fdc10..39501a9ed5 100644 --- a/client/ayon_core/plugins/publish/collect_hierarchy.py +++ b/client/ayon_core/plugins/publish/collect_hierarchy.py @@ -64,7 +64,8 @@ def process(self, context): "pixelAspect", ) for shot_attr in SHOT_ATTRS: - if shot_attr not in instance.data: + attr_value = instance.data.get(shot_attr) + if attr_value is None: # Shot attribute might not be defined (e.g. CSV ingest) self.log.debug( "%s shot attribute is not defined for instance.", @@ -72,7 +73,7 @@ def process(self, context): ) continue - shot_data["attributes"][shot_attr] = instance.data[shot_attr] + shot_data["attributes"][shot_attr] = attr_value # Split by '/' for AYON where asset is a path name = instance.data["folderPath"].split("/")[-1] From 70a38a6b1a3025ad653c2338dccfb30bdc9e0249 Mon Sep 17 00:00:00 2001 From: "robin@ynput.io" Date: Tue, 19 Nov 2024 08:22:13 -0500 Subject: [PATCH 7/8] Fix linting. --- client/ayon_core/plugins/publish/collect_hierarchy.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_core/plugins/publish/collect_hierarchy.py b/client/ayon_core/plugins/publish/collect_hierarchy.py index 39501a9ed5..cae89bd6bf 100644 --- a/client/ayon_core/plugins/publish/collect_hierarchy.py +++ b/client/ayon_core/plugins/publish/collect_hierarchy.py @@ -65,7 +65,7 @@ def process(self, context): ) for shot_attr in SHOT_ATTRS: attr_value = instance.data.get(shot_attr) - if attr_value is None: + if attr_value is None: # Shot attribute might not be defined (e.g. CSV ingest) self.log.debug( "%s shot attribute is not defined for instance.", From 26e5c2f52b05fd09c681305ffc151a3863aafbc5 Mon Sep 17 00:00:00 2001 From: "robin@ynput.io" Date: Tue, 19 Nov 2024 09:28:16 -0500 Subject: [PATCH 8/8] Adjust folder type creation in collect_hierarchy. --- client/ayon_core/plugins/publish/collect_hierarchy.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/client/ayon_core/plugins/publish/collect_hierarchy.py b/client/ayon_core/plugins/publish/collect_hierarchy.py index cae89bd6bf..00f5c06c0b 100644 --- a/client/ayon_core/plugins/publish/collect_hierarchy.py +++ b/client/ayon_core/plugins/publish/collect_hierarchy.py @@ -43,9 +43,8 @@ def process(self, context): shot_data = { "entity_type": "folder", - # WARNING Default folder type is hardcoded - # suppose that all instances are Shots - "folder_type": "Shot", + # WARNING unless overwritten, default folder type is hardcoded to shot + "folder_type": instance.data.get("folder_type") or "Shot", "tasks": instance.data.get("tasks") or {}, "comments": instance.data.get("comments", []), }