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

General: Fix links query on hero version #3900

Merged
merged 5 commits into from
Oct 10, 2022
Merged
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 12 additions & 3 deletions openpype/client/entity_links.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
from .entities import (
get_assets,
get_asset_by_id,
get_version_by_id,
get_representation_by_id,
convert_id,
)
Expand Down Expand Up @@ -127,12 +128,20 @@ def get_linked_representation_id(
if not version_id:
return []

version_doc = get_version_by_id(
project_name, version_id, fields=["type", "version_id"]
)
if version_doc["type"] == "hero_version":
version_id = version_doc["version_id"]

if max_depth is None:
max_depth = 0

match = {
"_id": version_id,
"type": {"$in": ["version", "hero_version"]}
# Links are not stored to hero versions at this moment so filter
# is limited to just versions
"type": "version"
Comment on lines +142 to +144
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually - are we sure? The input link collection I believe is retrieved from containers in the scene - those I suspect would have the representation id of the hero version. As such by doing this "fix" we'd never be able to list those inputs even though they are stored?

Copy link
Member Author

@iLLiCiTiT iLLiCiTiT Sep 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Links are added only to versioned version documents and hero version document don't have "data" at all.

But because hero versions are based on versioned documents we can reuse links from there.

Copy link
Collaborator

@BigRoy BigRoy Sep 23, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. Getting inputs FROM the hero version is then fixed. But any hero version IN the inputs is not? That hero version's inputs are not collected? (But might not be relevant for the UI we have now since it only shows direct inputs instead of a further depth.)

That does raise the question too that when we collect the inputs on publish would we want to resolve the hero version to the exact version it actually was at the time or do we want to just keep the link to the hero version? If we'd 'bake' it down to the exact version on collecting inputs the issue I mentioned would be gone plus you get the benefit of actually being able to see what version was used at the time in input link. Maybe we could tag it extra as "hero" so that the does know it originally was a hero link but at the time of publishing that was referring to v038.

@mkolar thoughts?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should we spin this up as a new issue?

}

graph_lookup = {
Expand Down Expand Up @@ -187,7 +196,7 @@ def _process_referenced_pipeline_result(result, link_type):
referenced_version_ids = set()
correctly_linked_ids = set()
for item in result:
input_links = item["data"].get("inputLinks")
input_links = item.get("data", {}).get("inputLinks")
if not input_links:
continue

Expand All @@ -203,7 +212,7 @@ def _process_referenced_pipeline_result(result, link_type):
continue

for output in sorted(outputs_recursive, key=lambda o: o["depth"]):
output_links = output["data"].get("inputLinks")
output_links = output.get("data", {}).get("inputLinks")
if not output_links:
continue

Expand Down