From 0cb6ce320633d0ea3e49ff2da9a1fbedcefd38a3 Mon Sep 17 00:00:00 2001 From: Jakub Jezek Date: Sat, 1 Dec 2018 14:22:17 +0100 Subject: [PATCH] merging @milan's work from publish_integrate --- pype/plugins/nuke/publish/collect_writes.py | 51 +++++++------------ pype/plugins/nuke/publish/render_local.py | 4 +- .../nuke/publish/validate_collection.py | 28 +++++----- .../nuke/publish/validate_collections.py | 34 ------------- 4 files changed, 33 insertions(+), 84 deletions(-) delete mode 100644 pype/plugins/nuke/publish/validate_collections.py diff --git a/pype/plugins/nuke/publish/collect_writes.py b/pype/plugins/nuke/publish/collect_writes.py index 4008cd1d08..e6097d8f6c 100644 --- a/pype/plugins/nuke/publish/collect_writes.py +++ b/pype/plugins/nuke/publish/collect_writes.py @@ -39,30 +39,9 @@ class CollectNukeWrites(pyblish.api.ContextPlugin): first_frame = int(node["first"].getValue()) last_frame = int(node["last"].getValue()) - # Add collection - collection = None + # get path path = nuke.filename(node) - - if "#" in path: - path_split = path.split("#") - length = len(path_split)-1 - path = "{}%0{}d{}".format(path_split[0], length, path_split[-1]) - - path += " [{0}-{1}]".format( - str(first_frame), - str(last_frame) - ) - self.log.info("collection: {}".format(path)) - - collection = None - if not node["render"].value(): - try: - collection = clique.parse(path) - - except Exception as e: - self.log.warning(e) - collection = None - + output_dir = os.path.dirname(path) # Include start and end render frame in label name = node.name() @@ -74,23 +53,29 @@ class CollectNukeWrites(pyblish.api.ContextPlugin): self.log.debug("checking for error: {}".format(label)) - # dealing with local/farm rendering - if node["render_farm"].value(): - families = "{}.farm".format(instance.data["families"][0]) + files = [] + # preredered frames + if not node["render"].value(): + # dealing with local/farm rendering + if node["render_farm"].value(): + families = "{}.farm".format(instance.data["families"][0]) + else: + families = "{}.local".format(instance.data["families"][0]) else: - families = "{}.local".format(instance.data["families"][0]) + families = 'prerendered.frames' + files = [f for f in os.listdir(output_dir)] self.log.debug("checking for error: {}".format(label)) instance.data.update({ - "path": nuke.filename(node), - "outputDir": os.path.dirname(nuke.filename(node)), + "path": path, + "outputDir": output_dir, "ext": ext, # todo: should be redundant "label": label, "families": [families], - "collection": collection, - "first_frame": first_frame, - "last_frame": last_frame, - "output_type": output_type + "files": files, + "firstFrame": first_frame, + "lastFrame": last_frame, + "outputType": output_type }) self.log.debug("instance.data: {}".format(instance.data)) diff --git a/pype/plugins/nuke/publish/render_local.py b/pype/plugins/nuke/publish/render_local.py index 9e69134600..aa8c98f34b 100644 --- a/pype/plugins/nuke/publish/render_local.py +++ b/pype/plugins/nuke/publish/render_local.py @@ -29,8 +29,8 @@ class NukeRenderLocal(pyblish.api.InstancePlugin): self.log.debug("instance collected: {}".format(instance.data)) - first_frame = instance.data.get("first_frame", None) - last_frame = instance.data.get("last_frame", None) + first_frame = instance.data.get("firstFrame", None) + last_frame = instance.data.get("lastFrame", None) node_subset_name = instance.data.get("subset", None) self.log.info("Starting render") diff --git a/pype/plugins/nuke/publish/validate_collection.py b/pype/plugins/nuke/publish/validate_collection.py index 30b699cec9..95864601aa 100644 --- a/pype/plugins/nuke/publish/validate_collection.py +++ b/pype/plugins/nuke/publish/validate_collection.py @@ -1,6 +1,6 @@ import os import pyblish.api -import nuke +import clique @pyblish.api.log @@ -10,6 +10,7 @@ class RepairCollectionAction(pyblish.api.Action): icon = "wrench" def process(self, context, plugin): + [os.remove(f) for f in context[0].data["files"]] context[0][0]["render"].setValue(True) self.log.info("Rendering toggled ON") @@ -18,26 +19,23 @@ class ValidateCollection(pyblish.api.InstancePlugin): """ Validates file output. """ order = pyblish.api.ValidatorOrder - optional = True - families = ["write"] - label = "Check Full Img Sequence" + # optional = True + families = ['prerendered.frames'] + label = "Check prerendered frames" hosts = ["nuke"] actions = [RepairCollectionAction] def process(self, instance): - if not instance.data["collection"]: - return - missing_files = [] - for f in instance.data["collection"]: - # print f - if not os.path.exists(f): - missing_files.append(f) + collections, remainder = clique.assemble(*instance.data['files']) + self.log.info('collections: {}'.format(collections)) - for f in missing_files: - instance.data["collection"].remove(f) + frame_length = instance.data["lastFrame"] \ + - instance.data["firstFrame"] - frame_length = instance.data["last_frame"] - instance.data["first_frame"] + assert len(collections) == 1, self.log.info("There are multiple collections in the folder") - assert len(list(instance.data["collection"])) is frame_length, self.log.info( + assert collections[0].is_contiguous(), self.log.info("Some frames appear to be missing") + + assert len(list(instance.data["files"])) is frame_length, self.log.info( "{} missing frames. Use repair to render all frames".format(__name__)) diff --git a/pype/plugins/nuke/publish/validate_collections.py b/pype/plugins/nuke/publish/validate_collections.py deleted file mode 100644 index ff1bfdc245..0000000000 --- a/pype/plugins/nuke/publish/validate_collections.py +++ /dev/null @@ -1,34 +0,0 @@ -import pyblish.api -import pype.api -import clique - -import os -import glob - - -class ValidateCollections(pyblish.api.InstancePlugin): - """Validates mapped resources. - - These are external files to the current application, for example - these could be textures, image planes, cache files or other linked - media. - - This validates: - - The resources are existing files. - - The resources have correctly collected the data. - - """ - - order = pype.api.ValidateContentsOrder - label = "Validate Collections" - families = ['prerendered.frames'] - - def process(self, instance): - - collections, remainder = clique.assemble(*instance.data['files']) - self.log.info('collections: {}'.format(collections)) - - assert len(collections) == 1, "There are multiple collections in the folder" - collection_instance = instance.data.get('collection', None) - - assert collections[0].is_contiguous(),"Some frames appear to be missing"