From 9fa7e893d80ddc2aff2e802ee27000c0803aabfd Mon Sep 17 00:00:00 2001 From: Milan Kolar Date: Mon, 27 May 2019 14:01:16 +0100 Subject: [PATCH] add support for more families in the new integrator --- .../global/publish/collect_filesequences.py | 9 ++- pype/plugins/global/publish/extract_jpeg.py | 13 ++++- .../global/publish/extract_quicktime.py | 13 ++++- pype/plugins/global/publish/integrate.py | 6 -- pype/plugins/global/publish/integrate_new.py | 11 +++- .../houdini/publish/extract_vdb_cache.py | 14 +++-- pype/plugins/maya/publish/extract_fbx.py | 17 ++++-- .../plugins/maya/publish/extract_thumbnail.py | 56 ++++--------------- .../plugins/maya/publish/extract_vrayproxy.py | 12 +++- pype/plugins/nuke/publish/collect_reads.py | 11 +++- pype/plugins/nuke/publish/collect_writes.py | 16 ++++-- pype/plugins/nuke/publish/extract_review.py | 28 +++++++--- pype/plugins/nuke/publish/extract_script.py | 16 ++++-- .../publish/collect_context.py | 1 - 14 files changed, 129 insertions(+), 94 deletions(-) diff --git a/pype/plugins/global/publish/collect_filesequences.py b/pype/plugins/global/publish/collect_filesequences.py index ce4c95d465..ce1ae2258e 100644 --- a/pype/plugins/global/publish/collect_filesequences.py +++ b/pype/plugins/global/publish/collect_filesequences.py @@ -179,7 +179,6 @@ class CollectFileSequences(pyblish.api.ContextPlugin): "subset": subset, "asset": data.get("asset", api.Session["AVALON_ASSET"]), "stagingDir": root, - "files": [list(collection)], "startFrame": start, "endFrame": end, "fps": fps, @@ -187,6 +186,14 @@ class CollectFileSequences(pyblish.api.ContextPlugin): }) instance.append(collection) + representation = { + 'name': 'jpg', + 'ext': '.jpg', + 'files': [list(collection)], + "stagingDir": root, + } + instance.data["representations"] = [representation] + if data.get('user'): context.data["user"] = data['user'] diff --git a/pype/plugins/global/publish/extract_jpeg.py b/pype/plugins/global/publish/extract_jpeg.py index 7720c9d56d..88e17f55c7 100644 --- a/pype/plugins/global/publish/extract_jpeg.py +++ b/pype/plugins/global/publish/extract_jpeg.py @@ -62,6 +62,13 @@ class ExtractJpegEXR(pyblish.api.InstancePlugin): sub_proc = subprocess.Popen(subprocess_jpeg) sub_proc.wait() - if "files" not in instance.data: - instance.data["files"] = list() - instance.data["files"].append(jpegFile) + if "representations" not in instance.data: + instance.data["representations"] = [] + + representation = { + 'name': 'jpg', + 'ext': '.jpg', + 'files': jpegFile, + "stagingDir": stagingdir, + } + instance.data["representations"].append(representation) diff --git a/pype/plugins/global/publish/extract_quicktime.py b/pype/plugins/global/publish/extract_quicktime.py index fd34c46e5e..4c7db34e95 100644 --- a/pype/plugins/global/publish/extract_quicktime.py +++ b/pype/plugins/global/publish/extract_quicktime.py @@ -70,6 +70,13 @@ class ExtractQuicktimeEXR(pyblish.api.InstancePlugin): sub_proc = subprocess.Popen(subprocess_mov) sub_proc.wait() - if "files" not in instance.data: - instance.data["files"] = list() - instance.data["files"].append(movFile) + if "representations" not in instance.data: + instance.data["representations"] = [] + + representation = { + 'name': 'mov', + 'ext': '.mov', + 'files': movFile, + "stagingDir": stagingdir, + } + instance.data["representations"].append(representation) diff --git a/pype/plugins/global/publish/integrate.py b/pype/plugins/global/publish/integrate.py index b4ca38c334..d1a572fbfd 100644 --- a/pype/plugins/global/publish/integrate.py +++ b/pype/plugins/global/publish/integrate.py @@ -26,16 +26,10 @@ class IntegrateAsset(pyblish.api.InstancePlugin): label = "Integrate Asset" order = pyblish.api.IntegratorOrder families = ["look", - "vdbcache", "assembly", - "vrayproxy", "yetiRig", "yeticache", "nukescript", - "review", - "scene", - "render", - "imagesequence", "write"] exclude_families = ["clip"] diff --git a/pype/plugins/global/publish/integrate_new.py b/pype/plugins/global/publish/integrate_new.py index e01c339143..5f6fa7b674 100644 --- a/pype/plugins/global/publish/integrate_new.py +++ b/pype/plugins/global/publish/integrate_new.py @@ -34,7 +34,7 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): 'anatomy_template': 'publish' or 'render', etc. template from anatomy that should be used for integrating this file. Only the first level can - be specified right now. + be specified right now. 'startFrame' 'endFrame' 'framerate' @@ -50,7 +50,13 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): "mayaAscii", "setdress", "layout", - "ass" + "ass", + "vdbcache", + "scene", + "vrayproxy", + "render", + "imagesequence", + "review" ] exclude_families = ["clip"] @@ -281,7 +287,6 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin): dst = anatomy_filled[template_name]["path"] instance.data["transfers"].append([src, dst]) - # template = anatomy.templates["publish"]["path"] instance.data["representations"][idx]['published_path'] = dst representation = { diff --git a/pype/plugins/houdini/publish/extract_vdb_cache.py b/pype/plugins/houdini/publish/extract_vdb_cache.py index cfd9104744..29686ef2fd 100644 --- a/pype/plugins/houdini/publish/extract_vdb_cache.py +++ b/pype/plugins/houdini/publish/extract_vdb_cache.py @@ -35,9 +35,15 @@ class ExtractVDBCache(pype.api.Extractor): traceback.print_exc() raise RuntimeError("Render failed: {0}".format(exc)) - if "files" not in instance.data: - instance.data["files"] = [] - output = instance.data["frames"] - instance.data["files"].append(output) + if "representations" not in instance.data: + instance.data["representations"] = [] + + representation = { + 'name': 'mov', + 'ext': '.mov', + 'files': output, + "stagingDir": staging_dir, + } + instance.data["representations"].append(representation) diff --git a/pype/plugins/maya/publish/extract_fbx.py b/pype/plugins/maya/publish/extract_fbx.py index 48dd5a135c..93a99eea72 100644 --- a/pype/plugins/maya/publish/extract_fbx.py +++ b/pype/plugins/maya/publish/extract_fbx.py @@ -146,9 +146,9 @@ class ExtractFBX(pype.api.Extractor): cmds.loadPlugin("fbxmaya", quiet=True) # Define output path - directory = self.staging_dir(instance) + stagingDir = self.staging_dir(instance) filename = "{0}.fbx".format(instance.name) - path = os.path.join(directory, filename) + path = os.path.join(stagingDir, filename) # The export requires forward slashes because we need # to format it into a string in a mel expression @@ -208,9 +208,16 @@ class ExtractFBX(pype.api.Extractor): cmds.select(members, r=1, noExpand=True) mel.eval('FBXExport -f "{}" -s'.format(path)) - if "files" not in instance.data: - instance.data["files"] = list() + if "representations" not in instance.data: + instance.data["representations"] = [] + + representation = { + 'name': 'mov', + 'ext': '.mov', + 'files': filename, + "stagingDir": stagingDir, + } + instance.data["representations"].append(representation) - instance.data["files"].append(filename) self.log.info("Extract FBX successful to: {0}".format(path)) diff --git a/pype/plugins/maya/publish/extract_thumbnail.py b/pype/plugins/maya/publish/extract_thumbnail.py index 8bcd017729..355aa2b08b 100644 --- a/pype/plugins/maya/publish/extract_thumbnail.py +++ b/pype/plugins/maya/publish/extract_thumbnail.py @@ -110,9 +110,9 @@ class ExtractThumbnail(pype.api.Extractor): "depthOfField": cmds.getAttr("{0}.depthOfField".format(camera)), } - stagingdir = self.staging_dir(instance) + stagingDir = self.staging_dir(instance) filename = "{0}".format(instance.name) - path = os.path.join(stagingdir, filename) + path = os.path.join(stagingDir, filename) self.log.info("Outputting images to %s" % path) @@ -131,51 +131,19 @@ class ExtractThumbnail(pype.api.Extractor): _, thumbnail = os.path.split(playblast) self.log.info("file list {}".format(thumbnail)) - # self.log.info("Calculating HUD data overlay") - # stagingdir = "C:/Users/milan.kolar/AppData/Local/Temp/pyblish_tmp_ucsymm" - # collected_frames = os.listdir(stagingdir) - # collections, remainder = clique.assemble(collected_frames) - # input_path = os.path.join(stagingdir, collections[0].format('{head}{padding}{tail}')) - # self.log.info("input {}".format(input_path)) + if "representations" not in instance.data: + instance.data["representations"] = [] - # movieFile = filename + ".mov" - # full_movie_path = os.path.join(stagingdir, movieFile) - # self.log.info("output {}".format(full_movie_path)) - # fls = [os.path.join(stagingdir, filename).replace("\\","/") for f in os.listdir( dir_path ) if f.endswith(preset['compression'])] - # self.log.info("file list {}}".format(fls[0])) + representation = { + 'name': 'thumbnail', + 'ext': '.jpg', + 'files': thumbnail, + "stagingDir": stagingDir, + "thumbnail": True + } + instance.data["representations"].append(representation) - # out, err = ( - # ffmpeg - # .input(input_path, framerate=25) - # .output(full_movie_path) - # .run(overwrite_output=True) - # ) - - if "files" not in instance.data: - instance.data["files"] = list() - instance.data["files"].append(thumbnail) - - # ftrackStrings = fStrings.annotationData() - # nData = ftrackStrings.niceData - # nData['version'] = instance.context.data('version') - # fFrame = int(pm.playbackOptions( q = True, minTime = True)) - # eFrame = int(pm.playbackOptions( q = True, maxTime = True)) - # nData['frame'] = [(str("{0:05d}".format(f))) for f in range(fFrame, eFrame + 1)] - # soundOfst = int(float(nData['oFStart'])) - int(float(nData['handle'])) - fFrame - # soundFile = mu.giveMePublishedAudio() - # self.log.info("SOUND offset %s" % str(soundOfst)) - # self.log.info("SOUND source video to %s" % str(soundFile)) - # ann = dHUD.draftAnnotate() - # if soundFile: - # ann.addAnotation(seqFls = fls, outputMoviePth = movieFullPth, annotateDataArr = nData, soundFile = soundFile, soundOffset = soundOfst) - # else: - # ann.addAnotation(seqFls = fls, outputMoviePth = movieFullPth, annotateDataArr = nData) - - # for f in fls: - # os.remove(f) - - # playblast = (ann.expPth).replace("\\","/") @contextlib.contextmanager diff --git a/pype/plugins/maya/publish/extract_vrayproxy.py b/pype/plugins/maya/publish/extract_vrayproxy.py index 5c68f3ca81..b2c84db22b 100644 --- a/pype/plugins/maya/publish/extract_vrayproxy.py +++ b/pype/plugins/maya/publish/extract_vrayproxy.py @@ -54,10 +54,16 @@ class ExtractVRayProxy(pype.api.Extractor): ignoreHiddenObjects=True, createProxyNode=False) - if "files" not in instance.data: - instance.data["files"] = list() + if "representations" not in instance.data: + instance.data["representations"] = [] - instance.data["files"].append(file_name) + representation = { + 'name': 'vrmesh', + 'ext': '.vrmesh', + 'files': file_name, + "stagingDir": staging_dir, + } + instance.data["representations"].append(representation) self.log.info("Extracted instance '%s' to: %s" % (instance.name, staging_dir)) diff --git a/pype/plugins/nuke/publish/collect_reads.py b/pype/plugins/nuke/publish/collect_reads.py index 75ea2efa3a..1bba6198d2 100644 --- a/pype/plugins/nuke/publish/collect_reads.py +++ b/pype/plugins/nuke/publish/collect_reads.py @@ -76,7 +76,16 @@ class CollectNukeReads(pyblish.api.ContextPlugin): self.log.debug("collected_frames: {}".format(label)) - instance.data["files"] = [source_files] + if "representations" not in instance.data: + instance.data["representations"] = [] + + representation = { + 'name': ext, + 'ext': "." + ext, + 'files': source_files, + "stagingDir": source_dir, + } + instance.data["representations"].append(representation) transfer = False if "publish" in node.knobs(): diff --git a/pype/plugins/nuke/publish/collect_writes.py b/pype/plugins/nuke/publish/collect_writes.py index 68cd227280..fb66a29bc8 100644 --- a/pype/plugins/nuke/publish/collect_writes.py +++ b/pype/plugins/nuke/publish/collect_writes.py @@ -63,12 +63,16 @@ class CollectNukeWrites(pyblish.api.ContextPlugin): int(last_frame) ) - if "files" not in instance.data: - instance.data["files"] = list() - try: - collected_frames = os.listdir(output_dir) - self.log.debug("collected_frames: {}".format(label)) - instance.data["files"].append(collected_frames) + if "representations" not in instance.data: + instance.data["representations"] = [] + + representation = { + 'name': ext, + 'ext': "." + ext, + 'files': collected_frames, + "stagingDir": output_dir, + } + instance.data["representations"].append(representation) except Exception: self.log.debug("couldn't collect frames: {}".format(label)) diff --git a/pype/plugins/nuke/publish/extract_review.py b/pype/plugins/nuke/publish/extract_review.py index 16fb07a3fc..ed38893927 100644 --- a/pype/plugins/nuke/publish/extract_review.py +++ b/pype/plugins/nuke/publish/extract_review.py @@ -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.staging_dir(instance) + self.stagingDir(instance) self.log.debug("instance: {}".format(instance)) self.log.debug("instance.data[families]: {}".format( @@ -50,10 +50,10 @@ class ExtractDataForReview(pype.api.Extractor): def transcode_mov(self, instance): collection = instance.data["collection"] - staging_dir = instance.data["stagingDir"].replace("\\", "/") + stagingDir = instance.data["stagingDir"].replace("\\", "/") file_name = collection.format("{head}mov") - review_mov = os.path.join(staging_dir, file_name).replace("\\", "/") + review_mov = os.path.join(stagingDir, file_name).replace("\\", "/") self.log.info("transcoding review mov: {0}".format(review_mov)) if instance.data.get("baked_colorspace_movie"): @@ -85,8 +85,8 @@ class ExtractDataForReview(pype.api.Extractor): import nuke temporary_nodes = [] - staging_dir = instance.data["stagingDir"].replace("\\", "/") - self.log.debug("StagingDir `{0}`...".format(staging_dir)) + stagingDir = instance.data["stagingDir"].replace("\\", "/") + self.log.debug("StagingDir `{0}`...".format(stagingDir)) collection = instance.data.get("collection", None) @@ -108,7 +108,7 @@ class ExtractDataForReview(pype.api.Extractor): node = previous_node = nuke.createNode("Read") node["file"].setValue( - os.path.join(staging_dir, fname).replace("\\", "/")) + os.path.join(stagingDir, fname).replace("\\", "/")) node["first"].setValue(first_frame) node["origfirst"].setValue(first_frame) @@ -147,7 +147,7 @@ class ExtractDataForReview(pype.api.Extractor): if representation in "mov": file = fhead + "baked.mov" - path = os.path.join(staging_dir, file).replace("\\", "/") + path = os.path.join(stagingDir, file).replace("\\", "/") self.log.debug("Path: {}".format(path)) instance.data["baked_colorspace_movie"] = path write_node["file"].setValue(path) @@ -158,7 +158,7 @@ class ExtractDataForReview(pype.api.Extractor): elif representation in "jpeg": file = fhead + "jpeg" - path = os.path.join(staging_dir, file).replace("\\", "/") + path = os.path.join(stagingDir, file).replace("\\", "/") instance.data["thumbnail"] = path write_node["file"].setValue(path) write_node["file_type"].setValue("jpeg") @@ -170,7 +170,17 @@ class ExtractDataForReview(pype.api.Extractor): first_frame = int(last_frame) / 2 last_frame = int(last_frame) / 2 # add into files for integration as representation - instance.data["files"].append(file) + + if "representations" not in instance.data: + instance.data["representations"] = [] + + representation = { + 'name': 'nk', + 'ext': '.nk', + 'files': file, + "stagingDir": stagingdir, + } + instance.data["representations"].append(representation) # Render frames nuke.execute(write_node.name(), int(first_frame), int(last_frame)) diff --git a/pype/plugins/nuke/publish/extract_script.py b/pype/plugins/nuke/publish/extract_script.py index f0ed438094..b54fa548a5 100644 --- a/pype/plugins/nuke/publish/extract_script.py +++ b/pype/plugins/nuke/publish/extract_script.py @@ -19,16 +19,22 @@ class ExtractScript(pype.api.Extractor): current_script = instance.context.data["currentFile"] # Define extract output file path - dir_path = self.staging_dir(instance) + stagingdir = self.staging_dir(instance) filename = "{0}".format(instance.data["name"]) - path = os.path.join(dir_path, filename) + path = os.path.join(stagingdir, filename) self.log.info("Performing extraction..") shutil.copy(current_script, path) - if "files" not in instance.data: - instance.data["files"] = list() + if "representations" not in instance.data: + instance.data["representations"] = [] - instance.data["files"].append(filename) + representation = { + 'name': 'nk', + 'ext': '.nk', + 'files': filename, + "stagingDir": stagingdir, + } + instance.data["representations"].append(representation) self.log.info("Extracted instance '%s' to: %s" % (instance.name, path)) diff --git a/pype/plugins/standalonepublish/publish/collect_context.py b/pype/plugins/standalonepublish/publish/collect_context.py index 73ae33ca18..f1a97ae7b6 100644 --- a/pype/plugins/standalonepublish/publish/collect_context.py +++ b/pype/plugins/standalonepublish/publish/collect_context.py @@ -54,7 +54,6 @@ class CollectContextDataSAPublish(pyblish.api.ContextPlugin): self.log.info("collected instance: {}".format(instance.data)) self.log.info("parsing data: {}".format(in_data)) - # instance.data["files"] = list() instance.data['destination_list'] = list() instance.data['representations'] = list() instance.data['source'] = 'standalone publisher'