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

Anatomy schema validation #1864

Merged
merged 3 commits into from
Jul 27, 2021
Merged
Show file tree
Hide file tree
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
23 changes: 23 additions & 0 deletions openpype/settings/entities/anatomy_entities.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from .dict_immutable_keys_entity import DictImmutableKeysEntity
from .lib import OverrideState
from .exceptions import EntitySchemaError


class AnatomyEntity(DictImmutableKeysEntity):
Expand All @@ -23,3 +24,25 @@ def on_child_change(self, child_obj):
if not child_obj.has_project_override:
child_obj.add_to_project_override()
return super(AnatomyEntity, self).on_child_change(child_obj)

def schema_validations(self):
non_group_children = []
for key, child_obj in self.non_gui_children.items():
if not child_obj.is_group:
non_group_children.append(key)

if non_group_children:
_non_group_children = [
"project_anatomy/{}".format(key)
for key in non_group_children
]
reason = (
"Anatomy must have all children as groups."
" Set 'is_group' to `true` on > {}"
).format(", ".join([
'"{}"'.format(item)
for item in _non_group_children
]))
raise EntitySchemaError(self, reason)

return super(AnatomyEntity, self).schema_validations()
9 changes: 9 additions & 0 deletions openpype/settings/entities/schemas/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -577,6 +577,15 @@ How output of the schema could look like on save:
}
```

## Anatomy
Anatomy represents data stored on project document.

### anatomy
- entity works similarly to `dict`
- anatomy has always all keys overriden with overrides
- overrides are not applied as all anatomy data must be available from project document
- all children must be groups

## Proxy wrappers
- should wraps multiple inputs only visually
- these does not have `"key"` key and do not allow to have `"is_file"` or `"is_group"` modifiers enabled
Expand Down