Skip to content
This repository has been archived by the owner on Sep 20, 2024. It is now read-only.

Editorial publishing workflow improvements #3580

Merged
merged 9 commits into from
Jul 28, 2022
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,8 @@ def process(self, context):
"tasks": {
task["name"]: {"type": task["type"]}
for task in self.add_tasks},
"representations": []
"representations": [],
"newAssetPublishing": True
})
self.log.debug("__ inst_data: {}".format(pformat(inst_data)))

Expand Down
3 changes: 2 additions & 1 deletion openpype/hosts/hiero/plugins/publish/precollect_instances.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,8 @@ def process(self, context):
"clipAnnotations": annotations,

# add all additional tags
"tags": phiero.get_track_item_tags(track_item)
"tags": phiero.get_track_item_tags(track_item),
"newAssetPublishing": True
})

# otio clip data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ def process(self, context):
"publish": resolve.get_publish_attribute(timeline_item),
"fps": context.data["fps"],
"handleStart": handle_start,
"handleEnd": handle_end
"handleEnd": handle_end,
"newAssetPublishing": True
})

# otio clip data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -170,7 +170,8 @@ def process(self, instance):
"frameStart": frame_start,
"frameEnd": frame_end,
"frameStartH": frame_start - handle_start,
"frameEndH": frame_end + handle_end
"frameEndH": frame_end + handle_end,
"newAssetPublishing": True
}

for data_key in instance_data_filter:
Expand Down
50 changes: 41 additions & 9 deletions openpype/plugins/publish/extract_hierarchy_avalon.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,9 +30,15 @@ def process(self, context):
self.log.debug("__ hierarchy_context: {}".format(hierarchy_context))

self.project = None
self.import_to_avalon(project_name, hierarchy_context)

def import_to_avalon(self, project_name, input_data, parent=None):
self.import_to_avalon(context, project_name, hierarchy_context)

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]
Expand Down Expand Up @@ -133,6 +139,9 @@ def import_to_avalon(self, project_name, input_data, parent=None):
# 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(
Expand All @@ -142,7 +151,7 @@ def import_to_avalon(self, project_name, input_data, parent=None):

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):
Expand All @@ -159,20 +168,43 @@ def unarchive_entity(self, entity, data):
{"_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 asset_doc

def _set_avalon_data_to_relative_instances(self, context, asset_doc):
for instance in context:
asset_name = asset_doc["name"]
jakubjezek001 marked this conversation as resolved.
Show resolved Hide resolved
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]
jakubjezek001 marked this conversation as resolved.
Show resolved Hide resolved

return get_asset_by_id(project_name, entity_id)
# update avalon data on instance
instance.data["anatomyData"].update({
"hierarchy": "/".join(parents),
"task": {},
"parent": parent_name
})

def _get_active_assets(self, context):
""" Returns only asset dictionary.
Expand Down
3 changes: 2 additions & 1 deletion openpype/plugins/publish/integrate.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
import openpype.api
from openpype.client import (
get_representations,
get_asset_by_name,
jakubjezek001 marked this conversation as resolved.
Show resolved Hide resolved
get_subset_by_name,
get_version_by_name,
)
Expand Down Expand Up @@ -426,7 +427,7 @@ def register(self, instance, file_transactions, filtered_repres):
"".format(len(prepared_representations)))

def prepare_subset(self, instance, project_name):
asset_doc = instance.data.get("assetEntity")
asset_doc = instance.data["assetEntity"]
subset_name = instance.data["subset"]
self.log.debug("Subset: {}".format(subset_name))

Expand Down
4 changes: 4 additions & 0 deletions openpype/plugins/publish/validate_asset_docs.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,10 @@ def process(self, instance):
if instance.data.get("assetEntity"):
self.log.info("Instance has set asset document in its data.")

elif instance.data.get("newAssetPublishing"):
# skip if it is editorial
self.log.info("Editorial instance is no need to check...")

else:
raise PublishValidationError((
"Instance \"{}\" doesn't have asset document "
Expand Down