Skip to content

EntityHub: Inherited attribute values - #373

Open
iLLiCiTiT wants to merge 1 commit into
developfrom
enhancement/entity-hub-inherited-attributes
Open

iLLiCiTiT wants to merge 1 commit into
developfrom
enhancement/entity-hub-inherited-attributes

Conversation

@iLLiCiTiT

Copy link
Copy Markdown
Member

Changelog Description

Attributes of entities in EntityHub can return values inherited from parent entities. Folders inherit from parent folders and the project, tasks inherit from their folder.

task.attribs.get("frameStart")            # own value, None if not set
task.attribs.get_inherited("frameStart")  # own value or value of closest parent that has it set
task.attribs.to_dict(inherited=True)      # all attributes with inheritance applied
task.attribs.inherited_items()

Additional info

EntityHub queries entities with own_attributes=True, so there was no way to get the effective value of an attribute.

  • Inheritance follows the server: only folders and tasks inherit, only attributes with inherit enabled in their schema, and only when the own value is None.
  • Values are resolved on each call by walking current parents in the hub, so uncommitted changes on parents (or a changed parent) are reflected immediately. Parents that are not loaded yet are fetched.
  • Fixed get_or_fetch_entity_by_id raising ValueError for the project id with "project" entity type when the project was not loaded yet. It now returns project_entity.

Testing notes:

  1. Create EntityHub for a project with nested folders, e.g. /ep01/sq01/sh0100, where only ep01 has frameStart set.
  2. Get sh0100 (or its task) and check attribs.get("frameStart") is None and attribs.get_inherited("frameStart") returns the value from ep01.
  3. Compare attribs.to_dict(inherited=True, ignore_none=False) with attrib of the same entity queried from server; they should match.
  4. Change frameStart on ep01 in the hub (without commit) and check get_inherited on sh0100 returns the new value. Set a value on sq01 and check it takes precedence.

Attributes of folder and task entities can resolve values inherited
from parent folders and project with 'get_inherited', 'inherited_items'
and 'to_dict(inherited=True)'. Values are resolved on each call from
current values of entities in the hub.

'get_or_fetch_entity_by_id' returns project entity when project name
is passed with 'project' entity type.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Changes recommended

Integration tests are missing for the new inherited-entity API, leaving closest-parent precedence, project fallback, opt-out behavior, and uncommitted parent changes unverified.

1 open issue
What changed in this PR

Adds inherited attribute support to EntityHub, allowing folders and tasks to resolve effective values from their parent hierarchy while preserving access to their own values.

Changes:

  • Adds get_inherited, inherited_items, and inherited-aware to_dict.
  • Resolves parent attributes dynamically, including unloaded parents and uncommitted changes.
  • Fixes lazy project entity lookup by project ID.
File Summary
ayon_api/​entity_hub.py Implements inherited attribute resolution and project lookup fixes. Review findings: treat a missing inherit schema flag as false (moderate, 1 vote); materialize one-shot entity_types iterables before membership checks (moderate, 1 vote); continue parent traversal when an intermediate schema lacks the attribute (moderate, 1 vote); add integration coverage for inheritance behavior (nit, 4 votes).

Review effort: Lite

Comment thread ayon_api/entity_hub.py
Comment on lines +1384 to +1389
def get_inherited(self, key: str, default: Optional[Any] = None) -> Any:
"""Get value of attribute with inheritance from parent entities.

Own value is returned if is set, otherwise value is taken from
the closest parent entity (folder or project) that has the value
set, if the attribute is inheritable. Value is resolved on each

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

type: enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants