From 37a4e91b4a47eb02eb66dbcad3633f0a4d3b0fda Mon Sep 17 00:00:00 2001 From: MustafaJafar Date: Fri, 14 Jun 2024 12:16:15 +0300 Subject: [PATCH] fix a bug with products with single file and improve the logic --- .../plugins/publish/collect_cache_farm.py | 48 +++++++------------ 1 file changed, 18 insertions(+), 30 deletions(-) diff --git a/client/ayon_houdini/plugins/publish/collect_cache_farm.py b/client/ayon_houdini/plugins/publish/collect_cache_farm.py index ecfebccfef..68a66dacbd 100644 --- a/client/ayon_houdini/plugins/publish/collect_cache_farm.py +++ b/client/ayon_houdini/plugins/publish/collect_cache_farm.py @@ -29,23 +29,30 @@ def process(self, instance): # Why do we need this particular collector to collect the expected # output files from a ROP node. Don't we have a dedicated collector # for that yet? + # Answer: No, we don't have a generic expected file collector. + # Because different product types needs different logic. + # e.g. check CollectMantraROPRenderProducts + # and CollectKarmaROPRenderProducts # Collect expected files ropnode = hou.node(instance.data["instance_node"]) output_parm = lib.get_output_parameter(ropnode) expected_filepath = output_parm.eval() instance.data.setdefault("files", list()) instance.data.setdefault("expectedFiles", list()) - if instance.data.get("frames"): - files = self.get_files(instance, expected_filepath) - # list of files - instance.data["files"].extend(files) - else: + + frames = instance.data.get("frames", []) + if not frames or isinstance(frames, str): # single file - instance.data["files"].append(output_parm.eval()) - cache_files = {"_": instance.data["files"]} - # Convert instance family to pointcache if it is bgeo or abc - # because ??? - self.log.debug(instance.data["families"]) + instance.data["files"].append(expected_filepath) + else: + # list of files + staging_dir, _ = os.path.split(expected_filepath) + instance.data["files"].extend( + ["{}/{}".format(staging_dir, f) for f in frames] + ) + + cache_files = {"cache": instance.data["files"]} + instance.data.update({ "plugin": "Houdini", "publish": True @@ -53,23 +60,4 @@ def process(self, instance): instance.data["families"].append("publish.hou") instance.data["expectedFiles"].append(cache_files) - self.log.debug("{}".format(instance.data)) - - def get_files(self, instance, output_parm): - """Get the files with the frame range data - - Args: - instance (_type_): instance - output_parm (_type_): path of output parameter - - Returns: - files: a list of files - """ - directory = os.path.dirname(output_parm) - - files = [ - os.path.join(directory, frame).replace("\\", "/") - for frame in instance.data["frames"] - ] - - return files + self.log.debug("{}".format(instance.data["expectedFiles"]))