From 24fd0cb749c71aecaa0883bab2e26bd9e30590ca Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Fri, 9 Feb 2024 00:34:33 +0200 Subject: [PATCH] add collector: CollectStagingDirsForCleaningUp --- .../collect_staging_dirs_for_cleaning_up.py | 90 +++++++++++++++++++ .../houdini/server/settings/publish.py | 9 ++ 2 files changed, 99 insertions(+) create mode 100644 client/ayon_core/hosts/houdini/plugins/publish/collect_staging_dirs_for_cleaning_up.py diff --git a/client/ayon_core/hosts/houdini/plugins/publish/collect_staging_dirs_for_cleaning_up.py b/client/ayon_core/hosts/houdini/plugins/publish/collect_staging_dirs_for_cleaning_up.py new file mode 100644 index 0000000000..9af475849f --- /dev/null +++ b/client/ayon_core/hosts/houdini/plugins/publish/collect_staging_dirs_for_cleaning_up.py @@ -0,0 +1,90 @@ +import pyblish.api + +from ayon_core.pipeline import AYONPyblishPluginMixin + + +class CollectStagingDirsForCleaningUp(pyblish.api.InstancePlugin, + AYONPyblishPluginMixin): + """Collect Staging Directories For Cleaning Up. + + This collector collects staging directories + and adds them to file remove list. + + CAUTION: + This collector deletes the parent folder of the exported files. + It works fine with the default filepaths in the creators. + Artist should be aware with that fact so they take care when + changing the file path in the ROP node. + Developers should be aware when changing the filepath pattern + in creator plugins. + """ + + order = pyblish.api.CollectorOrder + + hosts = ["houdini"] + label = "Collect Staging Directories For Cleaning Up" + + def process(self, instance): + + import hou + + node = hou.node(instance.data["instance_node"]) + + # Get sop path + node_type = node.type().name() + if node_type == "geometry": + filepath = node.evalParm("sopoutput") + + elif node_type == "comp": + filepath = node.evalParm("copoutput") + + elif node_type == "alembic": + filepath = node.evalParm("filename") + + elif node_type == "ifd": + filepath = node.evalParm("vm_picture") + # vm_picture is empty when mantra node is + # used to export .ifd files only. + if not filepath: + filepath = node.evalParm("soho_diskfile") + + elif node_type == "Redshift_Proxy_Output": + filepath = node.evalParm("RS_archive_file") + + elif node_type == "Redshift_ROP": + filepath = node.evalParm("RS_outputFileNamePrefix") + + elif node_type == "opengl": + filepath = node.evalParm("picture") + + elif node_type == "filmboxfbx": + filepath = node.evalParm("sopoutput") + + elif node_type == "usd": + filepath = node.evalParm("lopoutput") + + elif node_type == "karma": + filepath = node.evalParm("picture") + + elif node_type == "arnold": + filepath = node.evalParm("ar_picture") + # ar_picture is empty when arnold node is + # used to export .ass files only. + if not filepath: + filepath = node.evalParm("ar_ass_file") + + elif node_type == "vray_renderer": + filepath = node.evalParm("SettingsOutput_img_file_path") + + else: + self.log.debug( + "ROP node type '{}' is not supported for cleaning up." + .format(node_type) + ) + + if not filepath: + self.log.warning("No filepath value to collect.") + return + + self.log.debug("Add to clean up list: {}".format(filepath)) + instance.context.data["cleanupFullPaths"] = filepath diff --git a/server_addon/houdini/server/settings/publish.py b/server_addon/houdini/server/settings/publish.py index 1741568d63..55bb70cba4 100644 --- a/server_addon/houdini/server/settings/publish.py +++ b/server_addon/houdini/server/settings/publish.py @@ -49,6 +49,10 @@ class PublishPluginsModel(BaseSettingsModel): default_factory=CollectChunkSizeModel, title="Collect Chunk Size." ) + CollectStagingDirsForCleaningUp:BasicValidateModel = SettingsField( + default_factory=BasicValidateModel, + title="Collect Staging Directories For Cleaning Up." + ) ValidateContainers: BasicValidateModel = SettingsField( default_factory=BasicValidateModel, title="Validate Latest Containers.", @@ -79,6 +83,11 @@ DEFAULT_HOUDINI_PUBLISH_SETTINGS = { "optional": True, "chunk_size": 999999 }, + "CollectStagingDirsForCleaningUp": { + "enabled": True, + "optional": True, + "active": True + }, "ValidateContainers": { "enabled": True, "optional": True,