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

Skip invalid containers with a warning #179

Open
wants to merge 1 commit into
base: develop
Choose a base branch
from
Open
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
15 changes: 12 additions & 3 deletions client/ayon_maya/api/pipeline.py
Original file line number Diff line number Diff line change
Expand Up @@ -347,11 +347,18 @@ def parse_container(container):
container (str): A container node name.

Returns:
dict: The container schema data for this container node.
dict[str, Any]: The container schema data for this container node.

"""
data = lib.read(container)

required = ["id", "name", "namespace", "loader", "representation"]
missing = [key for key in required if key not in data]
Comment on lines +355 to +356
Copy link
Member

Choose a reason for hiding this comment

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

Suggested change
required = ["id", "name", "namespace", "loader", "representation"]
missing = [key for key in required if key not in data]
required = {"id", "name", "namespace", "loader", "representation"}
missing = required - set(data.keys())

if missing:
log.warning("Container '%s' is missing required keys: %s",
container, missing)
return {}
Copy link
Member

Choose a reason for hiding this comment

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

Shoulnd't this return None rather than empty dictionary?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Not according to the functions type hint :D
Checked the usage of the function and noticed this may also influence setdress in maya - so I may want to do this differently.


# Backwards compatibility pre-schemas for containers
data["schema"] = data.get("schema", "openpype:container-1.0")

Expand Down Expand Up @@ -411,12 +418,14 @@ def ls():
they are called 'containers'

Yields:
dict: container
dict[str, Any]: container

"""
container_names = _ls()
for container in sorted(container_names):
yield parse_container(container)
container_data = parse_container(container)
if container_data:
yield container_data


def containerise(name,
Expand Down