mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-25 05:14:40 +01:00
Merge pull request #3355 from pypeclub/bugfix/stpublisher-editorial-hierarchy
Standalone: settings improvements
This commit is contained in:
commit
c2fcd5da7d
5 changed files with 78 additions and 38 deletions
|
|
@ -1,4 +1,5 @@
|
|||
import os
|
||||
from pprint import pformat
|
||||
import re
|
||||
from copy import deepcopy
|
||||
import pyblish.api
|
||||
|
|
@ -21,6 +22,7 @@ class CollectHierarchyInstance(pyblish.api.ContextPlugin):
|
|||
families = ["shot"]
|
||||
|
||||
# presets
|
||||
shot_rename = True
|
||||
shot_rename_template = None
|
||||
shot_rename_search_patterns = None
|
||||
shot_add_hierarchy = None
|
||||
|
|
@ -46,7 +48,7 @@ class CollectHierarchyInstance(pyblish.api.ContextPlugin):
|
|||
parent_name = instance.context.data["assetEntity"]["name"]
|
||||
clip = instance.data["item"]
|
||||
clip_name = os.path.splitext(clip.name)[0].lower()
|
||||
if self.shot_rename_search_patterns:
|
||||
if self.shot_rename_search_patterns and self.shot_rename:
|
||||
search_text += parent_name + clip_name
|
||||
instance.data["anatomyData"].update({"clip_name": clip_name})
|
||||
for type, pattern in self.shot_rename_search_patterns.items():
|
||||
|
|
@ -56,9 +58,9 @@ class CollectHierarchyInstance(pyblish.api.ContextPlugin):
|
|||
continue
|
||||
instance.data["anatomyData"][type] = match[-1]
|
||||
|
||||
# format to new shot name
|
||||
instance.data["asset"] = self.shot_rename_template.format(
|
||||
**instance.data["anatomyData"])
|
||||
# format to new shot name
|
||||
instance.data["asset"] = self.shot_rename_template.format(
|
||||
**instance.data["anatomyData"])
|
||||
|
||||
def create_hierarchy(self, instance):
|
||||
asset_doc = instance.context.data["assetEntity"]
|
||||
|
|
@ -87,7 +89,7 @@ class CollectHierarchyInstance(pyblish.api.ContextPlugin):
|
|||
})
|
||||
|
||||
hierarchy = list()
|
||||
if self.shot_add_hierarchy:
|
||||
if self.shot_add_hierarchy.get("enabled"):
|
||||
parent_template_patern = re.compile(r"\{([a-z]*?)\}")
|
||||
# fill the parents parts from presets
|
||||
shot_add_hierarchy = self.shot_add_hierarchy.copy()
|
||||
|
|
@ -131,8 +133,8 @@ class CollectHierarchyInstance(pyblish.api.ContextPlugin):
|
|||
instance.data["parents"] = parents
|
||||
|
||||
# print
|
||||
self.log.debug(f"Hierarchy: {hierarchy}")
|
||||
self.log.debug(f"parents: {parents}")
|
||||
self.log.warning(f"Hierarchy: {hierarchy}")
|
||||
self.log.info(f"parents: {parents}")
|
||||
|
||||
tasks_to_add = dict()
|
||||
if self.shot_add_tasks:
|
||||
|
|
@ -163,6 +165,9 @@ class CollectHierarchyInstance(pyblish.api.ContextPlugin):
|
|||
})
|
||||
|
||||
def process(self, context):
|
||||
self.log.info("self.shot_add_hierarchy: {}".format(
|
||||
pformat(self.shot_add_hierarchy)
|
||||
))
|
||||
for instance in context:
|
||||
if instance.data["family"] in self.families:
|
||||
self.processing_instance(instance)
|
||||
|
|
|
|||
|
|
@ -39,11 +39,14 @@ class ExtractTrimVideoAudio(openpype.api.Extractor):
|
|||
# Generate mov file.
|
||||
fps = instance.data["fps"]
|
||||
video_file_path = instance.data["editorialSourcePath"]
|
||||
extensions = instance.data.get("extensions", [".mov"])
|
||||
extensions = instance.data.get("extensions", ["mov"])
|
||||
|
||||
for ext in extensions:
|
||||
self.log.info("Processing ext: `{}`".format(ext))
|
||||
|
||||
if not ext.startswith("."):
|
||||
ext = "." + ext
|
||||
|
||||
clip_trimed_path = os.path.join(
|
||||
staging_dir, instance.data["name"] + ext)
|
||||
# # check video file metadata
|
||||
|
|
|
|||
|
|
@ -145,9 +145,43 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin):
|
|||
if instance.data.get("farm"):
|
||||
return
|
||||
|
||||
# Prepare repsentations that should be integrated
|
||||
repres = instance.data.get("representations")
|
||||
# Raise error if instance don't have any representations
|
||||
if not repres:
|
||||
raise ValueError(
|
||||
"Instance {} has no files to transfer".format(
|
||||
instance.data["family"]
|
||||
)
|
||||
)
|
||||
|
||||
# Validate type of stored representations
|
||||
if not isinstance(repres, (list, tuple)):
|
||||
raise TypeError(
|
||||
"Instance 'files' must be a list, got: {0} {1}".format(
|
||||
str(type(repres)), str(repres)
|
||||
)
|
||||
)
|
||||
|
||||
# Filter representations
|
||||
filtered_repres = []
|
||||
for repre in repres:
|
||||
if "delete" in repre.get("tags", []):
|
||||
continue
|
||||
filtered_repres.append(repre)
|
||||
|
||||
# Skip instance if there are not representations to integrate
|
||||
# all representations should not be integrated
|
||||
if not filtered_repres:
|
||||
self.log.warning((
|
||||
"Skipping, there are no representations"
|
||||
" to integrate for instance {}"
|
||||
).format(instance.data["family"]))
|
||||
return
|
||||
|
||||
self.integrated_file_sizes = {}
|
||||
try:
|
||||
self.register(instance)
|
||||
self.register(instance, filtered_repres)
|
||||
self.log.info("Integrated Asset in to the database ...")
|
||||
self.log.info("instance.data: {}".format(instance.data))
|
||||
self.handle_destination_files(self.integrated_file_sizes,
|
||||
|
|
@ -158,7 +192,7 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin):
|
|||
self.handle_destination_files(self.integrated_file_sizes, 'remove')
|
||||
six.reraise(*sys.exc_info())
|
||||
|
||||
def register(self, instance):
|
||||
def register(self, instance, repres):
|
||||
# Required environment variables
|
||||
anatomy_data = instance.data["anatomyData"]
|
||||
|
||||
|
|
@ -236,18 +270,6 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin):
|
|||
"Establishing staging directory @ {0}".format(stagingdir)
|
||||
)
|
||||
|
||||
# Ensure at least one file is set up for transfer in staging dir.
|
||||
repres = instance.data.get("representations")
|
||||
repres = instance.data.get("representations")
|
||||
msg = "Instance {} has no files to transfer".format(
|
||||
instance.data["family"])
|
||||
assert repres, msg
|
||||
assert isinstance(repres, (list, tuple)), (
|
||||
"Instance 'files' must be a list, got: {0} {1}".format(
|
||||
str(type(repres)), str(repres)
|
||||
)
|
||||
)
|
||||
|
||||
subset = self.get_subset(asset_entity, instance)
|
||||
instance.data["subsetEntity"] = subset
|
||||
|
||||
|
|
@ -270,7 +292,10 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin):
|
|||
|
||||
self.log.debug("Creating version ...")
|
||||
|
||||
new_repre_names_low = [_repre["name"].lower() for _repre in repres]
|
||||
new_repre_names_low = [
|
||||
_repre["name"].lower()
|
||||
for _repre in repres
|
||||
]
|
||||
|
||||
existing_version = legacy_io.find_one({
|
||||
'type': 'version',
|
||||
|
|
@ -373,18 +398,8 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin):
|
|||
if profile:
|
||||
template_name = profile["template_name"]
|
||||
|
||||
|
||||
|
||||
published_representations = {}
|
||||
for idx, repre in enumerate(instance.data["representations"]):
|
||||
# reset transfers for next representation
|
||||
# instance.data['transfers'] is used as a global variable
|
||||
# in current codebase
|
||||
instance.data['transfers'] = list(orig_transfers)
|
||||
|
||||
if "delete" in repre.get("tags", []):
|
||||
continue
|
||||
|
||||
for idx, repre in enumerate(repres):
|
||||
published_files = []
|
||||
|
||||
# create template data for Anatomy
|
||||
|
|
@ -662,6 +677,10 @@ class IntegrateAssetNew(pyblish.api.InstancePlugin):
|
|||
"published_files": published_files
|
||||
}
|
||||
self.log.debug("__ representations: {}".format(representations))
|
||||
# reset transfers for next representation
|
||||
# instance.data['transfers'] is used as a global variable
|
||||
# in current codebase
|
||||
instance.data['transfers'] = list(orig_transfers)
|
||||
|
||||
# Remove old representations if there are any (before insertion of new)
|
||||
if existing_repres:
|
||||
|
|
|
|||
|
|
@ -257,12 +257,14 @@
|
|||
]
|
||||
},
|
||||
"CollectHierarchyInstance": {
|
||||
"shot_rename": true,
|
||||
"shot_rename_template": "{project[code]}_{_sequence_}_{_shot_}",
|
||||
"shot_rename_search_patterns": {
|
||||
"_sequence_": "(\\d{4})(?=_\\d{4})",
|
||||
"_shot_": "(\\d{4})(?!_\\d{4})"
|
||||
"_sequence_": "(sc\\d{3})",
|
||||
"_shot_": "(sh\\d{3})"
|
||||
},
|
||||
"shot_add_hierarchy": {
|
||||
"enabled": true,
|
||||
"parents_path": "{project}/{folder}/{sequence}",
|
||||
"parents": {
|
||||
"project": "{project[name]}",
|
||||
|
|
|
|||
|
|
@ -271,6 +271,11 @@
|
|||
"label": "Collect Instance Hierarchy",
|
||||
"is_group": true,
|
||||
"children": [
|
||||
{
|
||||
"type": "boolean",
|
||||
"key": "shot_rename",
|
||||
"label": "Shot Rename"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"key": "shot_rename_template",
|
||||
|
|
@ -289,7 +294,13 @@
|
|||
"type": "dict",
|
||||
"key": "shot_add_hierarchy",
|
||||
"label": "Shot hierarchy",
|
||||
"checkbox_key": "enabled",
|
||||
"children": [
|
||||
{
|
||||
"type": "boolean",
|
||||
"key": "enabled",
|
||||
"label": "Enabled"
|
||||
},
|
||||
{
|
||||
"type": "text",
|
||||
"key": "parents_path",
|
||||
|
|
@ -343,8 +354,8 @@
|
|||
"type": "number",
|
||||
"key": "timeline_frame_start",
|
||||
"label": "Timeline start frame",
|
||||
"default": 900000,
|
||||
"minimum": 1,
|
||||
"default": 90000,
|
||||
"minimum": 0,
|
||||
"maximum": 10000000
|
||||
},
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue