mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-03 09:24:57 +01:00
More draft refactoring - still not functional (WIP commit for my own sanity)
This commit is contained in:
parent
65d785d100
commit
0f95f87d77
1 changed files with 35 additions and 150 deletions
|
|
@ -31,7 +31,6 @@ import clique
|
|||
|
||||
from maya import cmds
|
||||
|
||||
from openpype.hosts.maya.api import lib
|
||||
from openpype.pipeline import legacy_io
|
||||
|
||||
from openpype_modules.deadline import abstract_submit_deadline
|
||||
|
|
@ -87,11 +86,15 @@ class MayaSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline):
|
|||
instance = self._instance
|
||||
context = instance.context
|
||||
|
||||
filepath = context.data["currentFile"]
|
||||
filename = os.path.basename(filepath)
|
||||
# Always use the original work file name for the Job name even when
|
||||
# rendering is done from the published Work File. The original work
|
||||
# file name is clearer because it can also have subversion strings,
|
||||
# etc. which are stripped for the published file.
|
||||
src_filepath = context.data["currentFile"]
|
||||
src_filename = os.path.basename(src_filepath)
|
||||
|
||||
job_info.Name = "%s - %s" % (filename, instance.name)
|
||||
job_info.BatchName = filename
|
||||
job_info.Name = "%s - %s" % (src_filename, instance.name)
|
||||
job_info.BatchName = src_filename
|
||||
job_info.Plugin = instance.data.get("mayaRenderPlugin", "MayaBatch")
|
||||
job_info.UserName = context.data.get(
|
||||
"deadlineUser", getpass.getuser())
|
||||
|
|
@ -116,9 +119,6 @@ class MayaSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline):
|
|||
if self.limit_groups:
|
||||
job_info.LimitGroups = ",".join(self.limit_groups)
|
||||
|
||||
self.payload_skeleton["JobInfo"]["Name"] = jobname
|
||||
self.payload_skeleton["JobInfo"]["BatchName"] = src_filename
|
||||
|
||||
# Optional, enable double-click to preview rendered
|
||||
# frames from Deadline Monitor
|
||||
self.payload_skeleton["JobInfo"]["OutputDirectory0"] = \
|
||||
|
|
@ -227,11 +227,17 @@ class MayaSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline):
|
|||
return attr.asdict(plugin_info)
|
||||
|
||||
def process_submission(self):
|
||||
# Override to NOT submit by default when calling super process() method
|
||||
pass
|
||||
|
||||
def process(self, instance):
|
||||
super(MayaSubmitDeadline, self).process(instance)
|
||||
instance = self._instance
|
||||
context = instance.context
|
||||
|
||||
# Generated by AbstractSubmitDeadline. The `job_info`, `plugin_info`
|
||||
# and `aux_files` are the skeleton payloads that are the basis for
|
||||
# all the maya submissions
|
||||
job_info = self.job_info
|
||||
plugin_info = self.plugin_info
|
||||
aux_files = self.aux_files
|
||||
filepath = self.scene_path # publish if `use_publish` else workfile
|
||||
|
||||
# TODO: Avoid the need for this logic here, needed for submit publish
|
||||
# Store output dir for unified publisher (filesequence)
|
||||
|
|
@ -241,21 +247,19 @@ class MayaSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline):
|
|||
|
||||
self.limit_groups = self.limit
|
||||
|
||||
context = instance.context
|
||||
workspace = context.data["workspaceDir"]
|
||||
|
||||
filepath = None
|
||||
patches = (
|
||||
context.data["project_settings"].get(
|
||||
"deadline", {}).get(
|
||||
"publish", {}).get(
|
||||
"MayaSubmitDeadline", {}).get(
|
||||
"scene_patches", {})
|
||||
)
|
||||
# Patch workfile (only when use_published is enabled)
|
||||
if self.use_published:
|
||||
patches = (
|
||||
context.data["project_settings"].get(
|
||||
"deadline", {}).get(
|
||||
"publish", {}).get(
|
||||
"MayaSubmitDeadline", {}).get(
|
||||
"scene_patches", {})
|
||||
)
|
||||
self._patch_workfile(filepath, patches)
|
||||
|
||||
# todo: on self.use_published originally use template_data["representation"] using .get("name") instead of .get("ext")
|
||||
# todo: on self.use_published replace path for publishRenderMetadataFolder
|
||||
# todo: on self.use_published apply scene patches to workfile instance
|
||||
# rep = i.data.get("representations")[0].get("name")
|
||||
|
||||
# if instance.data.get("publishRenderMetadataFolder"):
|
||||
|
|
@ -270,9 +274,8 @@ class MayaSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline):
|
|||
# patched_file = self._patch_workfile(filepath, patches)
|
||||
# patched_files.append(patched_file)
|
||||
|
||||
filepath = self.scene_path # collect by super().process
|
||||
|
||||
# Gather needed data ------------------------------------------------
|
||||
workspace = context.data["workspaceDir"]
|
||||
default_render_file = instance.context.data.get('project_settings')\
|
||||
.get('maya')\
|
||||
.get('RenderSettings')\
|
||||
|
|
@ -281,14 +284,10 @@ class MayaSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline):
|
|||
dirname = os.path.join(workspace, default_render_file)
|
||||
renderlayer = instance.data['setMembers'] # rs_beauty
|
||||
|
||||
# Always use the original work file name for the Job name even when
|
||||
# rendering is done from the published Work File. The original work
|
||||
# file name is clearer because it can also have subversion strings,
|
||||
# etc. which are stripped for the published file.
|
||||
src_filename = os.path.basename(context.data["currentFile"])
|
||||
jobname = "%s - %s" % (src_filename, instance.name)
|
||||
|
||||
# Get the variables depending on the renderer
|
||||
# TODO: Find replacement logic for `get_renderer_variables` through
|
||||
# what is collected for the render or is implemented in maya
|
||||
# api `lib_renderproducts`
|
||||
render_variables = get_renderer_variables(renderlayer, dirname)
|
||||
filename_0 = render_variables["filename_0"]
|
||||
if self.use_published:
|
||||
|
|
@ -842,8 +841,8 @@ class MayaSubmitDeadline(abstract_submit_deadline.AbstractSubmitDeadline):
|
|||
str: Patched file path or None
|
||||
|
||||
"""
|
||||
if os.path.splitext(file)[1].lower() != ".ma" or not patches:
|
||||
return None
|
||||
if not patches or os.path.splitext(file)[1].lower() != ".ma":
|
||||
return
|
||||
|
||||
compiled_regex = [re.compile(p["regex"]) for p in patches]
|
||||
with open(file, "r+") as pf:
|
||||
|
|
@ -931,7 +930,7 @@ def _format_tiles(
|
|||
os.path.basename(filename)
|
||||
)
|
||||
out["JobInfo"][out_tile_index] = new_filename
|
||||
out["PluginInfo"]["RegionPrefix{}".format(str(tile))] = \
|
||||
out["PluginInfo"]["RegionPrefix{}".format(tile)] = \
|
||||
"/{}".format(tile_prefix).join(prefix.rsplit("/", 1))
|
||||
|
||||
out["PluginInfo"]["RegionTop{}".format(tile)] = int(height) - (tile_y * h_space) # noqa: E501
|
||||
|
|
@ -951,117 +950,3 @@ def _format_tiles(
|
|||
|
||||
tile += 1
|
||||
return out, cfg
|
||||
|
||||
|
||||
def get_renderer_variables(renderlayer, root):
|
||||
"""Retrieve the extension which has been set in the VRay settings.
|
||||
|
||||
Will return None if the current renderer is not VRay
|
||||
For Maya 2016.5 and up the renderSetup creates renderSetupLayer node which
|
||||
start with `rs`. Use the actual node name, do NOT use the `nice name`
|
||||
|
||||
Args:
|
||||
renderlayer (str): the node name of the renderlayer.
|
||||
root (str): base path to render
|
||||
|
||||
Returns:
|
||||
dict
|
||||
|
||||
"""
|
||||
renderer = lib.get_renderer(renderlayer or lib.get_current_renderlayer())
|
||||
render_attrs = lib.RENDER_ATTRS.get(renderer, lib.RENDER_ATTRS["default"])
|
||||
|
||||
padding = cmds.getAttr("{}.{}".format(render_attrs["node"],
|
||||
render_attrs["padding"]))
|
||||
|
||||
filename_0 = cmds.renderSettings(
|
||||
fullPath=True,
|
||||
gin="#" * int(padding),
|
||||
lut=True,
|
||||
layer=renderlayer or lib.get_current_renderlayer())[0]
|
||||
filename_0 = re.sub('_<RenderPass>', '_beauty',
|
||||
filename_0, flags=re.IGNORECASE)
|
||||
prefix_attr = "defaultRenderGlobals.imageFilePrefix"
|
||||
|
||||
scene = cmds.file(query=True, sceneName=True)
|
||||
scene, _ = os.path.splitext(os.path.basename(scene))
|
||||
|
||||
if renderer == "vray":
|
||||
renderlayer = renderlayer.split("_")[-1]
|
||||
# Maya's renderSettings function does not return V-Ray file extension
|
||||
# so we get the extension from vraySettings
|
||||
extension = cmds.getAttr("vraySettings.imageFormatStr")
|
||||
|
||||
# When V-Ray image format has not been switched once from default .png
|
||||
# the getAttr command above returns None. As such we explicitly set
|
||||
# it to `.png`
|
||||
if extension is None:
|
||||
extension = "png"
|
||||
|
||||
if extension in ["exr (multichannel)", "exr (deep)"]:
|
||||
extension = "exr"
|
||||
|
||||
prefix_attr = "vraySettings.fileNamePrefix"
|
||||
filename_prefix = cmds.getAttr(prefix_attr)
|
||||
# we need to determine path for vray as maya `renderSettings` query
|
||||
# does not work for vray.
|
||||
|
||||
filename_0 = re.sub('<Scene>', scene, filename_prefix, flags=re.IGNORECASE) # noqa: E501
|
||||
filename_0 = re.sub('<Layer>', renderlayer, filename_0, flags=re.IGNORECASE) # noqa: E501
|
||||
filename_0 = "{}.{}.{}".format(
|
||||
filename_0, "#" * int(padding), extension)
|
||||
filename_0 = os.path.normpath(os.path.join(root, filename_0))
|
||||
elif renderer == "renderman":
|
||||
prefix_attr = "rmanGlobals.imageFileFormat"
|
||||
# NOTE: This is guessing extensions from renderman display types.
|
||||
# Some of them are just framebuffers, d_texture format can be
|
||||
# set in display setting. We set those now to None, but it
|
||||
# should be handled more gracefully.
|
||||
display_types = {
|
||||
"d_deepexr": "exr",
|
||||
"d_it": None,
|
||||
"d_null": None,
|
||||
"d_openexr": "exr",
|
||||
"d_png": "png",
|
||||
"d_pointcloud": "ptc",
|
||||
"d_targa": "tga",
|
||||
"d_texture": None,
|
||||
"d_tiff": "tif"
|
||||
}
|
||||
|
||||
extension = display_types.get(
|
||||
cmds.listConnections("rmanDefaultDisplay.displayType")[0],
|
||||
"exr"
|
||||
) or "exr"
|
||||
|
||||
filename_prefix = "{}/{}".format(
|
||||
cmds.getAttr("rmanGlobals.imageOutputDir"),
|
||||
cmds.getAttr("rmanGlobals.imageFileFormat")
|
||||
)
|
||||
|
||||
renderlayer = renderlayer.split("_")[-1]
|
||||
|
||||
filename_0 = re.sub('<scene>', scene, filename_prefix, flags=re.IGNORECASE) # noqa: E501
|
||||
filename_0 = re.sub('<layer>', renderlayer, filename_0, flags=re.IGNORECASE) # noqa: E501
|
||||
filename_0 = re.sub('<f[\\d+]>', "#" * int(padding), filename_0, flags=re.IGNORECASE) # noqa: E501
|
||||
filename_0 = re.sub('<ext>', extension, filename_0, flags=re.IGNORECASE) # noqa: E501
|
||||
filename_0 = os.path.normpath(os.path.join(root, filename_0))
|
||||
elif renderer == "redshift":
|
||||
# mapping redshift extension dropdown values to strings
|
||||
ext_mapping = ["iff", "exr", "tif", "png", "tga", "jpg"]
|
||||
extension = ext_mapping[
|
||||
cmds.getAttr("redshiftOptions.imageFormat")
|
||||
]
|
||||
else:
|
||||
# Get the extension, getAttr defaultRenderGlobals.imageFormat
|
||||
# returns an index number.
|
||||
filename_base = os.path.basename(filename_0)
|
||||
extension = os.path.splitext(filename_base)[-1].strip(".")
|
||||
|
||||
filename_prefix = cmds.getAttr(prefix_attr)
|
||||
return {"ext": extension,
|
||||
"filename_prefix": filename_prefix,
|
||||
"padding": padding,
|
||||
"filename_0": filename_0}
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue