add description, default values, context handling

This commit is contained in:
Ondřej Samohel 2020-11-12 18:50:54 +01:00
parent 2780ce5377
commit afa051b16e
No known key found for this signature in database
GPG key ID: 02376E18990A97C6

View file

@ -12,7 +12,6 @@ import six
from avalon import api from avalon import api
import pyblish.api import pyblish.api
from .abstract_expected_files import ExpectedFiles
from .abstract_metaplugins import AbstractMetaContextPlugin from .abstract_metaplugins import AbstractMetaContextPlugin
@ -26,44 +25,44 @@ class RenderInstance(object):
""" """
# metadata # metadata
version = attr.ib() version = attr.ib() # instance version
time = attr.ib() time = attr.ib() # time of instance creation (avalon.api.time())
source = attr.ib() source = attr.ib() # path to source scene file
label = attr.ib() label = attr.ib() # label to show in GUI
subset = attr.ib() subset = attr.ib() # subset name
asset = attr.ib(init=False) asset = attr.ib() # asset name (AVALON_ASSET)
attachTo = attr.ib(init=False) attachTo = attr.ib() # subset name to attach render to
setMembers = attr.ib() setMembers = attr.ib() # list of nodes/members producing render output
publish = attr.ib() publish = attr.ib() # bool, True to publish instance
renderer = attr.ib() name = attr.ib() # instance name
name = attr.ib()
# format settings # format settings
resolutionWidth = attr.ib() resolutionWidth = attr.ib() # resolution width (1920)
resolutionHeight = attr.ib() resolutionHeight = attr.ib() # resolution height (1080)
pixelAspect = attr.ib() pixelAspect = attr.ib() # pixel aspect (1.0)
tileRendering = attr.ib()
tilesX = attr.ib()
tilesY = attr.ib()
# time settings # time settings
frameStart = attr.ib() frameStart = attr.ib() # start frame
frameEnd = attr.ib() frameEnd = attr.ib() # start end
frameStep = attr.ib() frameStep = attr.ib() # frame step
# -------------------- # --------------------
# With default values # With default values
# metadata # metadata
review = attr.ib(default=False) renderer = attr.ib(default="") # renderer - can be used in Deadline
priority = attr.ib(default=50) review = attr.ib(default=False) # genereate review from instance (bool)
priority = attr.ib(default=50) # job priority on farm
family = attr.ib(default="renderlayer") family = attr.ib(default="renderlayer")
families = attr.ib(default=["renderlayer"]) families = attr.ib(default=["renderlayer"]) # list of families
# format settings # format settings
multipartExr = attr.ib(default=False) multipartExr = attr.ib(default=False) # flag for multipart exrs
convertToScanline = attr.ib(default=False) convertToScanline = attr.ib(default=False) # flag for exr conversion
tileRendering = attr.ib(default=False) # bool: treat render as tiles
tilesX = attr.ib(default=0) # number of tiles in X
tilesY = attr.ib(default=0) # number of tiles in Y
@frameStart.validator @frameStart.validator
def check_frame_start(self, _, value): def check_frame_start(self, _, value):
@ -115,17 +114,23 @@ class AbstractCollectRender(pyblish.api.ContextPlugin):
super(AbstractCollectRender, self).__init__(*args, **kwargs) super(AbstractCollectRender, self).__init__(*args, **kwargs)
self._file_path = None self._file_path = None
self._asset = api.Session["AVALON_ASSET"] self._asset = api.Session["AVALON_ASSET"]
self._context = None
def process(self, context): def process(self, context):
"""Entry point to collector.""" """Entry point to collector."""
self._context = context
for instance in context: for instance in context:
# make sure workfile instance publishing is enabled # make sure workfile instance publishing is enabled
if "workfile" in instance.data["families"]: try:
instance.data["publish"] = True if "workfile" in instance.data["families"]:
instance.data["publish"] = True
except KeyError:
# be tolerant if 'families' is missing.
pass
self._file_path = context.data["currentFile"].replace("\\", "/") self._file_path = context.data["currentFile"].replace("\\", "/")
render_instances = self.get_instances() render_instances = self.get_instances(context)
for render_instance in render_instances: for render_instance in render_instances:
exp_files = self.get_expected_files(render_instance) exp_files = self.get_expected_files(render_instance)
assert exp_files, "no file names were generated, this is bug" assert exp_files, "no file names were generated, this is bug"
@ -163,7 +168,7 @@ class AbstractCollectRender(pyblish.api.ContextPlugin):
"subset": render_instance.subset, "subset": render_instance.subset,
"attachTo": render_instance.attachTo, "attachTo": render_instance.attachTo,
"setMembers": render_instance.setMembers, "setMembers": render_instance.setMembers,
"multipartExr": exp_files.multipart, "multipartExr": render_instance.multipartExr,
"review": render_instance.review or False, "review": render_instance.review or False,
"publish": True, "publish": True,