From 39c31652d6f99ee501f32ba202663da658c99beb Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Tue, 29 Oct 2024 21:33:31 +0300 Subject: [PATCH 1/4] add publish families to cache creators --- client/ayon_houdini/plugins/create/create_arnold_ass.py | 3 +++ client/ayon_houdini/plugins/create/create_bgeo.py | 3 +++ client/ayon_houdini/plugins/create/create_model.py | 3 +++ client/ayon_houdini/plugins/create/create_pointcache.py | 3 +++ client/ayon_houdini/plugins/create/create_redshift_proxy.py | 3 +++ client/ayon_houdini/plugins/create/create_vbd_cache.py | 3 +++ 6 files changed, 18 insertions(+) diff --git a/client/ayon_houdini/plugins/create/create_arnold_ass.py b/client/ayon_houdini/plugins/create/create_arnold_ass.py index ec7ba508e0..c570f568f7 100644 --- a/client/ayon_houdini/plugins/create/create_arnold_ass.py +++ b/client/ayon_houdini/plugins/create/create_arnold_ass.py @@ -17,6 +17,9 @@ class CreateArnoldAss(plugin.HoudiniCreator): # will override it by the value in the project settings ext = ".ass" + def get_publish_families(self): + return ["ass", "publish.hou"] + def create(self, product_name, instance_data, pre_create_data): import hou diff --git a/client/ayon_houdini/plugins/create/create_bgeo.py b/client/ayon_houdini/plugins/create/create_bgeo.py index 474aa2f827..ab3f201a4d 100644 --- a/client/ayon_houdini/plugins/create/create_bgeo.py +++ b/client/ayon_houdini/plugins/create/create_bgeo.py @@ -13,6 +13,9 @@ class CreateBGEO(plugin.HoudiniCreator): product_type = "pointcache" icon = "gears" + def get_publish_families(self): + return ["pointcache", "bgeo", "publish.hou"] + def create(self, product_name, instance_data, pre_create_data): instance_data.update({"node_type": "geometry"}) diff --git a/client/ayon_houdini/plugins/create/create_model.py b/client/ayon_houdini/plugins/create/create_model.py index ef1c5741d4..5c4b000984 100644 --- a/client/ayon_houdini/plugins/create/create_model.py +++ b/client/ayon_houdini/plugins/create/create_model.py @@ -24,6 +24,9 @@ class CreateModel(plugin.HoudiniCreator): product_type = "model" icon = "cube" + def get_publish_families(self): + return ["model", "abc", "publish.hou"] + def create(self, product_name, instance_data, pre_create_data): instance_data.update({"node_type": "alembic"}) creator_attributes = instance_data.setdefault( diff --git a/client/ayon_houdini/plugins/create/create_pointcache.py b/client/ayon_houdini/plugins/create/create_pointcache.py index 06d7aaa4ec..5f69335726 100644 --- a/client/ayon_houdini/plugins/create/create_pointcache.py +++ b/client/ayon_houdini/plugins/create/create_pointcache.py @@ -14,6 +14,9 @@ class CreatePointCache(plugin.HoudiniCreator): product_type = "pointcache" icon = "gears" + def get_publish_families(self): + return ["pointcache", "abc", "publish.hou"] + def create(self, product_name, instance_data, pre_create_data): instance_data.update({"node_type": "alembic"}) creator_attributes = instance_data.setdefault( diff --git a/client/ayon_houdini/plugins/create/create_redshift_proxy.py b/client/ayon_houdini/plugins/create/create_redshift_proxy.py index d9bfe6cdd2..85de6fe981 100644 --- a/client/ayon_houdini/plugins/create/create_redshift_proxy.py +++ b/client/ayon_houdini/plugins/create/create_redshift_proxy.py @@ -12,6 +12,9 @@ class CreateRedshiftProxy(plugin.HoudiniCreator): product_type = "redshiftproxy" icon = "magic" + def get_publish_families(self): + return ["redshiftproxy", "publish.hou"] + def create(self, product_name, instance_data, pre_create_data): # Redshift provides a `Redshift_Proxy_Output` node type which shows diff --git a/client/ayon_houdini/plugins/create/create_vbd_cache.py b/client/ayon_houdini/plugins/create/create_vbd_cache.py index 804865860e..19b141bab0 100644 --- a/client/ayon_houdini/plugins/create/create_vbd_cache.py +++ b/client/ayon_houdini/plugins/create/create_vbd_cache.py @@ -14,6 +14,9 @@ class CreateVDBCache(plugin.HoudiniCreator): product_type = "vdbcache" icon = "cloud" + def get_publish_families(self): + return ["vbdcache", "publish.hou"] + def create(self, product_name, instance_data, pre_create_data): import hou From 57472d5fcd7ebfed244d64434df81a25b1f65870 Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Tue, 29 Oct 2024 21:34:03 +0300 Subject: [PATCH 2/4] remove unnecessary collector --- .../plugins/publish/collect_instances_type.py | 24 ------------------- 1 file changed, 24 deletions(-) delete mode 100644 client/ayon_houdini/plugins/publish/collect_instances_type.py diff --git a/client/ayon_houdini/plugins/publish/collect_instances_type.py b/client/ayon_houdini/plugins/publish/collect_instances_type.py deleted file mode 100644 index 75a394a1f9..0000000000 --- a/client/ayon_houdini/plugins/publish/collect_instances_type.py +++ /dev/null @@ -1,24 +0,0 @@ -"""Collector for different types. - -This will add additional families to different instance based on -the creator_identifier parameter. -""" -import pyblish.api -from ayon_houdini.api import plugin - - -class CollectPointcacheType(plugin.HoudiniInstancePlugin): - """Collect data type for different instances.""" - - order = pyblish.api.CollectorOrder - families = ["pointcache", "model"] - label = "Collect instances types" - - def process(self, instance): - if instance.data["creator_identifier"] == "io.openpype.creators.houdini.bgeo": # noqa: E501 - instance.data["families"] += ["bgeo"] - elif instance.data["creator_identifier"] in { - "io.openpype.creators.houdini.pointcache", - "io.openpype.creators.houdini.model" - }: - instance.data["families"] += ["abc"] From d735912f96ae69e3613c2b2eebca4580c438ed4b Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Tue, 29 Oct 2024 21:34:59 +0300 Subject: [PATCH 3/4] implement on_value_change callback and make attribute visible if `farm` is enabled --- .../plugins/publish/collect_chunk_size.py | 46 +++++++++++++++++-- 1 file changed, 43 insertions(+), 3 deletions(-) diff --git a/client/ayon_houdini/plugins/publish/collect_chunk_size.py b/client/ayon_houdini/plugins/publish/collect_chunk_size.py index cd94827ba7..9d057482a2 100644 --- a/client/ayon_houdini/plugins/publish/collect_chunk_size.py +++ b/client/ayon_houdini/plugins/publish/collect_chunk_size.py @@ -9,7 +9,7 @@ class CollectChunkSize(plugin.HoudiniInstancePlugin, """Collect chunk size for cache submission to Deadline.""" order = pyblish.api.CollectorOrder + 0.05 - families = ["ass", "pointcache", "vdbcache", "redshiftproxy", "model"] + families = ["publish.hou"] targets = ["local", "remote"] label = "Collect Chunk Size" chunk_size = 999999 @@ -20,12 +20,52 @@ def process(self, instance): instance.data["chunkSize"] = attr_values.get("chunkSize") @classmethod - def get_attribute_defs(cls): + def get_attr_defs_for_instance(cls, create_context, instance): + # Filtering of instance, if needed, can be customized + if not cls.instance_matches_plugin_families(instance): + return [] + + # Attributes logic + creator_attributes = instance["creator_attributes"] + + visible = creator_attributes.get("farm", False) + return [ NumberDef("chunkSize", minimum=1, maximum=999999, decimals=0, default=cls.chunk_size, - label="Frame Per Task") + label="Frame Per Task", + visible=visible) ] + + @classmethod + def register_create_context_callbacks(cls, create_context): + create_context.add_value_changed_callback(cls.on_values_changed) + + @classmethod + def on_values_changed(cls, event): + """Update instance attribute definitions on attribute changes.""" + + # Update attributes if any of the following plug-in attributes + # change: + keys = ["farm"] + + for instance_change in event["changes"]: + instance = instance_change["instance"] + if not cls.instance_matches_plugin_families(instance): + continue + value_changes = instance_change["changes"] + plugin_attribute_changes = ( + value_changes.get("creator_attributes", {}) + .get(cls.__name__, {})) + + if not any(key in plugin_attribute_changes for key in keys): + continue + + # Update the attribute definitions + new_attrs = cls.get_attr_defs_for_instance( + event["create_context"], instance + ) + instance.set_publish_plugin_attr_defs(cls.__name__, new_attrs) \ No newline at end of file From 4f646b517f0182c4d12009801beb53ddd1ed3a85 Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Wed, 13 Nov 2024 18:22:59 +0200 Subject: [PATCH 4/4] revert changes in collect_chunk_size.py --- .../plugins/publish/collect_chunk_size.py | 46 ++----------------- 1 file changed, 3 insertions(+), 43 deletions(-) diff --git a/client/ayon_houdini/plugins/publish/collect_chunk_size.py b/client/ayon_houdini/plugins/publish/collect_chunk_size.py index 9d057482a2..cd94827ba7 100644 --- a/client/ayon_houdini/plugins/publish/collect_chunk_size.py +++ b/client/ayon_houdini/plugins/publish/collect_chunk_size.py @@ -9,7 +9,7 @@ class CollectChunkSize(plugin.HoudiniInstancePlugin, """Collect chunk size for cache submission to Deadline.""" order = pyblish.api.CollectorOrder + 0.05 - families = ["publish.hou"] + families = ["ass", "pointcache", "vdbcache", "redshiftproxy", "model"] targets = ["local", "remote"] label = "Collect Chunk Size" chunk_size = 999999 @@ -20,52 +20,12 @@ def process(self, instance): instance.data["chunkSize"] = attr_values.get("chunkSize") @classmethod - def get_attr_defs_for_instance(cls, create_context, instance): - # Filtering of instance, if needed, can be customized - if not cls.instance_matches_plugin_families(instance): - return [] - - # Attributes logic - creator_attributes = instance["creator_attributes"] - - visible = creator_attributes.get("farm", False) - + def get_attribute_defs(cls): return [ NumberDef("chunkSize", minimum=1, maximum=999999, decimals=0, default=cls.chunk_size, - label="Frame Per Task", - visible=visible) + label="Frame Per Task") ] - - @classmethod - def register_create_context_callbacks(cls, create_context): - create_context.add_value_changed_callback(cls.on_values_changed) - - @classmethod - def on_values_changed(cls, event): - """Update instance attribute definitions on attribute changes.""" - - # Update attributes if any of the following plug-in attributes - # change: - keys = ["farm"] - - for instance_change in event["changes"]: - instance = instance_change["instance"] - if not cls.instance_matches_plugin_families(instance): - continue - value_changes = instance_change["changes"] - plugin_attribute_changes = ( - value_changes.get("creator_attributes", {}) - .get(cls.__name__, {})) - - if not any(key in plugin_attribute_changes for key in keys): - continue - - # Update the attribute definitions - new_attrs = cls.get_attr_defs_for_instance( - event["create_context"], instance - ) - instance.set_publish_plugin_attr_defs(cls.__name__, new_attrs) \ No newline at end of file