mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-02 17:04:54 +01:00
Merge branch 'bugfix/integrate_fails_editorial_publish' into bugfix/OP-3654_Flame-re-timing-produces-frame-range-discrepancy-
This commit is contained in:
commit
f22a985a10
2 changed files with 40 additions and 16 deletions
|
|
@ -30,9 +30,15 @@ class ExtractHierarchyToAvalon(pyblish.api.ContextPlugin):
|
|||
self.log.debug("__ hierarchy_context: {}".format(hierarchy_context))
|
||||
|
||||
self.project = None
|
||||
self.import_to_avalon(project_name, hierarchy_context)
|
||||
self.import_to_avalon(context, project_name, hierarchy_context)
|
||||
|
||||
def import_to_avalon(self, project_name, input_data, parent=None):
|
||||
def import_to_avalon(
|
||||
self,
|
||||
context,
|
||||
project_name,
|
||||
input_data,
|
||||
parent=None,
|
||||
):
|
||||
for name in input_data:
|
||||
self.log.info("input_data[name]: {}".format(input_data[name]))
|
||||
entity_data = input_data[name]
|
||||
|
|
@ -133,6 +139,9 @@ class ExtractHierarchyToAvalon(pyblish.api.ContextPlugin):
|
|||
# Unarchive if entity was archived
|
||||
entity = self.unarchive_entity(unarchive_entity, data)
|
||||
|
||||
# make sure all relative instances have correct avalon data
|
||||
self._set_avalon_data_to_relative_instances(context, entity)
|
||||
|
||||
if update_data:
|
||||
# Update entity data with input data
|
||||
legacy_io.update_many(
|
||||
|
|
@ -142,7 +151,7 @@ class ExtractHierarchyToAvalon(pyblish.api.ContextPlugin):
|
|||
|
||||
if "childs" in entity_data:
|
||||
self.import_to_avalon(
|
||||
project_name, entity_data["childs"], entity
|
||||
context, project_name, entity_data["childs"], entity
|
||||
)
|
||||
|
||||
def unarchive_entity(self, entity, data):
|
||||
|
|
@ -159,20 +168,43 @@ class ExtractHierarchyToAvalon(pyblish.api.ContextPlugin):
|
|||
{"_id": entity["_id"]},
|
||||
new_entity
|
||||
)
|
||||
|
||||
return new_entity
|
||||
|
||||
def create_avalon_asset(self, project_name, name, data):
|
||||
item = {
|
||||
def create_avalon_asset(self, name, data):
|
||||
asset_doc = {
|
||||
"schema": "openpype:asset-3.0",
|
||||
"name": name,
|
||||
"parent": self.project["_id"],
|
||||
"type": "asset",
|
||||
"data": data
|
||||
}
|
||||
self.log.debug("Creating asset: {}".format(item))
|
||||
entity_id = legacy_io.insert_one(item).inserted_id
|
||||
self.log.debug("Creating asset: {}".format(asset_doc))
|
||||
asset_doc["_id"] = legacy_io.insert_one(asset_doc).inserted_id
|
||||
|
||||
return get_asset_by_id(project_name, entity_id)
|
||||
return asset_doc
|
||||
|
||||
def _set_avalon_data_to_relative_instances(self, context, asset_doc):
|
||||
for instance in context:
|
||||
asset_name = asset_doc["name"]
|
||||
inst_asset_name = instance.data["asset"]
|
||||
|
||||
if asset_name == inst_asset_name:
|
||||
instance.data["assetEntity"] = asset_doc
|
||||
|
||||
# get parenting data
|
||||
parents = asset_doc["data"].get("parents") or list()
|
||||
|
||||
# equire only relative parent
|
||||
if parents:
|
||||
parent_name = parents[-1]
|
||||
|
||||
# update avalon data on instance
|
||||
instance.data["avalonData"].update({
|
||||
"hierarchy": "/".join(parents),
|
||||
"task": {},
|
||||
"parent": parent_name
|
||||
})
|
||||
|
||||
def _get_active_assets(self, context):
|
||||
""" Returns only asset dictionary.
|
||||
|
|
|
|||
|
|
@ -274,14 +274,6 @@ class IntegrateAsset(pyblish.api.InstancePlugin):
|
|||
def register(self, instance, file_transactions, filtered_repres):
|
||||
project_name = legacy_io.active_project()
|
||||
|
||||
# making sure editorial instances have its `assetEntity`
|
||||
if instance.data.get("newAssetPublishing"):
|
||||
asset_doc = get_asset_by_name(
|
||||
project_name,
|
||||
instance.data["asset"]
|
||||
)
|
||||
instance.data["assetEntity"] = asset_doc
|
||||
|
||||
instance_stagingdir = instance.data.get("stagingDir")
|
||||
if not instance_stagingdir:
|
||||
self.log.info((
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue