Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix: Hero representation of version is not synchronized. #4191

Closed
wants to merge 2 commits into from
Closed
Changes from all 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
33 changes: 29 additions & 4 deletions openpype/modules/sync_server/sync_server_module.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,10 @@
get_representations,
get_representation_by_id,
)
from openpype.client.entities import (
get_hero_version_by_subset_id,
get_representation_parents,
)
from openpype.modules import OpenPypeModule, ITrayModule
from openpype.settings import (
get_project_settings,
Expand Down Expand Up @@ -1792,11 +1796,32 @@ def _update_site(self, project_name, representation_id,

Used for refactoring ugly reset_provider_for_file
"""
query = {
"_id": ObjectId(representation_id)
}
representation_ids = [ObjectId(representation_id)]

self.connection.database[project_name].update_one(
# Add hero version
representation = get_representation_by_id(
project_name, representation_id
)
representation_parents = get_representation_parents(
Copy link
Member

@iLLiCiTiT iLLiCiTiT Dec 13, 2022

Choose a reason for hiding this comment

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

You don't need all parents but only version. Or? It looks like all you need is

version_doc = get_version_by_id(representation["parent"])

project_name, representation
)
hero_version = get_hero_version_by_subset_id(
Copy link
Member

@iLLiCiTiT iLLiCiTiT Dec 13, 2022

Choose a reason for hiding this comment

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

You should check if hero version matches the version doc.

repre_doc = get_representation_by_id(
    project_name, representation_id, fields=["_id", "parent"]
)
representation_ids = [repre_doc["_id"]]
version_doc = get_version_by_id(repre_doc["parent"])
if version_doc["type"] != "hero_version":
    hero_version = get_hero_version_by_subset_id(
        project_name, version_doc["parent"], fields=["_id", "version_id"]
    )
    if hero_version and hero_version["version_id"] == version_doc["_id"]:
        hero_repre_doc = get_representation_by_name(
            project_name,
            repre_doc["name"],
            hero_version["_id"]
        )
        representation_ids.append(hero_repre_doc["_id"])

query = {"_id": {"$in": representation_ids}}
...

project_name, representation_parents[1]["_id"], fields=["_id"]
)
if hero_version:
representations = get_representations(
project_name,
version_ids=[hero_version["_id"]],
fields=["_id"],
context_filters={"ext": [representation["context"]["ext"]]},
Copy link
Member

Choose a reason for hiding this comment

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

I don't think it should be filtrered by extension in context but by "name".

Copy link
Member

Choose a reason for hiding this comment

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

I don't think so, I have representations which have name 'thumbnail'.
(But I have also some old representations without representation["context"]["ext"])

Copy link
Member

@iLLiCiTiT iLLiCiTiT Dec 22, 2022

Choose a reason for hiding this comment

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

So it should be filtered by representation name instead of extension. Extension on context can be not unique (there can be more then one representation with extension .mov under single version). So this is unsave and could potentially cause sync of more representations.

)
representation_ids.extend(
[repre["_id"] for repre in representations]
)

query = {"_id": {"$in": representation_ids}}

self.connection.database[project_name].update_many(
query,
update,
upsert=True,
Expand Down