mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-26 13:52:15 +01:00
fix(nks): tasks were not shared between instances
This commit is contained in:
parent
7881e6bd60
commit
8a77c702a1
1 changed files with 110 additions and 101 deletions
|
|
@ -3,7 +3,7 @@ import avalon.api as avalon
|
|||
import re
|
||||
|
||||
|
||||
class CollectHierarchyInstance(pyblish.api.InstancePlugin):
|
||||
class CollectHierarchyInstance(pyblish.api.ContextPlugin):
|
||||
"""Collecting hierarchy context from `parents` and `hierarchy` data
|
||||
present in `clip` family instances coming from the request json data file
|
||||
|
||||
|
|
@ -31,123 +31,130 @@ class CollectHierarchyInstance(pyblish.api.InstancePlugin):
|
|||
if entity_type:
|
||||
return {"entityType": entity_type, "entityName": value}
|
||||
|
||||
def process(self, instance):
|
||||
context = instance.context
|
||||
tags = instance.data.get("tags", None)
|
||||
clip = instance.data["item"]
|
||||
asset = instance.data.get("asset")
|
||||
def process(self, context):
|
||||
|
||||
# create asset_names conversion table
|
||||
if not context.data.get("assetsShared"):
|
||||
context.data["assetsShared"] = dict()
|
||||
for instance in context[:]:
|
||||
tags = instance.data.get("tags", None)
|
||||
clip = instance.data["item"]
|
||||
asset = instance.data.get("asset")
|
||||
|
||||
# build data for inner nukestudio project property
|
||||
data = {
|
||||
"sequence": (
|
||||
context.data['activeSequence'].name().replace(' ', '_')
|
||||
),
|
||||
"track": clip.parent().name().replace(' ', '_'),
|
||||
"clip": asset
|
||||
}
|
||||
self.log.debug("__ data: {}".format(data))
|
||||
# create asset_names conversion table
|
||||
if not context.data.get("assetsShared"):
|
||||
context.data["assetsShared"] = dict()
|
||||
|
||||
# checking if tags are available
|
||||
if not tags:
|
||||
return
|
||||
# build data for inner nukestudio project property
|
||||
data = {
|
||||
"sequence": (
|
||||
context.data['activeSequence'].name().replace(' ', '_')
|
||||
),
|
||||
"track": clip.parent().name().replace(' ', '_'),
|
||||
"clip": asset
|
||||
}
|
||||
self.log.debug("__ data: {}".format(data))
|
||||
|
||||
# loop trough all tags
|
||||
for t in tags:
|
||||
t_metadata = dict(t["metadata"])
|
||||
t_type = t_metadata.get("tag.label", "")
|
||||
t_note = t_metadata.get("tag.note", "")
|
||||
# checking if tags are available
|
||||
self.log.debug("__ instance.data[name]: {}".format(instance.data["name"]))
|
||||
self.log.debug("__ tags: {}".format(tags))
|
||||
|
||||
# and finding only hierarchical tag
|
||||
if "hierarchy" in t_type.lower():
|
||||
d_metadata = dict()
|
||||
parents = list()
|
||||
if not tags:
|
||||
return
|
||||
|
||||
# main template from Tag.note
|
||||
template = t_note
|
||||
# loop trough all tags
|
||||
for t in tags:
|
||||
t_metadata = dict(t["metadata"])
|
||||
t_type = t_metadata.get("tag.label", "")
|
||||
t_note = t_metadata.get("tag.note", "")
|
||||
|
||||
# if shot in template then remove it
|
||||
if "shot" in template.lower():
|
||||
instance.data["asset"] = [
|
||||
t for t in template.split('/')][-1]
|
||||
template = "/".join([t for t in template.split('/')][0:-1])
|
||||
self.log.debug("__ t_type: {}".format(t_type))
|
||||
|
||||
# take template from Tag.note and break it into parts
|
||||
template_split = template.split("/")
|
||||
patern = re.compile(r"\{([a-z]*?)\}")
|
||||
par_split = [patern.findall(t)
|
||||
for t in template.split("/")]
|
||||
# and finding only hierarchical tag
|
||||
if "hierarchy" in t_type.lower():
|
||||
d_metadata = dict()
|
||||
parents = list()
|
||||
|
||||
# format all {} in two layers
|
||||
for k, v in t_metadata.items():
|
||||
new_k = k.split(".")[1]
|
||||
# main template from Tag.note
|
||||
template = t_note
|
||||
|
||||
# ignore all help strings
|
||||
if 'help' in k:
|
||||
continue
|
||||
# self.log.info("__ new_k: `{}`".format(new_k))
|
||||
try:
|
||||
# first try all data and context data to
|
||||
# add to individual properties
|
||||
new_v = str(v).format(
|
||||
**dict(context.data, **data))
|
||||
d_metadata[new_k] = new_v
|
||||
# if shot in template then remove it
|
||||
if "shot" in template.lower():
|
||||
instance.data["asset"] = [
|
||||
t for t in template.split('/')][-1]
|
||||
template = "/".join([t for t in template.split('/')][0:-1])
|
||||
|
||||
# create parents
|
||||
# find matching index of order
|
||||
p_match_i = [i for i, p in enumerate(par_split)
|
||||
if new_k in p]
|
||||
# take template from Tag.note and break it into parts
|
||||
template_split = template.split("/")
|
||||
patern = re.compile(r"\{([a-z]*?)\}")
|
||||
par_split = [patern.findall(t)
|
||||
for t in template.split("/")]
|
||||
|
||||
# if any is matching then convert to entity_types
|
||||
if p_match_i:
|
||||
parent = self.convert_to_entity(
|
||||
new_k, template_split[p_match_i[0]])
|
||||
parents.insert(p_match_i[0], parent)
|
||||
except Exception:
|
||||
d_metadata[new_k] = v
|
||||
# format all {} in two layers
|
||||
for k, v in t_metadata.items():
|
||||
new_k = k.split(".")[1]
|
||||
|
||||
# create new shot asset name
|
||||
instance.data["asset"] = instance.data["asset"].format(
|
||||
**d_metadata)
|
||||
self.log.debug(
|
||||
"__ instance.data[asset]: "
|
||||
"{}".format(instance.data["asset"])
|
||||
)
|
||||
# ignore all help strings
|
||||
if 'help' in k:
|
||||
continue
|
||||
# self.log.info("__ new_k: `{}`".format(new_k))
|
||||
try:
|
||||
# first try all data and context data to
|
||||
# add to individual properties
|
||||
new_v = str(v).format(
|
||||
**dict(context.data, **data))
|
||||
d_metadata[new_k] = new_v
|
||||
|
||||
# lastly fill those individual properties itno
|
||||
# format the string with collected data
|
||||
parents = [{"entityName": p["entityName"].format(
|
||||
**d_metadata), "entityType": p["entityType"]}
|
||||
for p in parents]
|
||||
self.log.debug("__ parents: {}".format(parents))
|
||||
# create parents
|
||||
# find matching index of order
|
||||
p_match_i = [i for i, p in enumerate(par_split)
|
||||
if new_k in p]
|
||||
|
||||
hierarchy = template.format(
|
||||
**d_metadata)
|
||||
self.log.debug("__ hierarchy: {}".format(hierarchy))
|
||||
# if any is matching then convert to entity_types
|
||||
if p_match_i:
|
||||
parent = self.convert_to_entity(
|
||||
new_k, template_split[p_match_i[0]])
|
||||
parents.insert(p_match_i[0], parent)
|
||||
except Exception:
|
||||
d_metadata[new_k] = v
|
||||
|
||||
# check if hierarchy attribute is already created
|
||||
# it should not be so return warning if it is
|
||||
hd = instance.data.get("hierarchy")
|
||||
assert not hd, (
|
||||
"Only one Hierarchy Tag is allowed. "
|
||||
"Clip: `{}`".format(asset)
|
||||
)
|
||||
# create new shot asset name
|
||||
instance.data["asset"] = instance.data["asset"].format(
|
||||
**d_metadata)
|
||||
self.log.debug(
|
||||
"__ instance.data[asset]: "
|
||||
"{}".format(instance.data["asset"])
|
||||
)
|
||||
|
||||
assetsShared = {
|
||||
asset: {
|
||||
"asset": instance.data["asset"],
|
||||
"hierarchy": hierarchy,
|
||||
"parents": parents
|
||||
}}
|
||||
self.log.debug("__ assetsShared: {}".format(assetsShared))
|
||||
# add formated hierarchy path into instance data
|
||||
instance.data["hierarchy"] = hierarchy
|
||||
instance.data["parents"] = parents
|
||||
context.data["assetsShared"].update(
|
||||
assetsShared)
|
||||
# lastly fill those individual properties itno
|
||||
# format the string with collected data
|
||||
parents = [{"entityName": p["entityName"].format(
|
||||
**d_metadata), "entityType": p["entityType"]}
|
||||
for p in parents]
|
||||
self.log.debug("__ parents: {}".format(parents))
|
||||
|
||||
hierarchy = template.format(
|
||||
**d_metadata)
|
||||
self.log.debug("__ hierarchy: {}".format(hierarchy))
|
||||
|
||||
# check if hierarchy attribute is already created
|
||||
# it should not be so return warning if it is
|
||||
hd = instance.data.get("hierarchy")
|
||||
assert not hd, (
|
||||
"Only one Hierarchy Tag is allowed. "
|
||||
"Clip: `{}`".format(asset)
|
||||
)
|
||||
|
||||
assetsShared = {
|
||||
asset: {
|
||||
"asset": instance.data["asset"],
|
||||
"hierarchy": hierarchy,
|
||||
"parents": parents,
|
||||
"tasks": instance.data['tasks']
|
||||
}}
|
||||
self.log.debug("__ assetsShared: {}".format(assetsShared))
|
||||
# add formated hierarchy path into instance data
|
||||
instance.data["hierarchy"] = hierarchy
|
||||
instance.data["parents"] = parents
|
||||
context.data["assetsShared"].update(
|
||||
assetsShared)
|
||||
|
||||
|
||||
class CollectHierarchyContext(pyblish.api.ContextPlugin):
|
||||
|
|
@ -202,7 +209,9 @@ class CollectHierarchyContext(pyblish.api.ContextPlugin):
|
|||
self.log.debug("__ s_asset_data: {}".format(s_asset_data))
|
||||
name = instance.data["asset"] = s_asset_data["asset"]
|
||||
instance.data["parents"] = s_asset_data["parents"]
|
||||
instance.data["parents"] = s_asset_data["parents"]
|
||||
instance.data["hierarchy"] = s_asset_data["hierarchy"]
|
||||
instance.data["tasks"] = s_asset_data["tasks"]
|
||||
|
||||
self.log.debug(
|
||||
"__ instance.data[parents]: {}".format(
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue