From 2413a76e9cd00db18f614322bf4a28192d61ec72 Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Thu, 15 Feb 2024 11:05:40 +0200 Subject: [PATCH] BigRoy comment - add expoted files to 'cleanupFullPaths and staging dirs to 'cleanupEmptyDirs' --- ...up.py => collect_files_for_cleaning_up.py} | 66 +++++++++++-------- .../houdini/server/settings/publish.py | 6 +- 2 files changed, 40 insertions(+), 32 deletions(-) rename client/ayon_core/hosts/houdini/plugins/publish/{collect_staging_dirs_for_cleaning_up.py => collect_files_for_cleaning_up.py} (58%) 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_files_for_cleaning_up.py similarity index 58% rename from client/ayon_core/hosts/houdini/plugins/publish/collect_staging_dirs_for_cleaning_up.py rename to client/ayon_core/hosts/houdini/plugins/publish/collect_files_for_cleaning_up.py index 1917e3ae26..215e3fb2ed 100644 --- a/client/ayon_core/hosts/houdini/plugins/publish/collect_staging_dirs_for_cleaning_up.py +++ b/client/ayon_core/hosts/houdini/plugins/publish/collect_files_for_cleaning_up.py @@ -3,23 +3,20 @@ import os from ayon_core.pipeline import AYONPyblishPluginMixin -class CollectStagingDirsForCleaningUp(pyblish.api.InstancePlugin, - AYONPyblishPluginMixin): - """Collect Staging Directories For Cleaning Up. +class CollectFilesForCleaningUp(pyblish.api.InstancePlugin, + AYONPyblishPluginMixin): + """Collect Files For Cleaning Up. - This collector collects staging directories + This collector collects output files 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. + This collector deletes the exported files and + deletes the parent folder if it was empty. + Artists are free to change the file path in the ROP node. """ - order = pyblish.api.CollectorOrder + order = pyblish.api.CollectorOrder + 0.2 # it should run after CollectFrames hosts = ["houdini"] families = [ @@ -32,16 +29,35 @@ class CollectStagingDirsForCleaningUp(pyblish.api.InstancePlugin, "review", "staticMesh", "usd", - "vdbcache", + "vdbcache" ] - label = "Collect Staging Directories For Cleaning Up" + label = "Collect Files For Cleaning Up" def process(self, instance): import hou node = hou.node(instance.data["instance_node"]) + filepath = self.get_filepath(node) + if not filepath: + self.log.warning("No filepath value to collect.") + return + + staging_dir, _ = os.path.split(filepath) + files = instance.data.get("frames", []) + if files: + files = ["{}/{}".format(staging_dir, f) for f in files] + else: + files = [filepath] + + self.log.debug("Add directories to 'cleanupEmptyDir': {}".format(staging_dir)) + instance.context.data["cleanupEmptyDirs"].append(staging_dir) + + self.log.debug("Add files to 'cleanupFullPaths': {}".format(files)) + instance.context.data["cleanupFullPaths"] += files + + def get_filepath(self, node): # Get sop path node_type = node.type().name() filepath = None @@ -55,11 +71,10 @@ class CollectStagingDirsForCleaningUp(pyblish.api.InstancePlugin, 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: + if node.evalParm("soho_outputmode"): filepath = node.evalParm("soho_diskfile") + else: + filepath = node.evalParm("vm_picture") elif node_type == "Redshift_Proxy_Output": filepath = node.evalParm("RS_archive_file") @@ -80,11 +95,10 @@ class CollectStagingDirsForCleaningUp(pyblish.api.InstancePlugin, 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: + if node.evalParm("ar_ass_export_enable"): filepath = node.evalParm("ar_ass_file") + else: + filepath = node.evalParm("ar_picture") elif node_type == "vray_renderer": filepath = node.evalParm("SettingsOutput_img_file_path") @@ -94,11 +108,5 @@ class CollectStagingDirsForCleaningUp(pyblish.api.InstancePlugin, "ROP node type '{}' is not supported for cleaning up." .format(node_type) ) - return - - if not filepath: - self.log.warning("No filepath value to collect.") - return - filepath = os.path.dirname(filepath) - self.log.debug("Add to clean up list: {}".format(filepath)) - instance.context.data["cleanupFullPaths"].append(filepath) + + return filepath \ No newline at end of file diff --git a/server_addon/houdini/server/settings/publish.py b/server_addon/houdini/server/settings/publish.py index c0ac6e4118..eb895b429e 100644 --- a/server_addon/houdini/server/settings/publish.py +++ b/server_addon/houdini/server/settings/publish.py @@ -49,9 +49,9 @@ class PublishPluginsModel(BaseSettingsModel): default_factory=CollectChunkSizeModel, title="Collect Chunk Size." ) - CollectStagingDirsForCleaningUp:BasicValidateModel = SettingsField( + CollectFilesForCleaningUp:BasicValidateModel = SettingsField( default_factory=BasicValidateModel, - title="Collect Staging Directories For Cleaning Up." + title="Collect Files For Cleaning Up." ) ValidateContainers: BasicValidateModel = SettingsField( default_factory=BasicValidateModel, @@ -83,7 +83,7 @@ DEFAULT_HOUDINI_PUBLISH_SETTINGS = { "optional": True, "chunk_size": 999999 }, - "CollectStagingDirsForCleaningUp": { + "CollectFilesForCleaningUp": { "enabled": False, "optional": True, "active": True