Merge branch 'feature/OP-1562_Flame--pre-collecting-timeline-segments-as-subsets' into feature/OP-1537_Flame-Submitting-jobs-to-Burner-farm

This commit is contained in:
Jakub Jezek 2022-01-19 15:37:48 +01:00
commit dabcf629b7
No known key found for this signature in database
GPG key ID: D8548FBF690B100A
3 changed files with 50 additions and 46 deletions

View file

@ -601,12 +601,12 @@ def get_clips_in_reels(project):
return output_clips
def get_reformated_path(path, padded=True):
def get_reformated_path(fname, padded=True):
"""
Return fixed python expression path
Args:
path (str): path url or simple file name
fname (str): file name
Returns:
type: string with reformated path
@ -615,27 +615,27 @@ def get_reformated_path(path, padded=True):
get_reformated_path("plate.1001.exr") > plate.%04d.exr
"""
padding = get_padding_from_path(path)
found = get_frame_from_path(path)
padding = get_padding_from_path(fname)
found = get_frame_from_path(fname)
if not found:
log.info("Path is not sequence: {}".format(path))
return path
log.info("File name is not sequence: {}".format(fname))
return fname
if padded:
path = path.replace(found, "%0{}d".format(padding))
fname = fname.replace(found, "%0{}d".format(padding))
else:
path = path.replace(found, "%d")
fname = fname.replace(found, "%d")
return path
return fname
def get_padding_from_path(path):
def get_padding_from_path(fname):
"""
Return padding number from Flame path style
Args:
path (str): path url or simple file name
fname (str): file name
Returns:
int: padding number
@ -644,20 +644,17 @@ def get_padding_from_path(path):
get_padding_from_path("plate.0001.exr") > 4
"""
found = get_frame_from_path(path)
found = get_frame_from_path(fname)
if found:
return len(found)
else:
return None
return len(found) if found else None
def get_frame_from_path(path):
def get_frame_from_path(fname):
"""
Return sequence number from Flame path style
Args:
path (str): path url or simple file name
fname (str): file name
Returns:
int: sequence frame number
@ -669,12 +666,9 @@ def get_frame_from_path(path):
"""
frame_pattern = re.compile(r"[._](\d+)[.]")
found = re.findall(frame_pattern, path)
found = re.findall(frame_pattern, fname)
if found:
return found.pop()
else:
return None
return found.pop() if found else None
@contextlib.contextmanager

View file

@ -10,7 +10,7 @@ from pprint import pformat
class PrecollectInstances(pyblish.api.ContextPlugin):
"""Collect all Track items selection."""
order = pyblish.api.CollectorOrder - 0.49
order = pyblish.api.CollectorOrder - 0.47
label = "Precollect Instances"
hosts = ["flame"]
@ -57,16 +57,10 @@ class PrecollectInstances(pyblish.api.ContextPlugin):
marker_data["handleEnd"] = min(
marker_data["handleEnd"], tail)
# add audio to families
with_audio = False
if marker_data.pop("audio"):
with_audio = True
with_audio = bool(marker_data.pop("audio"))
# add tag data to instance data
data = {
k: v for k, v in marker_data.items()
if k not in ("id", "applieswhole", "label")
}
# add marker data to instance data
inst_data = dict(marker_data.items())
asset = marker_data["asset"]
subset = marker_data["subset"]
@ -83,7 +77,7 @@ class PrecollectInstances(pyblish.api.ContextPlugin):
label += " {}".format(subset)
label += " {}".format("[" + ", ".join(families) + "]")
data.update({
inst_data.update({
"name": "{}_{}".format(asset, subset),
"label": label,
"asset": asset,
@ -96,17 +90,19 @@ class PrecollectInstances(pyblish.api.ContextPlugin):
"path": file_path
})
# otio clip data
# get otio clip data
otio_data = self._get_otio_clip_instance_data(clip_data) or {}
self.log.debug("__ otio_data: {}".format(pformat(otio_data)))
data.update(otio_data)
self.log.debug("__ data: {}".format(pformat(data)))
# add to instance data
inst_data.update(otio_data)
self.log.debug("__ inst_data: {}".format(pformat(inst_data)))
# add resolution
self._get_resolution_to_data(data, context)
self._get_resolution_to_data(inst_data, context)
# create instance
instance = context.create_instance(**data)
instance = context.create_instance(**inst_data)
# add colorspace data
instance.data.update({
@ -116,7 +112,7 @@ class PrecollectInstances(pyblish.api.ContextPlugin):
})
# create shot instance for shot attributes create/update
self._create_shot_instance(context, clip_name, **data)
self._create_shot_instance(context, clip_name, **inst_data)
self.log.info("Creating instance: {}".format(instance))
self.log.info(

View file

@ -1,5 +1,6 @@
import pyblish.api
import avalon.api as avalon
import openpype.lib as oplib
import openpype.hosts.flame.api as opfapi
from openpype.hosts.flame.otio import flame_export
@ -8,22 +9,35 @@ class PrecollecTimelineOCIO(pyblish.api.ContextPlugin):
"""Inject the current working context into publish context"""
label = "Precollect Timeline OTIO"
order = pyblish.api.CollectorOrder - 0.5
order = pyblish.api.CollectorOrder - 0.48
def process(self, context):
asset = avalon.Session["AVALON_ASSET"]
subset = "otioTimeline"
# plugin defined
family = "workfile"
variant = "otioTimeline"
# main
asset_doc = context.data["assetEntity"]
task_name = avalon.Session["AVALON_TASK"]
project = opfapi.get_current_project()
sequence = opfapi.get_current_sequence(opfapi.CTX.selection)
# create subset name
subset_name = oplib.get_subset_name_with_asset_doc(
family,
variant,
task_name,
asset_doc,
)
# adding otio timeline to context
with opfapi.maintained_segment_selection(sequence):
otio_timeline = flame_export.create_otio_timeline(sequence)
instance_data = {
"name": "{}_{}".format(asset, subset),
"asset": asset,
"subset": "{}{}".format(asset, subset.capitalize()),
"name": subset_name,
"asset": asset_doc["name"],
"subset": subset_name,
"family": "workfile"
}