implement nuke publish with the new integrator

This commit is contained in:
Milan Kolar 2019-05-27 23:49:17 +01:00
parent ccbcc564df
commit 4ea25d3418
8 changed files with 107 additions and 65 deletions

View file

@ -16,21 +16,21 @@ class CleanUp(pyblish.api.InstancePlugin):
exclude_families = ["clip"]
def process(self, instance):
if [ef for ef in self.exclude_families
if instance.data["family"] in ef]:
return
import tempfile
staging_dir = instance.data.get("stagingDir", None)
if not staging_dir or not os.path.exists(staging_dir):
self.log.info("No staging directory found: %s" % staging_dir)
return
temp_root = tempfile.gettempdir()
if not os.path.normpath(staging_dir).startswith(temp_root):
self.log.info("Skipping cleanup. Staging directory is not in the "
"temp folder: %s" % staging_dir)
return
self.log.info("Removing temporary folder ...")
shutil.rmtree(staging_dir)
# if [ef for ef in self.exclude_families
# if instance.data["family"] in ef]:
# return
# import tempfile
#
# staging_dir = instance.data.get("stagingDir", None)
# if not staging_dir or not os.path.exists(staging_dir):
# self.log.info("No staging directory found: %s" % staging_dir)
# return
#
# temp_root = tempfile.gettempdir()
# if not os.path.normpath(staging_dir).startswith(temp_root):
# self.log.info("Skipping cleanup. Staging directory is not in the "
# "temp folder: %s" % staging_dir)
# return
#
# self.log.info("Removing temporary folder ...")
# shutil.rmtree(staging_dir)

View file

@ -28,9 +28,7 @@ class IntegrateAsset(pyblish.api.InstancePlugin):
families = ["look",
"assembly",
"yetiRig",
"yeticache",
"nukescript",
"write"]
"yeticache"]
exclude_families = ["clip"]
def process(self, instance):

View file

@ -56,7 +56,10 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin):
"vrayproxy",
"render",
"imagesequence",
"review"
"review",
"nukescript",
"render",
"write"
]
exclude_families = ["clip"]
@ -228,7 +231,7 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin):
if isinstance(files, list):
src_collections, remainder = clique.assemble(files)
self.log.debug(
"dst_collections: {}".format(str(src_collections)))
"src_collections: {}".format(str(src_collections)))
src_collection = src_collections[0]
# Assert that each member has identical suffix
src_head = src_collection.format("{head}")
@ -242,6 +245,8 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin):
anatomy_filled = anatomy.format(template_data)
test_dest_files.append(
anatomy_filled[template_name]["path"])
self.log.debug(
"test_dest_files: {}".format(str(test_dest_files)))
dst_collections, remainder = clique.assemble(test_dest_files)
dst_collection = dst_collections[0]

View file

@ -24,7 +24,7 @@ class IntegrateFrames(pyblish.api.InstancePlugin):
label = "Integrate Frames"
order = pyblish.api.IntegratorOrder
families = ["imagesequence", "render", "write", "source"]
families = ["imagesequence", "source"]
family_targets = [".frames", ".local", ".review", "imagesequence", "render", "source"]
exclude_families = ["clip"]

View file

@ -64,19 +64,27 @@ class CollectNukeWrites(pyblish.api.ContextPlugin):
)
if "representations" not in instance.data:
instance.data["representations"] = []
instance.data["representations"] = list()
try:
collected_frames = os.listdir(output_dir)
representation = {
'name': ext,
'ext': "." + ext,
'files': collected_frames,
"stagingDir": output_dir,
}
instance.data["representations"].append(representation)
representation = {
'name': ext,
'ext': ext,
'files': collected_frames,
"stagingDir": output_dir,
"anatomy_template": "render"
}
instance.data["representations"].append(representation)
except Exception:
self.log.debug("couldn't collect frames: {}".format(label))
# except Exception:
# self.log.debug("couldn't collect frames: {}".format(label))
instance.data.update({
"path": path,
"outputDir": output_dir,

View file

@ -49,18 +49,27 @@ class NukeRenderLocal(pype.api.Extractor):
# swap path back to publish path
path = node['file'].value()
node['file'].setValue(path.replace(temp_dir, output_dir))
ext = node["file_type"].value()
if "files" not in instance.data:
instance.data["files"] = list()
if "representations" not in instance.data:
instance.data["representations"] = []
instance.data["files"] = [os.listdir(temp_dir)]
collected_frames = os.listdir(temp_dir)
repre = {
'name': ext,
'ext': ext,
'files': collected_frames,
"stagingDir": temp_dir,
"anatomy_template": "render"
}
instance.data["representations"].append(repre)
self.log.info("Extracted instance '{0}' to: {1}".format(
instance.name,
output_dir
temp_dir
))
collections, remainder = clique.assemble(*instance.data['files'])
collections, remainder = clique.assemble(collected_frames)
self.log.info('collections: {}'.format(str(collections)))
if collections:

View file

@ -26,7 +26,7 @@ class ExtractDataForReview(pype.api.Extractor):
# Deselect all nodes to prevent external connections
[i["selected"].setValue(False) for i in nuke.allNodes()]
self.log.debug("creating staging dir:")
self.stagingDir(instance)
self.staging_dir(instance)
self.log.debug("instance: {}".format(instance))
self.log.debug("instance.data[families]: {}".format(
@ -75,13 +75,28 @@ class ExtractDataForReview(pype.api.Extractor):
instance.data["baked_colorspace_movie"]))
os.remove(instance.data["baked_colorspace_movie"])
instance.data["files"].append(file_name)
if "representations" not in instance.data:
instance.data["representations"] = []
representation = {
'name': 'mov',
'ext': 'mov',
'files': file_name,
"stagingDir": stagingDir,
"anatomy_template": "render",
"thumbnail": False,
"preview": True,
'startFrameReview': instance.data['startFrame'],
'endFrameReview': instance.data['endFrame'],
'frameRate': instance.context.data["framerate"]
}
instance.data["representations"].append(representation)
def render_review_representation(self,
instance,
representation="mov"):
assert instance.data['files'], "Instance data files should't be empty!"
assert instance.data['representations'][0]['files'], "Instance data files should't be empty!"
import nuke
temporary_nodes = []
@ -155,6 +170,8 @@ class ExtractDataForReview(pype.api.Extractor):
write_node["raw"].setValue(1)
write_node.setInput(0, previous_node)
temporary_nodes.append(write_node)
thumbnail = False
preview = True
elif representation in "jpeg":
file = fhead + "jpeg"
@ -165,6 +182,8 @@ class ExtractDataForReview(pype.api.Extractor):
write_node["raw"].setValue(1)
write_node.setInput(0, previous_node)
temporary_nodes.append(write_node)
thumbnail = True
preview = False
# retime for
first_frame = int(last_frame) / 2
@ -174,13 +193,16 @@ class ExtractDataForReview(pype.api.Extractor):
if "representations" not in instance.data:
instance.data["representations"] = []
representation = {
'name': 'nk',
'ext': '.nk',
repre = {
'name': representation,
'ext': representation,
'files': file,
"stagingDir": stagingdir,
"stagingDir": stagingDir,
"anatomy_template": "render",
"thumbnail": thumbnail,
"preview": preview
}
instance.data["representations"].append(representation)
instance.data["representations"].append(repre)
# Render frames
nuke.execute(write_node.name(), int(first_frame), int(last_frame))

View file

@ -30,33 +30,33 @@ class ValidatePrerenderedFrames(pyblish.api.InstancePlugin):
hosts = ["nuke"]
actions = [RepairCollectionAction]
def process(self, instance):
self.log.debug('instance.data["files"]: {}'.format(instance.data['files']))
assert instance.data.get('files'), "no frames were collected, you need to render them"
for repre in instance.data.get('representations'):
collections, remainder = clique.assemble(*instance.data['files'])
self.log.info('collections: {}'.format(str(collections)))
assert repre.get('files'), "no frames were collected, you need to render them"
collection = collections[0]
collections, remainder = clique.assemble(repre["files"])
self.log.info('collections: {}'.format(str(collections)))
frame_length = instance.data["endFrame"] \
- instance.data["startFrame"] + 1
collection = collections[0]
if frame_length is not 1:
assert len(collections) == 1, "There are multiple collections in the folder"
assert collection.is_contiguous(), "Some frames appear to be missing"
frame_length = instance.data["endFrame"] \
- instance.data["startFrame"] + 1
assert remainder is not None, "There are some extra files in folder"
if frame_length != 1:
assert len(collections) == 1, "There are multiple collections in the folder"
assert collection.is_contiguous(), "Some frames appear to be missing"
self.log.info('frame_length: {}'.format(frame_length))
self.log.info('len(collection.indexes): {}'.format(
len(collection.indexes)))
assert remainder is not None, "There are some extra files in folder"
assert len(
collection.indexes
) is frame_length, "{} missing frames. Use "
"repair to render all frames".format(__name__)
self.log.info('frame_length: {}'.format(frame_length))
self.log.info('len(collection.indexes): {}'.format(
len(collection.indexes)))
instance.data['collection'] = collection
assert len(
collection.indexes
) is frame_length, "{} missing frames. Use "
"repair to render all frames".format(__name__)
instance.data['collection'] = collection