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

Commit

Permalink
AYON Editorial: Hierarchy context have names as keys
Browse files Browse the repository at this point in the history
  • Loading branch information
iLLiCiTiT authored Dec 12, 2023
2 parents dc62acc + 476921c commit f456a5a
Show file tree
Hide file tree
Showing 5 changed files with 32 additions and 22 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -257,8 +257,6 @@ def process(self, context):
if 'shot' not in instance.data.get('family', ''):
continue

name = instance.data["asset"]

# get handles
handle_start = int(instance.data["handleStart"])
handle_end = int(instance.data["handleEnd"])
Expand Down Expand Up @@ -286,6 +284,8 @@ def process(self, context):
parents = instance.data.get('parents', [])
self.log.debug(f"parents: {pformat(parents)}")

# Split by '/' for AYON where asset is a path
name = instance.data["asset"].split("/")[-1]
actual = {name: in_info}

for parent in reversed(parents):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -155,8 +155,6 @@ def _solve_hierarchy_context(self, instance):
else {}
)

asset_name = instance.data["asset"]

# get handles
handle_start = int(instance.data["handleStart"])
handle_end = int(instance.data["handleEnd"])
Expand All @@ -177,6 +175,8 @@ def _solve_hierarchy_context(self, instance):

parents = instance.data.get('parents', [])

# Split by '/' for AYON where asset is a path
asset_name = instance.data["asset"].split("/")[-1]
actual = {asset_name: in_info}

for parent in reversed(parents):
Expand Down
5 changes: 3 additions & 2 deletions openpype/plugins/publish/collect_hierarchy.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,8 +61,9 @@ def process(self, context):
"resolutionHeight": instance.data["resolutionHeight"],
"pixelAspect": instance.data["pixelAspect"]
}

actual = {instance.data["asset"]: shot_data}
# Split by '/' for AYON where asset is a path
name = instance.data["asset"].split("/")[-1]
actual = {name: shot_data}

for parent in reversed(instance.data["parents"]):
next_dict = {}
Expand Down
18 changes: 12 additions & 6 deletions openpype/plugins/publish/collect_resources_path.py
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,6 @@ class CollectResourcesPath(pyblish.api.InstancePlugin):
]

def process(self, instance):

anatomy = instance.context.data["anatomy"]

template_data = copy.deepcopy(instance.data["anatomyData"])
Expand All @@ -80,11 +79,18 @@ def process(self, instance):
"representation": "TEMP"
})

# For the first time publish
if instance.data.get("hierarchy"):
template_data.update({
"hierarchy": instance.data["hierarchy"]
})
# Add fill keys for editorial publishing creating new entity
# TODO handle in editorial plugin
if instance.data.get("newAssetPublishing"):
if "hierarchy" not in instance.data:
template_data["hierarchy"] = instance.data["hierarchy"]

if "asset" not in template_data:
asset_name = instance.data["asset"].split("/")[-1]
template_data["asset"] = asset_name
template_data["folder"] = {
"name": asset_name
}

publish_templates = anatomy.templates_obj["publish"]
if "folder" in publish_templates:
Expand Down
23 changes: 13 additions & 10 deletions openpype/plugins/publish/extract_hierarchy_to_ayon.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,23 +223,24 @@ def _filter_hierarchy(self, context):
valid_ids = set()

hierarchy_queue = collections.deque()
hierarchy_queue.append((project_id, project_children_context))
hierarchy_queue.append((project_id, "", project_children_context))
while hierarchy_queue:
queue_item = hierarchy_queue.popleft()
parent_id, children_context = queue_item
parent_id, parent_path, children_context = queue_item
if not children_context:
continue

for asset, asset_info in children_context.items():
for folder_name, folder_info in children_context.items():
folder_path = "{}/{}".format(parent_path, folder_name)
if (
asset not in active_folder_paths
and not asset_info.get("childs")
folder_path not in active_folder_paths
and not folder_info.get("childs")
):
continue
asset_name = asset.split("/")[-1]

item_id = uuid.uuid4().hex
new_item = copy.deepcopy(asset_info)
new_item["name"] = asset_name
new_item = copy.deepcopy(folder_info)
new_item["name"] = folder_name
new_item["children"] = []
new_children_context = new_item.pop("childs", None)
tasks = new_item.pop("tasks", {})
Expand All @@ -253,9 +254,11 @@ def _filter_hierarchy(self, context):
items_by_id[item_id] = new_item
parent_id_by_item_id[item_id] = parent_id

if asset in active_folder_paths:
if folder_path in active_folder_paths:
valid_ids.add(item_id)
hierarchy_queue.append((item_id, new_children_context))
hierarchy_queue.append(
(item_id, folder_path, new_children_context)
)

if not valid_ids:
return None
Expand Down

0 comments on commit f456a5a

Please sign in to comment.