celaction publishing wip

This commit is contained in:
Jakub Jezek 2020-04-30 15:33:09 +01:00
parent 950644f630
commit 13dda8ef24
4 changed files with 95 additions and 48 deletions

View file

@ -0,0 +1,60 @@
"""
Requires:
context -> anatomy
context -> anatomyData
Provides:
instance -> publishDir
instance -> resourcesDir
"""
import os
import copy
import pyblish.api
from avalon import api
class CollectRenderPath(pyblish.api.InstancePlugin):
"""Generate file and directory path where rendered images will be"""
label = "Collect Render Path"
order = pyblish.api.CollectorOrder + 0.495
def process(self, instance):
anatomy = instance.context.data["anatomy"]
template_data = copy.deepcopy(instance.data["anatomyData"])
# This is for cases of Deprecated anatomy without `folder`
# TODO remove when all clients have solved this issue
template_data.update({
"frame": "FRAME_TEMP",
"representation": "png"
})
anatomy_filled = anatomy.format(template_data)
if "folder" in anatomy.templates["render"]:
render_folder = anatomy_filled["render"]["folder"]
render_file = anatomy_filled["render"]["file"]
else:
# solve deprecated situation when `folder` key is not underneath
# `publish` anatomy
project_name = api.Session["AVALON_PROJECT"]
self.log.warning((
"Deprecation warning: Anatomy does not have set `folder`"
" key underneath `publish` (in global of for project `{}`)."
).format(project_name))
file_path = anatomy_filled["render"]["path"]
# Directory
render_folder = os.path.dirname(file_path)
render_file = os.path.basename(file_path)
render_folder = os.path.normpath(render_folder)
render_path = os.path.join(render_folder, render_file)
instance.data["outputRenderPath"] = render_path
self.log.debug("outputRenderPath: \"{}\"".format(render_path))

View file

@ -6,9 +6,12 @@ import pyblish.api
class CollectCelactionRender(pyblish.api.ContextPlugin): class CollectCelactionRender(pyblish.api.ContextPlugin):
""" Adds the celaction render instances """ """ Adds the celaction render instances """
label = "Collect Celaction Render Instance"
order = pyblish.api.CollectorOrder + 0.1 order = pyblish.api.CollectorOrder + 0.1
def process(self, context): def process(self, context):
project_entity = context.data["projectEntity"]
asset_entity = context.data["assetEntity"]
# scene render # scene render
scene_file = os.path.basename(context.data["currentFile"]) scene_file = os.path.basename(context.data["currentFile"])
@ -23,7 +26,22 @@ class CollectCelactionRender(pyblish.api.ContextPlugin):
# getting instance state # getting instance state
instance.data["publish"] = True instance.data["publish"] = True
data = context.data("kwargs")["data"] # add assetEntity data into instance
instance.data.update({
"subset": "renderAnimationMain",
"asset": asset_entity["name"],
"frameStart": asset_entity["data"]["frameStart"],
"frameEnd": asset_entity["data"]["frameEnd"],
"handleStart": asset_entity["data"]["handleStart"],
"handleEnd": asset_entity["data"]["handleEnd"],
"fps": asset_entity["data"]["fps"],
"resolutionWidth": asset_entity["data"]["resolutionWidth"],
"resolutionHeight": asset_entity["data"]["resolutionHeight"],
"pixelAspect": 1,
"step": 1
})
for item in data: data = context.data.get("kwargs", {}).get("data", {})
instance.set_data(item, value=data[item])
if data:
instance.data.update(data)

View file

@ -1,18 +1,6 @@
"""
Requires:
context -> anatomy
context -> anatomyData
Provides:
instance -> publishDir
instance -> resourcesDir
"""
import os import os
import copy
import pyblish.api import pyblish.api
from avalon import api
class CollectRenderPath(pyblish.api.InstancePlugin): class CollectRenderPath(pyblish.api.InstancePlugin):
@ -22,39 +10,20 @@ class CollectRenderPath(pyblish.api.InstancePlugin):
order = pyblish.api.CollectorOrder + 0.495 order = pyblish.api.CollectorOrder + 0.495
def process(self, instance): def process(self, instance):
anatomy = instance.context.data["anatomy"] current_file = instance.context.data["currentFile"]
work_dir = os.path.dirname(current_file)
work_file = os.path.basename(current_file)
template_data = copy.deepcopy(instance.data["anatomyData"]) render_dir = os.path.join(
work_dir, "render", "celaction"
)
render_path = os.path.join(
render_dir, ".".join([instance.data["subset"], "%05d", "png"])
)
# This is for cases of Deprecated anatomy without `folder` # create dir if it doesnt exists
# TODO remove when all clients have solved this issue os.makedirs(render_dir, exist_ok=True)
template_data.update({
"frame": "FRAME_TEMP",
"representation": "png"
})
anatomy_filled = anatomy.format(template_data) instance.data["path"] = render_path
if "folder" in anatomy.templates["render"]: self.log.info(f"Render output path set to: `{render_path}`")
render_folder = anatomy_filled["render"]["folder"]
render_file = anatomy_filled["render"]["file"]
else:
# solve deprecated situation when `folder` key is not underneath
# `publish` anatomy
project_name = api.Session["AVALON_PROJECT"]
self.log.warning((
"Deprecation warning: Anatomy does not have set `folder`"
" key underneath `publish` (in global of for project `{}`)."
).format(project_name))
file_path = anatomy_filled["render"]["path"]
# Directory
render_folder = os.path.dirname(file_path)
render_file = os.path.basename(file_path)
render_folder = os.path.normpath(render_folder)
render_path = os.path.join(render_folder, render_file)
instance.data["outputRenderPath"] = render_path
self.log.debug("outputRenderPath: \"{}\"".format(render_path))