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

Representation: Support for trait-based representation. #418

Closed
antirotor opened this issue Nov 1, 2024 · 2 comments · Fixed by #431
Closed

Representation: Support for trait-based representation. #418

antirotor opened this issue Nov 1, 2024 · 2 comments · Fixed by #431
Assignees

Comments

@antirotor
Copy link
Member

antirotor commented Nov 1, 2024

Story

With the move to the new representation model, we need to change a little bit how it is handled in backend. New representations are basically lists of traits - pydantic models that describe "the nature" of the representation itself. More info here and here. But in essence, those traits are serialized to dict/json like this:

{
        "ayon.content.FileLocation.v1": {
            "file_path": "/path/to/file",
            "file_size": 1024,
            "file_hash": None,
        },
        "ayon.2d.Image.v1": {},
        "ayon.content.MimeType.v1": {
             "mime_type": "image/jpeg",
        },
}

Proposal

We could introduce new column trait and store these there to keep "data" for more generic purpose. Then there is files column that will be superseded be Traits holding basically the same data. So my proposal is (when retrieving this data) search in traits, if not there, search in files column.

Further notes

Since Representation Traits are very dynamic in nature - core set defined in ayon-core, but every addon can define its own traits. So available traits set is based on current bundle of addon. There could be backend support to get schema of all available models for example. But the value of it is yet to be determined. New representation traits will allows some analytic work on AYON frontend - queries like "get me all published images larger then 2K" etc.

@antirotor antirotor added the type: feature Adding something new and exciting to the product label Nov 1, 2024
@BigRoy
Copy link
Contributor

BigRoy commented Nov 1, 2024

Just wanted to comment that we're likely better of storing the "version" of the data inside the data of each entry, like e.g.:

{
        "ayon.content.FileLocation": {
            "file_path": "/path/to/file",
            "file_size": 1024,
            "file_hash": None,
            "__version__": "1"
        },
        ...
}

Just so that if you wanted to check whether the dict has a trait that you don't need to "look for any matching version" but you can do the O1 lookup in the data instead?


Since Traits as pydantic models are very dynamic in nature

They are actually the opposite. The models are very static/typed and clear - not dynamic. I suppose you're referring to the fact that something can have any combination of traits which is what makes it dynamic. But that's not due to pydantic itself?

@martastain martastain removed the type: feature Adding something new and exciting to the product label Nov 6, 2024
@antirotor
Copy link
Member Author

I suppose you're referring to the fact that something can have any combination of traits which is what makes it dynamic. But that's not due to pydantic itself?

Yes, sorry. Pydantic models of individual Traits are static, but their combination in representation isn't.

Regarding version: that is already part of the concept - how - that is still matter of discussion (but not here, as this should "just" add column to database) but rather here

@martastain martastain linked a pull request Nov 11, 2024 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants