From 106116ed47dba6273aca3e45218b7e3ba653f371 Mon Sep 17 00:00:00 2001 From: wikoreman Date: Thu, 26 Jul 2018 18:07:00 +0200 Subject: [PATCH 01/13] renamed for clearity --- colorbleed/plugins/maya/create/colorbleed_vrayscene.py | 0 colorbleed/plugins/maya/publish/collect_vray_scene.py | 0 .../maya/publish/{submit_deadline.py => submit_maya_deadline.py} | 0 colorbleed/plugins/maya/publish/submit_vray_deadline.py | 0 4 files changed, 0 insertions(+), 0 deletions(-) create mode 100644 colorbleed/plugins/maya/create/colorbleed_vrayscene.py create mode 100644 colorbleed/plugins/maya/publish/collect_vray_scene.py rename colorbleed/plugins/maya/publish/{submit_deadline.py => submit_maya_deadline.py} (100%) create mode 100644 colorbleed/plugins/maya/publish/submit_vray_deadline.py diff --git a/colorbleed/plugins/maya/create/colorbleed_vrayscene.py b/colorbleed/plugins/maya/create/colorbleed_vrayscene.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/colorbleed/plugins/maya/publish/collect_vray_scene.py b/colorbleed/plugins/maya/publish/collect_vray_scene.py new file mode 100644 index 0000000000..e69de29bb2 diff --git a/colorbleed/plugins/maya/publish/submit_deadline.py b/colorbleed/plugins/maya/publish/submit_maya_deadline.py similarity index 100% rename from colorbleed/plugins/maya/publish/submit_deadline.py rename to colorbleed/plugins/maya/publish/submit_maya_deadline.py diff --git a/colorbleed/plugins/maya/publish/submit_vray_deadline.py b/colorbleed/plugins/maya/publish/submit_vray_deadline.py new file mode 100644 index 0000000000..e69de29bb2 From 257e61d7690554b45dec61a2ec545a718646f80e Mon Sep 17 00:00:00 2001 From: wikoreman Date: Thu, 26 Jul 2018 18:07:23 +0200 Subject: [PATCH 02/13] added submit vray to deadline logic --- .../maya/publish/submit_vray_deadline.py | 212 ++++++++++++++++++ 1 file changed, 212 insertions(+) diff --git a/colorbleed/plugins/maya/publish/submit_vray_deadline.py b/colorbleed/plugins/maya/publish/submit_vray_deadline.py index e69de29bb2..ac2a005694 100644 --- a/colorbleed/plugins/maya/publish/submit_vray_deadline.py +++ b/colorbleed/plugins/maya/publish/submit_vray_deadline.py @@ -0,0 +1,212 @@ +import getpass +import json +import os +from copy import deepcopy + +import pyblish.api + +from avalon import api +from avalon.vendor import requests + +from maya import cmds + + +class VraySubmitDeadline(pyblish.api.InstancePlugin): + """""" + label = "Submit to Deadline ( vrscene )" + order = pyblish.api.IntegratorOrder + hosts = ["maya"] + families = ["colorbleed.vrayscene"] + + def process(self, instance): + + AVALON_DEADLINE = api.Session.get("AVALON_DEADLINE", + "http://localhost:8082") + assert AVALON_DEADLINE, "Requires AVALON_DEADLINE" + + context = instance.context + + deadline_url = context.data["deadlineUrl"] + deadline_user = context.data.get("deadlineUser", getpass.getuser()) + + filepath = context.data["currentFile"] + filename = os.path.basename(filepath) + task_name = "{} - {}".format(filename, instance.name) + + batch_name = "VRay Scene Export - {}".format(filename) + + output_filepath = context.data["outputFilePath"].replace("\\", "/") + + # This is also the input file for the render job + first_file = self.format_output_filename_zero(instance, filename) + + # Primary job + self.log.info("Submitting export job ..") + + payload = { + "JobInfo": { + # Top-level group name + "BatchName": batch_name, + + # Job name, as seen in Monitor + "Name": task_name, + + # Arbitrary username, for visualisation in Monitor + "UserName": deadline_user, + + "Plugin": "MayaCmd", + "Frames": "1", + + "Comment": context.data.get("comment", ""), + "Whitelist": "cb7" + }, + "PluginInfo": { + + # Mandatory for Deadline + "Version": cmds.about(version=True), + + # Input + "SceneFile": filepath, + + # Output directory and filename + "OutputFilePath": output_filepath, + + "CommandLineOptions": self.build_command(instance), + + "UseOnlyCommandLineOptions": True, + + "SkipExistingFrames": True, + }, + + # Mandatory for Deadline, may be empty + "AuxFiles": [] + } + + environment = dict(AVALON_TOOLS="global;python36;maya2018") + + jobinfo_environment = self.build_jobinfo_environment(environment) + + payload["JobInfo"].update(jobinfo_environment) + + self.log.info("Job Data:\n{}".format(json.dumps(payload))) + + response = requests.post(url=deadline_url, json=payload) + if not response.ok: + raise RuntimeError(response.text) + + # Secondary job + # Store job to create dependency chain + dependency = response.json() + + self.log.info("Submitting render job ..") + + start_frame = int(instance.data["startFrame"]) + end_frame = int(instance.data["endFrame"]) + + payload_b = { + "JobInfo": { + + "JobDependency0": dependency["_id"], + "BatchName": batch_name, + "Name": "Render {}".format(task_name), + "UserName": deadline_user, + + "Frames": "{}-{}".format(start_frame, end_frame), + + "Plugin": "Vray", + "OverrideTaskExtraInfoNames": False, + "Whitelist": "cb7" + }, + "PluginInfo": { + + "InputFilename": first_file, + "Threads": 0, + "OutputFilename": "", + "SeparateFilesPerFrame": True, + "VRayEngine": "V-Ray", + + "Width": instance.data["resolution"][0], + "Height": instance.data["resolution"][1], + + }, + "AuxFiles": [], + } + + tools = environment["AVALON_TOOLS"] + ";vrayrenderslave" + environment_b = deepcopy(environment) + environment_b["AVALON_TOOLS"] = tools + + jobinfo_environment_b = self.build_jobinfo_environment(environment_b) + payload_b["JobInfo"].update(jobinfo_environment_b) + + self.log.info(json.dumps(payload_b)) + + response_b = requests.post(url=deadline_url, json=payload_b) + if not response_b.ok: + raise RuntimeError(response_b.text) + + print(response_b.text) + + def build_command(self, instance): + """Create command for Render.exe to export vray scene + + Returns: + str + + """ + + cmd = ('-r vray -proj {project} -cam {cam} -noRender -s {startFrame} ' + '-e {endFrame} -rl {layer} -exportFramesSeparate') + + return cmd.format(project=instance.context.data["workspaceDir"], + cam=instance.data.get("cam", "persp"), + startFrame=instance.data["startFrame"], + endFrame=instance.data["endFrame"], + layer=instance.name) + + def build_jobinfo_environment(self, env): + """Format environment keys and values to match Deadline rquirements + + Returns: + dict + + """ + return {"EnvironmentKeyValue%d" % index: "%s=%s" % (k, env[k]) + for index, k in enumerate(env)} + + def format_output_filename_zero(self, instance, filename): + """Format the expected output file of the Export job + + Example: + //_ + shot010 + + Args: + instance: + filename(str): + + Returns: + str + """ + + def smart_replace(string, key_values): + new_string = string + for key, value in key_values.items(): + new_string = new_string.replace(key, value) + return new_string + + # Ensure filename has no extension + file_name, _ = os.path.splitext(filename) + output_filename = instance.context.data["outputFilePath"] + + # Reformat without tokens + output_path = smart_replace(output_filename, + {"": file_name, + "": instance.name}) + + start_frame = int(instance.data["startFrame"]) + filename_zero = "{}_{:04d}.vrscene".format(output_path, start_frame) + + result = filename_zero.replace("\\", "/") + + return result From 85f28aefb904a4ab75d13831255de3e7c89e73c9 Mon Sep 17 00:00:00 2001 From: wikoreman Date: Thu, 26 Jul 2018 18:07:44 +0200 Subject: [PATCH 03/13] added vrayscene plugin --- .../maya/create/colorbleed_vrayscene.py | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) diff --git a/colorbleed/plugins/maya/create/colorbleed_vrayscene.py b/colorbleed/plugins/maya/create/colorbleed_vrayscene.py index e69de29bb2..0f84db8971 100644 --- a/colorbleed/plugins/maya/create/colorbleed_vrayscene.py +++ b/colorbleed/plugins/maya/create/colorbleed_vrayscene.py @@ -0,0 +1,30 @@ +from collections import OrderedDict + +import avalon.maya + + +class CreateVRayScene(avalon.maya.Creator): + + label = "VRay Scene" + family = "colorbleed.vrayscene" + # icon = "blocks" + + def __init__(self, *args, **kwargs): + super(CreateVRayScene, self).__init__(*args, **kwargs) + + # We won't be publishing this one + self.data["id"] = "avalon.vrayscene" + + # We don't need subset or asset attributes + self.data.pop("subset", None) + self.data.pop("asset", None) + self.data.pop("active", None) + + data = OrderedDict(**self.data) + + data["camera"] = "persp" + data["pools"] = "" + + self.data = data + + self.options = {"useSelection": False} # Force no content From e20f0ac009573826aed92e4bb34b2fcd68919112 Mon Sep 17 00:00:00 2001 From: wikoreman Date: Thu, 26 Jul 2018 18:08:04 +0200 Subject: [PATCH 04/13] added vray scene collector --- .../maya/publish/collect_vray_scene.py | 95 +++++++++++++++++++ 1 file changed, 95 insertions(+) diff --git a/colorbleed/plugins/maya/publish/collect_vray_scene.py b/colorbleed/plugins/maya/publish/collect_vray_scene.py index e69de29bb2..f99a1a8e86 100644 --- a/colorbleed/plugins/maya/publish/collect_vray_scene.py +++ b/colorbleed/plugins/maya/publish/collect_vray_scene.py @@ -0,0 +1,95 @@ +import os + +import pyblish.api + +from avalon import api, maya + +from maya import cmds + + +class CollectVRayScene(pyblish.api.ContextPlugin): + + order = pyblish.api.CollectorOrder + label = "Collect VRay Scene" + hosts = ["maya"] + + def process(self, context): + + asset = api.Session["AVALON_ASSET"] + + AVALON_DEADLINE = api.Session.get("AVALON_DEADLINE", None) + assert AVALON_DEADLINE, "Can't submit without Deadline connection!" + + context.data["deadlineUrl"] = "{}/api/jobs".format(AVALON_DEADLINE) + + # Create output file path with template + file_name = context.data["currentFile"].replace("\\", "/") + output_filepath = os.path.join(context.data["workspaceDir"], + "vrayscene", + "", + "", + "_") + + context.data["outputFilePath"] = output_filepath + + # Get VRay Scene instance + vray_scenes = maya.lsattr("family", "colorbleed.vrayscene") + if not vray_scenes: + self.log.info("No instance found of family: `colorbleed.vrayscene`") + return + + assert len(vray_scenes) == 1, "Multiple vrayscene instances found!" + vray_scene = vray_scenes[0] + + camera = cmds.getAttr("{}.camera".format(vray_scene)) or "persp" + + # Animation data + start_frame = cmds.getAttr("defaultRenderGlobals.startFrame") + end_frame = cmds.getAttr("defaultRenderGlobals.endFrame") + context.data["startFrame"] = int(start_frame) + context.data["endFrame"] = int(end_frame) + + # Get render layers + renderlayers = [i for i in cmds.ls(type="renderLayer") if + cmds.getAttr("{}.renderable".format(i)) and not + cmds.referenceQuery(i, isNodeReferenced=True)] + + # Sort by displayOrder + def sort_by_display_order(layer): + return cmds.getAttr("%s.displayOrder" % layer) + + renderlayers = sorted(renderlayers, key=sort_by_display_order) + + resolution = (cmds.getAttr("defaultResolution.width"), + cmds.getAttr("defaultResolution.height")) + + for layer in renderlayers: + + if layer.endswith("defaultRenderLayer"): + layer = "masterLayer" + + data = { + "subset": layer, + "setMembers": layer, + + "camera": camera, + "startFrame": start_frame, + "endFrame": end_frame, + "renderer": "vray", + "resolution": resolution, + + # instance subset + "family": "VRay Scene", + "families": ["colorbleed.vrayscene"], + "asset": asset, + "time": api.time(), + "author": context.data["user"], + + # Add source to allow tracing back to the scene from + # which was submitted originally + "source": file_name + } + + instance = context.create_instance(layer) + self.log.info("Created: %s" % instance.name) + instance.data.update(data) From b1fdec440bc784d806b429ad18e692aa3a7e656b Mon Sep 17 00:00:00 2001 From: wikoreman Date: Thu, 26 Jul 2018 18:09:11 +0200 Subject: [PATCH 05/13] removed debug whitelist --- colorbleed/plugins/maya/publish/submit_vray_deadline.py | 1 - 1 file changed, 1 deletion(-) diff --git a/colorbleed/plugins/maya/publish/submit_vray_deadline.py b/colorbleed/plugins/maya/publish/submit_vray_deadline.py index ac2a005694..d1fbe3efab 100644 --- a/colorbleed/plugins/maya/publish/submit_vray_deadline.py +++ b/colorbleed/plugins/maya/publish/submit_vray_deadline.py @@ -58,7 +58,6 @@ class VraySubmitDeadline(pyblish.api.InstancePlugin): "Frames": "1", "Comment": context.data.get("comment", ""), - "Whitelist": "cb7" }, "PluginInfo": { From 84236373e926c9a5f64d172c98d0e0c9c11f233d Mon Sep 17 00:00:00 2001 From: wikoreman Date: Fri, 27 Jul 2018 13:14:59 +0200 Subject: [PATCH 06/13] added validator for translator settings --- .../publish/validate_translator_settings.py | 45 +++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 colorbleed/plugins/maya/publish/validate_translator_settings.py diff --git a/colorbleed/plugins/maya/publish/validate_translator_settings.py b/colorbleed/plugins/maya/publish/validate_translator_settings.py new file mode 100644 index 0000000000..7c7479792c --- /dev/null +++ b/colorbleed/plugins/maya/publish/validate_translator_settings.py @@ -0,0 +1,45 @@ +import pyblish.api +import colorbleed.api + +from maya import cmds + + +class ValidateTranslatorEnabled(pyblish.api.ContextPlugin): + + order = colorbleed.api.ValidateContentsOrder + label = "VRay Translator Settings" + families = ["colorbleed.vrayscene"] + actions = [colorbleed.api.RepairContextAction] + + def process(self, context): + + # Get vraySettings node + vray_settings = cmds.ls(type="VRaySettingsNode") + assert vray_settings, "Please ensure a VRay Settings Node is present" + + node = vray_settings[0] + + if not cmds.getAttr("{}.vrscene_on".format(node)): + self.info.error("Export vrscene not enabled") + + if not cmds.getAttr("{}.misc_eachFrameInFile".format(node)): + self.info.error("Each Frame in File not enabled") + + vrscene_filename = cmds.getAttr("{}.vrscene_filename".format(node)) + if vrscene_filename != "vrayscene//_/": + self.info.error("Template for file name is wrong") + + @classmethod + def repair(cls, context): + + vray_settings = cmds.ls(type="VRaySettingsNode") + if not vray_settings: + node = cmds.createNode("VRaySettingsNode") + else: + node = vray_settings[0] + + cmds.setAttr("{}.vrscene_on".format(node), True) + cmds.setAttr("{}.misc_eachFrameInFile".format(node), True) + cmds.setAttr("{}.vrscene_filename".format(node), + "vrayscene//_/", + type="string") From 5d6c355b45c7072ab2f767cab78f317c1a4eed61 Mon Sep 17 00:00:00 2001 From: wikoreman Date: Fri, 27 Jul 2018 13:16:15 +0200 Subject: [PATCH 07/13] added colorbleed.vrayscene to plugin --- .../plugins/global/publish/submit_publish_job.py | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/colorbleed/plugins/global/publish/submit_publish_job.py b/colorbleed/plugins/global/publish/submit_publish_job.py index 34a09c9b81..5cbba4f800 100644 --- a/colorbleed/plugins/global/publish/submit_publish_job.py +++ b/colorbleed/plugins/global/publish/submit_publish_job.py @@ -123,7 +123,9 @@ class SubmitDependentImageSequenceJobDeadline(pyblish.api.InstancePlugin): label = "Submit image sequence jobs to Deadline" order = pyblish.api.IntegratorOrder + 0.1 hosts = ["fusion", "maya"] - families = ["colorbleed.saver.deadline", "colorbleed.renderlayer"] + families = ["colorbleed.saver.deadline", + "colorbleed.renderlayer", + "colorbleed.vrayscene"] def process(self, instance): @@ -162,8 +164,10 @@ class SubmitDependentImageSequenceJobDeadline(pyblish.api.InstancePlugin): regex = "^{subset}.*\d+{ext}$".format(subset=re.escape(subset), ext=ext) + # Remove deadline submission job, not needed in metadata + data.pop("deadlineSubmissionJob") + # Write metadata for publish job - render_job = data.pop("deadlineSubmissionJob") metadata = { "regex": regex, "startFrame": start, @@ -189,7 +193,7 @@ class SubmitDependentImageSequenceJobDeadline(pyblish.api.InstancePlugin): override = data["overrideExistingFrame"] # override = data.get("overrideExistingFrame", False) - out_file = render_job.get("OutFile") + out_file = job.get("OutFile") if not out_file: raise RuntimeError("OutFile not found in render job!") From ad55a128585964f1ba9fe3a046c0617b8b952d39 Mon Sep 17 00:00:00 2001 From: wikoreman Date: Fri, 27 Jul 2018 13:16:44 +0200 Subject: [PATCH 08/13] Extended options for vrayscene instance --- .../maya/create/colorbleed_vrayscene.py | 4 + .../maya/publish/collect_vray_scene.py | 74 +++++++++++-------- .../maya/publish/submit_vray_deadline.py | 58 ++++++++++++--- 3 files changed, 93 insertions(+), 43 deletions(-) diff --git a/colorbleed/plugins/maya/create/colorbleed_vrayscene.py b/colorbleed/plugins/maya/create/colorbleed_vrayscene.py index 0f84db8971..e30f4ac3ce 100644 --- a/colorbleed/plugins/maya/create/colorbleed_vrayscene.py +++ b/colorbleed/plugins/maya/create/colorbleed_vrayscene.py @@ -23,6 +23,10 @@ class CreateVRayScene(avalon.maya.Creator): data = OrderedDict(**self.data) data["camera"] = "persp" + data["suspendRenderJob"] = False + data["suspendPublishJob"] = False + data["includeDefaultRenderLayer"] = False + data["extendFrames"] = False data["pools"] = "" self.data = data diff --git a/colorbleed/plugins/maya/publish/collect_vray_scene.py b/colorbleed/plugins/maya/publish/collect_vray_scene.py index f99a1a8e86..6ecb07f123 100644 --- a/colorbleed/plugins/maya/publish/collect_vray_scene.py +++ b/colorbleed/plugins/maya/publish/collect_vray_scene.py @@ -8,6 +8,8 @@ from maya import cmds class CollectVRayScene(pyblish.api.ContextPlugin): + """Collect all information prior for exporting vrscenes + """ order = pyblish.api.CollectorOrder label = "Collect VRay Scene" @@ -15,22 +17,12 @@ class CollectVRayScene(pyblish.api.ContextPlugin): def process(self, context): + # Sort by displayOrder + def sort_by_display_order(layer): + return cmds.getAttr("%s.displayOrder" % layer) + asset = api.Session["AVALON_ASSET"] - - AVALON_DEADLINE = api.Session.get("AVALON_DEADLINE", None) - assert AVALON_DEADLINE, "Can't submit without Deadline connection!" - - context.data["deadlineUrl"] = "{}/api/jobs".format(AVALON_DEADLINE) - - # Create output file path with template - file_name = context.data["currentFile"].replace("\\", "/") - output_filepath = os.path.join(context.data["workspaceDir"], - "vrayscene", - "", - "", - "_") - - context.data["outputFilePath"] = output_filepath + work_dir = context.data["workspaceDir"] # Get VRay Scene instance vray_scenes = maya.lsattr("family", "colorbleed.vrayscene") @@ -41,29 +33,48 @@ class CollectVRayScene(pyblish.api.ContextPlugin): assert len(vray_scenes) == 1, "Multiple vrayscene instances found!" vray_scene = vray_scenes[0] - camera = cmds.getAttr("{}.camera".format(vray_scene)) or "persp" + vrscene_data = {k: cmds.getAttr("%s.%s" % (vray_scene, k)) for + k in cmds.listAttr(vray_scene, userDefined=True)} - # Animation data - start_frame = cmds.getAttr("defaultRenderGlobals.startFrame") - end_frame = cmds.getAttr("defaultRenderGlobals.endFrame") - context.data["startFrame"] = int(start_frame) - context.data["endFrame"] = int(end_frame) + # Output data + start_frame = int(cmds.getAttr("defaultRenderGlobals.startFrame")) + end_frame = int(cmds.getAttr("defaultRenderGlobals.endFrame")) - # Get render layers - renderlayers = [i for i in cmds.ls(type="renderLayer") if - cmds.getAttr("{}.renderable".format(i)) and not - cmds.referenceQuery(i, isNodeReferenced=True)] + # Create output file path with template + file_name = context.data["currentFile"].replace("\\", "/") + vrscene = ("vrayscene", "", "_", "") + vrscene_output = os.path.join(work_dir, *vrscene) - # Sort by displayOrder - def sort_by_display_order(layer): - return cmds.getAttr("%s.displayOrder" % layer) + vrscene_data["startFrame"] = start_frame + vrscene_data["endFrame"] = end_frame + vrscene_data["vrsceneOutput"] = vrscene_output - renderlayers = sorted(renderlayers, key=sort_by_display_order) + context.data["startFrame"] = start_frame + context.data["endFrame"] = end_frame + # Check and create render output template for render job + # outputDir is required for submit_publish_job + if not vrscene_data.get("suspendRenderJob", False): + renders = ("renders", "", "_", "") + output_renderpath = os.path.join(work_dir, *renders) + vrscene_data["outputDir"] = output_renderpath + + # Get resolution resolution = (cmds.getAttr("defaultResolution.width"), cmds.getAttr("defaultResolution.height")) - for layer in renderlayers: + # Get render layers + render_layers = [i for i in cmds.ls(type="renderLayer") if + cmds.getAttr("{}.renderable".format(i)) and not + cmds.referenceQuery(i, isNodeReferenced=True)] + + # Check if we need to filter out the default render layer + if vrscene_data.get("includeDefaultRenderLayer", True): + render_layers = [r for r in render_layers + if r != "defaultRenderLayer"] + + render_layers = sorted(render_layers, key=sort_by_display_order) + for layer in render_layers: if layer.endswith("defaultRenderLayer"): layer = "masterLayer" @@ -72,7 +83,6 @@ class CollectVRayScene(pyblish.api.ContextPlugin): "subset": layer, "setMembers": layer, - "camera": camera, "startFrame": start_frame, "endFrame": end_frame, "renderer": "vray", @@ -90,6 +100,8 @@ class CollectVRayScene(pyblish.api.ContextPlugin): "source": file_name } + data.update(vrscene_data) + instance = context.create_instance(layer) self.log.info("Created: %s" % instance.name) instance.data.update(data) diff --git a/colorbleed/plugins/maya/publish/submit_vray_deadline.py b/colorbleed/plugins/maya/publish/submit_vray_deadline.py index d1fbe3efab..77cb8f2ec6 100644 --- a/colorbleed/plugins/maya/publish/submit_vray_deadline.py +++ b/colorbleed/plugins/maya/publish/submit_vray_deadline.py @@ -12,7 +12,15 @@ from maya import cmds class VraySubmitDeadline(pyblish.api.InstancePlugin): - """""" + """Export the scene to `.vrscene` files per frame per render layer + + vrscene files will be written out based on the following template: + /vrayscene//_/ + + A dependency job will be added for each layer to render the framer + through VRay Standalone + + """ label = "Submit to Deadline ( vrscene )" order = pyblish.api.IntegratorOrder hosts = ["maya"] @@ -26,7 +34,7 @@ class VraySubmitDeadline(pyblish.api.InstancePlugin): context = instance.context - deadline_url = context.data["deadlineUrl"] + deadline_url = "{}/api/jobs".format(AVALON_DEADLINE) deadline_user = context.data.get("deadlineUser", getpass.getuser()) filepath = context.data["currentFile"] @@ -35,10 +43,13 @@ class VraySubmitDeadline(pyblish.api.InstancePlugin): batch_name = "VRay Scene Export - {}".format(filename) - output_filepath = context.data["outputFilePath"].replace("\\", "/") + # Get the output template for vrscenes + vrscene_output = instance.data["vrsceneOutput"] # This is also the input file for the render job - first_file = self.format_output_filename_zero(instance, filename) + first_file = self.format_output_filename(instance, + filename, + vrscene_output) # Primary job self.log.info("Submitting export job ..") @@ -68,7 +79,7 @@ class VraySubmitDeadline(pyblish.api.InstancePlugin): "SceneFile": filepath, # Output directory and filename - "OutputFilePath": output_filepath, + "OutputFilePath": vrscene_output.replace("\\", "/"), "CommandLineOptions": self.build_command(instance), @@ -97,11 +108,26 @@ class VraySubmitDeadline(pyblish.api.InstancePlugin): # Store job to create dependency chain dependency = response.json() + if instance.data["suspendRenderJob"]: + self.log.info("Skipping render job and publish job") + return + self.log.info("Submitting render job ..") start_frame = int(instance.data["startFrame"]) end_frame = int(instance.data["endFrame"]) + # Create output directory for renders + render_ouput = self.format_output_filename(instance, + filename, + instance.data["outputDir"], + dir=True) + + self.log.info("Render output: %s" % render_ouput) + + # Update output dir + instance.data["outputDir"] = render_ouput + payload_b = { "JobInfo": { @@ -120,7 +146,7 @@ class VraySubmitDeadline(pyblish.api.InstancePlugin): "InputFilename": first_file, "Threads": 0, - "OutputFilename": "", + "OutputFilename": render_ouput, "SeparateFilesPerFrame": True, "VRayEngine": "V-Ray", @@ -131,6 +157,7 @@ class VraySubmitDeadline(pyblish.api.InstancePlugin): "AuxFiles": [], } + # Add vray renderslave to environment tools = environment["AVALON_TOOLS"] + ";vrayrenderslave" environment_b = deepcopy(environment) environment_b["AVALON_TOOLS"] = tools @@ -140,11 +167,14 @@ class VraySubmitDeadline(pyblish.api.InstancePlugin): self.log.info(json.dumps(payload_b)) + # Post job to deadline response_b = requests.post(url=deadline_url, json=payload_b) if not response_b.ok: raise RuntimeError(response_b.text) - print(response_b.text) + # Add job for publish job + if not instance.data.get("suspendPublishJob", False): + instance.data["deadlineSubmissionJob"] = response_b.json() def build_command(self, instance): """Create command for Render.exe to export vray scene @@ -173,19 +203,21 @@ class VraySubmitDeadline(pyblish.api.InstancePlugin): return {"EnvironmentKeyValue%d" % index: "%s=%s" % (k, env[k]) for index, k in enumerate(env)} - def format_output_filename_zero(self, instance, filename): + def format_output_filename(self, instance, filename, template, dir=False): """Format the expected output file of the Export job Example: - //_ - shot010 + /_/ + "shot010_v006/shot010_v006_CHARS/CHARS" Args: instance: filename(str): + dir(bool): Returns: str + """ def smart_replace(string, key_values): @@ -196,13 +228,15 @@ class VraySubmitDeadline(pyblish.api.InstancePlugin): # Ensure filename has no extension file_name, _ = os.path.splitext(filename) - output_filename = instance.context.data["outputFilePath"] # Reformat without tokens - output_path = smart_replace(output_filename, + output_path = smart_replace(template, {"": file_name, "": instance.name}) + if dir: + return output_path.replace("\\", "/") + start_frame = int(instance.data["startFrame"]) filename_zero = "{}_{:04d}.vrscene".format(output_path, start_frame) From 72ceefc5484458ac3ca6faeef7da13c4592d94fb Mon Sep 17 00:00:00 2001 From: wikoreman Date: Fri, 27 Jul 2018 18:10:59 +0200 Subject: [PATCH 09/13] Don't throw errors, not needed --- colorbleed/plugins/global/publish/submit_publish_job.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/colorbleed/plugins/global/publish/submit_publish_job.py b/colorbleed/plugins/global/publish/submit_publish_job.py index 5cbba4f800..ca5e186825 100644 --- a/colorbleed/plugins/global/publish/submit_publish_job.py +++ b/colorbleed/plugins/global/publish/submit_publish_job.py @@ -136,8 +136,10 @@ class SubmitDependentImageSequenceJobDeadline(pyblish.api.InstancePlugin): # Get a submission job job = instance.data.get("deadlineSubmissionJob") if not job: - raise RuntimeError("Can't continue without valid deadline " - "submission prior to this plug-in.") + self.log.warning("Can't continue without valid deadline " + "submission prior to this plug-in.") + self.log.info("Skipping Publish Job") + return data = instance.data.copy() subset = data["subset"] @@ -162,7 +164,7 @@ class SubmitDependentImageSequenceJobDeadline(pyblish.api.InstancePlugin): ext = "\.\D+" regex = "^{subset}.*\d+{ext}$".format(subset=re.escape(subset), - ext=ext) + ext=re.escape(subset)) # Remove deadline submission job, not needed in metadata data.pop("deadlineSubmissionJob") From ccf36bffb3289ae3b935937aa9fbe310316a841c Mon Sep 17 00:00:00 2001 From: wikoreman Date: Fri, 27 Jul 2018 18:11:25 +0200 Subject: [PATCH 10/13] Added extension and fixed outputfilename --- colorbleed/plugins/maya/publish/collect_vray_scene.py | 4 ++++ colorbleed/plugins/maya/publish/submit_vray_deadline.py | 9 +++++++-- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/colorbleed/plugins/maya/publish/collect_vray_scene.py b/colorbleed/plugins/maya/publish/collect_vray_scene.py index 6ecb07f123..cedd527106 100644 --- a/colorbleed/plugins/maya/publish/collect_vray_scene.py +++ b/colorbleed/plugins/maya/publish/collect_vray_scene.py @@ -63,6 +63,9 @@ class CollectVRayScene(pyblish.api.ContextPlugin): resolution = (cmds.getAttr("defaultResolution.width"), cmds.getAttr("defaultResolution.height")) + # Get format extension + extension = cmds.getAttr("vraySettings.imageFormatStr") + # Get render layers render_layers = [i for i in cmds.ls(type="renderLayer") if cmds.getAttr("{}.renderable".format(i)) and not @@ -87,6 +90,7 @@ class CollectVRayScene(pyblish.api.ContextPlugin): "endFrame": end_frame, "renderer": "vray", "resolution": resolution, + "ext": extension, # instance subset "family": "VRay Scene", diff --git a/colorbleed/plugins/maya/publish/submit_vray_deadline.py b/colorbleed/plugins/maya/publish/submit_vray_deadline.py index 77cb8f2ec6..925013c693 100644 --- a/colorbleed/plugins/maya/publish/submit_vray_deadline.py +++ b/colorbleed/plugins/maya/publish/submit_vray_deadline.py @@ -77,7 +77,6 @@ class VraySubmitDeadline(pyblish.api.InstancePlugin): # Input "SceneFile": filepath, - # Output directory and filename "OutputFilePath": vrscene_output.replace("\\", "/"), @@ -93,6 +92,7 @@ class VraySubmitDeadline(pyblish.api.InstancePlugin): } environment = dict(AVALON_TOOLS="global;python36;maya2018") + environment.update(api.Session.copy()) jobinfo_environment = self.build_jobinfo_environment(environment) @@ -116,6 +116,7 @@ class VraySubmitDeadline(pyblish.api.InstancePlugin): start_frame = int(instance.data["startFrame"]) end_frame = int(instance.data["endFrame"]) + ext = instance.data.get("ext", "exr") # Create output directory for renders render_ouput = self.format_output_filename(instance, @@ -128,6 +129,10 @@ class VraySubmitDeadline(pyblish.api.InstancePlugin): # Update output dir instance.data["outputDir"] = render_ouput + # Format output file name + sequence_fiename = ".".join([instance.name, "%04d", ext]) + output_filename = os.path.join(render_ouput, sequence_fiename) + payload_b = { "JobInfo": { @@ -146,7 +151,7 @@ class VraySubmitDeadline(pyblish.api.InstancePlugin): "InputFilename": first_file, "Threads": 0, - "OutputFilename": render_ouput, + "OutputFilename": output_filename, "SeparateFilesPerFrame": True, "VRayEngine": "V-Ray", From be668ac27ab5250f8af18af84270af72162cbb0b Mon Sep 17 00:00:00 2001 From: wikoreman Date: Mon, 30 Jul 2018 09:48:44 +0200 Subject: [PATCH 11/13] reverting unwanted change --- colorbleed/plugins/global/publish/submit_publish_job.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/colorbleed/plugins/global/publish/submit_publish_job.py b/colorbleed/plugins/global/publish/submit_publish_job.py index ca5e186825..1c77d5c845 100644 --- a/colorbleed/plugins/global/publish/submit_publish_job.py +++ b/colorbleed/plugins/global/publish/submit_publish_job.py @@ -164,7 +164,7 @@ class SubmitDependentImageSequenceJobDeadline(pyblish.api.InstancePlugin): ext = "\.\D+" regex = "^{subset}.*\d+{ext}$".format(subset=re.escape(subset), - ext=re.escape(subset)) + ext=re.escape(ext)) # Remove deadline submission job, not needed in metadata data.pop("deadlineSubmissionJob") From c16013beec3d2bafc47b6dbf4bc8cede551649a4 Mon Sep 17 00:00:00 2001 From: wikoreman Date: Mon, 30 Jul 2018 12:00:02 +0200 Subject: [PATCH 12/13] include the '.' in the regex --- colorbleed/plugins/global/publish/submit_publish_job.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/colorbleed/plugins/global/publish/submit_publish_job.py b/colorbleed/plugins/global/publish/submit_publish_job.py index 1c77d5c845..184ed0b43d 100644 --- a/colorbleed/plugins/global/publish/submit_publish_job.py +++ b/colorbleed/plugins/global/publish/submit_publish_job.py @@ -159,12 +159,12 @@ class SubmitDependentImageSequenceJobDeadline(pyblish.api.InstancePlugin): # This assumes the output files start with subset name and ends with # a file extension. if "ext" in instance.data: - ext = re.escape(instance.data["ext"]) + ext = instance.data["ext"].strip(".") else: ext = "\.\D+" - regex = "^{subset}.*\d+{ext}$".format(subset=re.escape(subset), - ext=re.escape(ext)) + regex = "^{subset}.*\d+\.{ext}$".format(subset=re.escape(subset), + ext=re.escape(ext)) # Remove deadline submission job, not needed in metadata data.pop("deadlineSubmissionJob") From 5f6c0b9e574c18c9b69ce318ac1a3aa0d3b0b433 Mon Sep 17 00:00:00 2001 From: wikoreman Date: Mon, 30 Jul 2018 12:27:00 +0200 Subject: [PATCH 13/13] Fix typo --- colorbleed/plugins/maya/publish/submit_vray_deadline.py | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/colorbleed/plugins/maya/publish/submit_vray_deadline.py b/colorbleed/plugins/maya/publish/submit_vray_deadline.py index 925013c693..97c26497f8 100644 --- a/colorbleed/plugins/maya/publish/submit_vray_deadline.py +++ b/colorbleed/plugins/maya/publish/submit_vray_deadline.py @@ -130,8 +130,8 @@ class VraySubmitDeadline(pyblish.api.InstancePlugin): instance.data["outputDir"] = render_ouput # Format output file name - sequence_fiename = ".".join([instance.name, "%04d", ext]) - output_filename = os.path.join(render_ouput, sequence_fiename) + sequence_filename = ".".join([instance.name, "%04d", ext]) + output_filename = os.path.join(render_ouput, sequence_filename) payload_b = { "JobInfo": { @@ -150,7 +150,6 @@ class VraySubmitDeadline(pyblish.api.InstancePlugin): "PluginInfo": { "InputFilename": first_file, - "Threads": 0, "OutputFilename": output_filename, "SeparateFilesPerFrame": True, "VRayEngine": "V-Ray",