Merge branch 'feature/PYPE-570-maya-renderlayer-creator' of bitbucket.org:pypeclub/pype into feature/PYPE-570-maya-renderlayer-creator

This commit is contained in:
Milan Kolar 2020-02-25 21:40:23 +01:00
commit af11677b4e
6 changed files with 82 additions and 77 deletions

View file

@ -26,8 +26,8 @@ class ExtractBurnin(pype.api.Extractor):
if "representations" not in instance.data:
raise RuntimeError("Burnin needs already created mov to work on.")
version = instance.context.data.get(
'version', instance.data.get('version'))
version = instance.data.get(
'version', instance.context.data.get('version'))
frame_start = int(instance.data.get("frameStart") or 0)
frame_end = int(instance.data.get("frameEnd") or 1)
duration = frame_end - frame_start + 1

View file

@ -170,7 +170,7 @@ class ProcessSubmittedJobOnFarm(pyblish.api.InstancePlugin):
}
# list of family names to transfer to new family if present
families_transfer = ["render2d", "ftrack", "slate"]
families_transfer = ["render3d", "render2d", "ftrack", "slate"]
def _submit_deadline_post_job(self, instance, job):
"""
@ -372,7 +372,7 @@ class ProcessSubmittedJobOnFarm(pyblish.api.InstancePlugin):
# create represenation
rep = {
"name": aov,
"name": ext,
"ext": ext,
"files": [os.path.basename(f) for f in list(cols[0])],
"frameStart": start,
@ -381,7 +381,7 @@ class ProcessSubmittedJobOnFarm(pyblish.api.InstancePlugin):
"stagingDir": staging,
"anatomy_template": "render",
"fps": new_instance.get("fps"),
"tags": ["review", "preview"] if preview else []
"tags": ["review"] if preview else []
}
# add tags
@ -617,12 +617,14 @@ class ProcessSubmittedJobOnFarm(pyblish.api.InstancePlugin):
`foo` and `xxx`
"""
self.log.info(data.get("expectedFiles"))
if isinstance(data.get("expectedFiles")[0], dict):
# we cannot attach AOVs to other subsets as we consider every
# AOV subset of its own.
if len(data.get("attachTo")) > 0:
assert len(data.get("expectedFiles")[0].keys()) > 1, (
assert len(data.get("expectedFiles")[0].keys()) == 1, (
"attaching multiple AOVs or renderable cameras to "
"subset is not supported")
@ -660,6 +662,7 @@ class ProcessSubmittedJobOnFarm(pyblish.api.InstancePlugin):
new_i = copy(i)
new_i["version"] = at.get("version")
new_i["subset"] = at.get("subset")
new_i["append"] = True
new_i["families"].append(at.get("family"))
new_instances.append(new_i)
self.log.info(" - {} / v{}".format(

View file

@ -101,6 +101,10 @@ class CollectMayaRender(pyblish.api.ContextPlugin):
render_instance = instance
render_instance.data["remove"] = True
# make sure workfile instance publishing is enabled
if 'workfile' in instance.data['families']:
instance.data["publish"] = True
if not render_instance:
self.log.info("No render instance found, skipping render "
"layer collection.")

View file

@ -1,6 +1,4 @@
import pyblish
from avalon import api, io
class DetermineFutureVersion(pyblish.api.InstancePlugin):
"""
@ -20,66 +18,11 @@ class DetermineFutureVersion(pyblish.api.InstancePlugin):
for i in context:
if i.data["subset"] in attach_to_subsets:
latest_version = self._get_latest_version(i.data["subset"])
# this will get corresponding subset in attachTo list
# so we can set version there
# # this will get corresponding subset in attachTo list
# # so we can set version there
sub = next(item for item in instance.data['attachTo'] if item["subset"] == i.data["subset"]) # noqa: E501
if not latest_version:
# if latest_version is None, subset is not yet in
# database so we'll check its instance to see if version
# is there and use that, or we'll just stay with v1
latest_version = i.data.get("version", 1)
sub["version"] = latest_version
sub["version"] = i.data.get("version", 1)
self.log.info("render will be attached to {} v{}".format(
sub["subset"], sub["version"]
))
def _get_latest_version(self, subset):
latest_version = None
project_name = api.Session["AVALON_PROJECT"]
asset_name = api.Session["AVALON_ASSET"]
project_entity = io.find_one({
"type": "project",
"name": project_name
})
assert project_entity, (
"Project '{0}' was not found."
).format(project_name)
asset_entity = io.find_one({
"type": "asset",
"name": asset_name,
"parent": project_entity["_id"]
})
assert asset_entity, (
"No asset found by the name '{0}' in project '{1}'"
).format(asset_name, project_name)
if asset_entity:
subset_entity = io.find_one({
"type": "subset",
"name": subset,
"parent": asset_entity["_id"]
})
if subset_entity is None:
self.log.info("Subset entity does not exist yet.")
pass
else:
version_entity = io.find_one(
{
"type": "version",
"parent": subset_entity["_id"]
},
sort=[("name", -1)]
)
if version_entity:
latest_version = version_entity["name"]
return latest_version

View file

@ -117,6 +117,8 @@ class MayaSubmitDeadline(pyblish.api.InstancePlugin):
else:
optional = True
use_published = True
def process(self, instance):
DEADLINE_REST_URL = os.environ.get("DEADLINE_REST_URL",
@ -125,21 +127,66 @@ class MayaSubmitDeadline(pyblish.api.InstancePlugin):
context = instance.context
workspace = context.data["workspaceDir"]
anatomy = context.data['anatomy']
filepath = None
if self.use_published:
for i in context:
if "workfile" in i.data["families"]:
assert i.data["publish"] is True, (
"Workfile (scene) must be published along")
template_data = i.data.get("anatomyData")
rep = i.data.get("representations")[0].get("name")
template_data["representation"] = rep
template_data["ext"] = rep
template_data["comment"] = None
anatomy_filled = anatomy.format(template_data)
template_filled = anatomy_filled["publish"]["path"]
filepath = os.path.normpath(template_filled)
self.log.info("Using published scene for render {}".format(
filepath))
# now we need to switch scene in expected files
# because <scene> token will now point to published
# scene file and that might differ from current one
new_scene = os.path.splitext(
os.path.basename(filepath))[0]
orig_scene = os.path.splitext(
os.path.basename(context.data["currentFile"]))[0]
exp = instance.data.get("expectedFiles")
if isinstance(exp[0], dict):
# we have aovs and we need to iterate over them
new_exp = {}
for aov, files in exp[0].items():
replaced_files = []
for f in files:
replaced_files.append(
f.replace(orig_scene, new_scene)
)
new_exp[aov] = replaced_files
instance.data["expectedFiles"] = [new_exp]
else:
new_exp = []
for f in exp:
new_exp.append(
f.replace(orig_scene, new_scene)
)
instance.data["expectedFiles"] = [new_exp]
self.log.info("Scene name was switched {} -> {}".format(
orig_scene, new_scene
))
allInstances = []
for result in context.data["results"]:
if (result["instance"] is not None and
result["instance"] not in allInstances):
allInstances.append(result["instance"])
for inst in allInstances:
print(inst)
if inst.data['family'] == 'scene':
filepath = inst.data['destination_list'][0]
# fallback if nothing was set
if not filepath:
self.log.warning("Falling back to workfile")
filepath = context.data["currentFile"]
self.log.debug(filepath)

View file

@ -50,7 +50,7 @@ class ValidateRenderSettings(pyblish.api.InstancePlugin):
ImagePrefixTokens = {
'arnold': 'maya/<Scene>/<RenderLayer>/<RenderLayer>_<RenderPass',
'arnold': 'maya/<Scene>/<RenderLayer>/<RenderLayer>_<RenderPass>',
'redshift': 'maya/<Scene>/<RenderLayer>/<RenderLayer>',
'vray': 'maya/<scene>/<Layer>/<Layer>',
'renderman': '<layer>_<aov>.<f4>.<ext>'
@ -143,11 +143,19 @@ class ValidateRenderSettings(pyblish.api.InstancePlugin):
dir_prefix))
else:
if not re.search(cls.R_AOV_TOKEN, prefix):
invalid = True
cls.log.error("Wrong image prefix [ {} ] - "
"doesn't have: '<renderpass>' or "
"token".format(prefix))
multichannel = cmds.getAttr("defaultArnoldDriver.mergeAOVs")
if multichannel:
if re.search(cls.R_AOV_TOKEN, prefix):
invalid = True
cls.log.error("Wrong image prefix [ {} ] - "
"You can't use '<renderpass>' token "
"with merge AOVs turned on".format(prefix))
else:
if not re.search(cls.R_AOV_TOKEN, prefix):
invalid = True
cls.log.error("Wrong image prefix [ {} ] - "
"doesn't have: '<renderpass>' or "
"token".format(prefix))
# prefix check
if prefix.lower() != cls.ImagePrefixTokens[renderer].lower():