merging @milan's work from publish_integrate

This commit is contained in:
Jakub Jezek 2018-12-01 14:22:17 +01:00
parent bf9813f7ef
commit 0cb6ce3206
4 changed files with 33 additions and 84 deletions

View file

@ -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))

View file

@ -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")

View file

@ -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__))

View file

@ -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"