mirror of
https://github.com/ynput/ayon-core.git
synced 2025-12-24 12:54:40 +01:00
Merge pull request #1601 from BigRoy/1600-collect-versions-loaded-in-scene-fails-in-unreal-due-to-lack-of-name-key-in-containers
Collect Loaded Scene Versions: skip invalid containers
This commit is contained in:
commit
cb06323e96
1 changed files with 29 additions and 0 deletions
|
|
@ -1,3 +1,5 @@
|
|||
from __future__ import annotations
|
||||
from typing import Any
|
||||
import ayon_api
|
||||
import ayon_api.utils
|
||||
|
||||
|
|
@ -32,6 +34,8 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin):
|
|||
self.log.debug("No loaded containers found in scene.")
|
||||
return
|
||||
|
||||
containers = self._filter_invalid_containers(containers)
|
||||
|
||||
repre_ids = {
|
||||
container["representation"]
|
||||
for container in containers
|
||||
|
|
@ -78,3 +82,28 @@ class CollectSceneLoadedVersions(pyblish.api.ContextPlugin):
|
|||
|
||||
self.log.debug(f"Collected {len(loaded_versions)} loaded versions.")
|
||||
context.data["loadedVersions"] = loaded_versions
|
||||
|
||||
def _filter_invalid_containers(
|
||||
self,
|
||||
containers: list[dict[str, Any]]
|
||||
) -> list[dict[str, Any]]:
|
||||
"""Filter out invalid containers lacking required keys.
|
||||
|
||||
Skip any invalid containers that lack 'representation' or 'name'
|
||||
keys to avoid KeyError.
|
||||
"""
|
||||
# Only filter by what's required for this plug-in instead of validating
|
||||
# a full container schema.
|
||||
required_keys = {"name", "representation"}
|
||||
valid = []
|
||||
for container in containers:
|
||||
missing = [key for key in required_keys if key not in container]
|
||||
if missing:
|
||||
self.log.warning(
|
||||
"Skipping invalid container, missing required keys:"
|
||||
" {}. {}".format(", ".join(missing), container)
|
||||
)
|
||||
continue
|
||||
valid.append(container)
|
||||
|
||||
return valid
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue