From 43e573313019a59f486767504ecfcc1823577325 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Thu, 8 Aug 2024 19:02:04 +0200 Subject: [PATCH 1/8] :art: add render layer name collector --- .../plugins/publish/collect_renderlayer.py | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 client/ayon_houdini/plugins/publish/collect_renderlayer.py diff --git a/client/ayon_houdini/plugins/publish/collect_renderlayer.py b/client/ayon_houdini/plugins/publish/collect_renderlayer.py new file mode 100644 index 0000000000..b628fc7340 --- /dev/null +++ b/client/ayon_houdini/plugins/publish/collect_renderlayer.py @@ -0,0 +1,27 @@ +"""Collect Render layer name from ROP. + +This simple collector will take name of the ROP node and set it as the render +layer name for the instance. + +This aligns with the behavior of Maya and possibly others, even though there +is nothing like render layer explicitly in Houdini. + +""" +import hou +import pyblish.api +from ayon_houdini.api import plugin + + +class CollectRendelayerFromROP(plugin.HoudiniInstancePlugin): + label = "Collect Render layer name from ROP" + order = pyblish.api.CollectorOrder + families = ["mantra_rop", + "karma_rop", + "redshift_rop", + "arnold_rop", + "vray_rop", + "usdrender"] + + def process(self, instance): + rop = hou.node(instance.data.get("instance_node")) + instance.data["renderlayer"] = rop.name() From 2de898ae71945a0d7a47b99ff70baa68e05b2c1e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Thu, 8 Aug 2024 19:02:33 +0200 Subject: [PATCH 2/8] :recycle: use function from library to get group and product names --- .../publish/collect_local_render_instances.py | 32 +++++++++++-------- 1 file changed, 18 insertions(+), 14 deletions(-) diff --git a/client/ayon_houdini/plugins/publish/collect_local_render_instances.py b/client/ayon_houdini/plugins/publish/collect_local_render_instances.py index 931a79535b..19ad4417be 100644 --- a/client/ayon_houdini/plugins/publish/collect_local_render_instances.py +++ b/client/ayon_houdini/plugins/publish/collect_local_render_instances.py @@ -1,10 +1,14 @@ import os + import pyblish.api from ayon_core.pipeline.create import get_product_name from ayon_core.pipeline.farm.patterning import match_aov_pattern +from ayon_core.pipeline.farm.pyblish_functions import ( + get_product_name_and_group_from_template +) from ayon_core.pipeline.publish import ( + apply_plugin_settings_automatically, get_plugin_settings, - apply_plugin_settings_automatically ) from ayon_houdini.api import plugin @@ -62,23 +66,23 @@ def process(self, instance): # Create Instance for each AOV. context = instance.context - expectedFiles = next(iter(instance.data["expectedFiles"]), {}) + expected_files = next(iter(instance.data["expectedFiles"]), {}) product_type = "render" # is always render - product_group = get_product_name( - context.data["projectName"], - context.data["taskEntity"]["name"], - context.data["taskEntity"]["taskType"], - context.data["hostName"], - product_type, - instance.data["productName"] - ) - - for aov_name, aov_filepaths in expectedFiles.items(): - product_name = product_group + for aov_name, aov_filepaths in expected_files.items(): + dynamic_data = {} if aov_name: - product_name = "{}_{}".format(product_name, aov_name) + dynamic_data["aov"] = aov_name + + product_name, product_group = get_product_name_and_group_from_template( + project_name=context.data["projectName"], + task_entity=context.data["taskEntity"], + host_name=context.data["hostName"], + product_type=product_type, + variant=instance.data["productName"], + dynamic_data = dynamic_data, + ) # Create instance for each AOV aov_instance = context.create_instance(product_name) From 3c587b8eb9491b96a312ee5e58b0743058a2de04 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Thu, 8 Aug 2024 19:04:15 +0200 Subject: [PATCH 3/8] :arrow_up: increase ayon-core dependency --- package.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.py b/package.py index ef979eb493..2c7bdfe60f 100644 --- a/package.py +++ b/package.py @@ -5,6 +5,6 @@ client_dir = "ayon_houdini" ayon_required_addons = { - "core": ">0.4.1", + "core": ">=0.4.4", } ayon_compatible_addons = {} From 86c9c6743523bdebdf732a81e3de307fb74bd1b6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Thu, 8 Aug 2024 19:17:59 +0200 Subject: [PATCH 4/8] :recycle: remove unused import --- .../plugins/publish/collect_local_render_instances.py | 1 - 1 file changed, 1 deletion(-) diff --git a/client/ayon_houdini/plugins/publish/collect_local_render_instances.py b/client/ayon_houdini/plugins/publish/collect_local_render_instances.py index 19ad4417be..658e6928ca 100644 --- a/client/ayon_houdini/plugins/publish/collect_local_render_instances.py +++ b/client/ayon_houdini/plugins/publish/collect_local_render_instances.py @@ -1,7 +1,6 @@ import os import pyblish.api -from ayon_core.pipeline.create import get_product_name from ayon_core.pipeline.farm.patterning import match_aov_pattern from ayon_core.pipeline.farm.pyblish_functions import ( get_product_name_and_group_from_template From 0d39c38443815c0086794d06889a28996bb1caea Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Fri, 9 Aug 2024 13:27:59 +0200 Subject: [PATCH 5/8] :recycle: change plugin order --- client/ayon_houdini/plugins/publish/collect_renderlayer.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_houdini/plugins/publish/collect_renderlayer.py b/client/ayon_houdini/plugins/publish/collect_renderlayer.py index b628fc7340..5e2dddf534 100644 --- a/client/ayon_houdini/plugins/publish/collect_renderlayer.py +++ b/client/ayon_houdini/plugins/publish/collect_renderlayer.py @@ -14,7 +14,7 @@ class CollectRendelayerFromROP(plugin.HoudiniInstancePlugin): label = "Collect Render layer name from ROP" - order = pyblish.api.CollectorOrder + order = pyblish.api.CollectorOrder - 0.499 families = ["mantra_rop", "karma_rop", "redshift_rop", From 3be44048ae131dbd86e67c4d274678389096f091 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= <33513211+antirotor@users.noreply.github.com> Date: Mon, 19 Aug 2024 15:36:50 +0200 Subject: [PATCH 6/8] Update client/ayon_houdini/plugins/publish/collect_local_render_instances.py Co-authored-by: Kayla Man <64118225+moonyuet@users.noreply.github.com> --- .../plugins/publish/collect_local_render_instances.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/client/ayon_houdini/plugins/publish/collect_local_render_instances.py b/client/ayon_houdini/plugins/publish/collect_local_render_instances.py index 658e6928ca..6bdd4c8e06 100644 --- a/client/ayon_houdini/plugins/publish/collect_local_render_instances.py +++ b/client/ayon_houdini/plugins/publish/collect_local_render_instances.py @@ -80,7 +80,7 @@ def process(self, instance): host_name=context.data["hostName"], product_type=product_type, variant=instance.data["productName"], - dynamic_data = dynamic_data, + dynamic_data=dynamic_data, ) # Create instance for each AOV From d324d239de759e911d5d5796a2029ae60240043a Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ond=C5=99ej=20Samohel?= Date: Mon, 19 Aug 2024 15:54:24 +0200 Subject: [PATCH 7/8] :recycle: add optional render layer --- .../plugins/publish/collect_local_render_instances.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/client/ayon_houdini/plugins/publish/collect_local_render_instances.py b/client/ayon_houdini/plugins/publish/collect_local_render_instances.py index 6bdd4c8e06..00ecbd1316 100644 --- a/client/ayon_houdini/plugins/publish/collect_local_render_instances.py +++ b/client/ayon_houdini/plugins/publish/collect_local_render_instances.py @@ -73,6 +73,9 @@ def process(self, instance): dynamic_data = {} if aov_name: dynamic_data["aov"] = aov_name + + if instance.data.get("renderlayer"): + dynamic_data["renderlayer"] = instance.data["renderlayer"] product_name, product_group = get_product_name_and_group_from_template( project_name=context.data["projectName"], From 044108e4f5ee79049bed3abdbf09509bf3562bfa Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Thu, 19 Sep 2024 17:31:12 +0300 Subject: [PATCH 8/8] respect use_legacy_product_names_for_renders --- .../publish/collect_local_render_instances.py | 64 ++++++++++++++++--- 1 file changed, 55 insertions(+), 9 deletions(-) diff --git a/client/ayon_houdini/plugins/publish/collect_local_render_instances.py b/client/ayon_houdini/plugins/publish/collect_local_render_instances.py index 3b5dbf6ee8..3ba54d2f38 100644 --- a/client/ayon_houdini/plugins/publish/collect_local_render_instances.py +++ b/client/ayon_houdini/plugins/publish/collect_local_render_instances.py @@ -1,9 +1,10 @@ import os - +import warnings import pyblish.api from ayon_core.pipeline.farm.patterning import match_aov_pattern from ayon_core.pipeline.farm.pyblish_functions import ( - get_product_name_and_group_from_template + get_product_name_and_group_from_template, + _get_legacy_product_name_and_group ) from ayon_core.pipeline.publish import ( get_plugin_settings, @@ -96,13 +97,10 @@ def process(self, instance): if instance.data.get("renderlayer"): dynamic_data["renderlayer"] = instance.data["renderlayer"] - product_name, product_group = get_product_name_and_group_from_template( - project_name=context.data["projectName"], - task_entity=context.data["taskEntity"], - host_name=context.data["hostName"], - product_type=product_type, - variant=instance.data["productName"], - dynamic_data=dynamic_data, + product_name, product_group = self._get_product_name_and_group( + instance, + product_type, + dynamic_data ) # Create instance for each AOV @@ -171,3 +169,51 @@ def process(self, instance): # Skip integrating original render instance. # We are not removing it because it's used to trigger the render. instance.data["integrate"] = False + + def _get_product_name_and_group(self, instance, product_type, dynamic_data): + """Get product name and group + + This method matches the logic in farm that gets + `product_name` and `group_name` respecting + `use_legacy_product_names_for_renders` logic in core settings. + + Args: + instance (pyblish.api.Instance): The instance to publish. + product_type (str): Product type. + dynamic_data (dict): Dynamic data (camera, aov, ...) + + Returns: + tuple (str, str): product name and group name + + """ + + project_settings = instance.context.data.get("project_settings") + + use_legacy_product_name = True + try: + use_legacy_product_name = project_settings["core"]["tools"]["creator"]["use_legacy_product_names_for_renders"] # noqa: E501 + except KeyError: + warnings.warn( + ("use_legacy_for_renders not found in project settings. " + "Using legacy product name for renders. Please update " + "your ayon-core version."), DeprecationWarning) + use_legacy_product_name = True + + if use_legacy_product_name: + product_name, group_name = _get_legacy_product_name_and_group( + product_type=product_type, + source_product_name=instance.data["productName"], + task_name=instance.data["task"], + dynamic_data=dynamic_data) + + else: + product_name, group_name = get_product_name_and_group_from_template( + project_name=instance.context.data["projectName"], + task_entity=instance.context.data["taskEntity"], + host_name=instance.context.data["hostName"], + product_type=product_type, + variant=instance.data["productName"], + dynamic_data=dynamic_data + ) + + return product_name, group_name