Merge pull request #3095 from pypeclub/bugfix/collect_loaded_versions_skip_not_existing_representations

General: Collect loaded versions skips not existing representations
This commit is contained in:
Jakub Trllo 2022-04-28 11:02:47 +02:00 committed by GitHub
commit 0f933dd066
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -41,21 +41,33 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin):
loaded_versions = []
_containers = list(host.ls())
_repr_ids = [ObjectId(c["representation"]) for c in _containers]
repre_docs = legacy_io.find(
{"_id": {"$in": _repr_ids}},
projection={"_id": 1, "parent": 1}
)
version_by_repr = {
str(doc["_id"]): doc["parent"] for doc in
legacy_io.find(
{"_id": {"$in": _repr_ids}},
projection={"parent": 1}
)
str(doc["_id"]): doc["parent"]
for doc in repre_docs
}
# QUESTION should we add same representation id when loaded multiple
# times?
for con in _containers:
repre_id = con["representation"]
version_id = version_by_repr.get(repre_id)
if version_id is None:
self.log.warning((
"Skipping container,"
" did not find representation document. {}"
).format(str(con)))
continue
# NOTE:
# may have more then one representation that are same version
version = {
"subsetName": con["name"],
"representation": ObjectId(con["representation"]),
"version": version_by_repr[con["representation"]], # _id
"representation": ObjectId(repre_id),
"version": version_id,
}
loaded_versions.append(version)