Skip to content

Enum resolvers: Add status enum for each entity type#962

Open
iLLiCiTiT wants to merge 6 commits into
developfrom
enhancement/entity-type-specific-status-enum
Open

Enum resolvers: Add status enum for each entity type#962
iLLiCiTiT wants to merge 6 commits into
developfrom
enhancement/entity-type-specific-status-enum

Conversation

@iLLiCiTiT

@iLLiCiTiT iLLiCiTiT commented Jun 8, 2026

Copy link
Copy Markdown
Member

PR Checklist

Added statuses enum resolver for each entity type there is.

Description of changes

Class StatusesEnumResolver now has defined entity_types to define set of available entity types for which to return statuses. The entity types enum is filtering them by the value and also create new items based on it. Then were added separate classes for each entity type.

Technical details

I first added entity_type as a string and then changed it to set[str], not sure if there might be usecase in future to be able to show statuses for folder and task at the same time? If not it should be easy to revert entity_types to entity_type.

Additional context

Currently the StatusesEnumResolver really can't be used in production as the usage is always scoped to a certain entity type.

@iLLiCiTiT iLLiCiTiT added the type: enhancement Improvement of existing functionality or minor addition label Jun 8, 2026
@iLLiCiTiT iLLiCiTiT requested review from kalisp and martastain June 8, 2026 14:57
@iLLiCiTiT iLLiCiTiT self-assigned this Jun 8, 2026
@martastain

Copy link
Copy Markdown
Member

Instead of having a separate resolver for every entity, couldn't we just use params? (add entity_type: str to accepted params and then use it in the same way project_name is used. That was the original idea of passing additional settings to resolvers. Ofc we could have aliases like in this PR, but the support for passing additional contextual parameters in query string is already there and can be used.

@iLLiCiTiT

Copy link
Copy Markdown
Member Author

Instead of having a separate resolver for every entity, couldn't we just use params? (add entity_type: str to accepted params and then use it in the same way project_name is used. That was the original idea of passing additional settings to resolvers. Ofc we could have aliases like in this PR, but the support for passing additional contextual parameters in query string is already there and can be used.

That would be better, BUT how would you then use it in enum_resolver?

@martastain

martastain commented Jun 12, 2026

Copy link
Copy Markdown
Member

You mean in settings? This should work:

class MySettings(BaseSettingsModel):
    folder_status: Annotated[str, SettingsField(enum_resolver=lambda: EnumRegistry.resolve("statuses", entity_type="folder)]
    

@iLLiCiTiT

iLLiCiTiT commented Jun 12, 2026

Copy link
Copy Markdown
Member Author

You mean in settings? This should work:

So what is StatusesEnumResolver for? That requires some knowledge of EnumRegistry and you have to use lambda. Whereas with this, you can just use it...

@martastain

Copy link
Copy Markdown
Member

The point is, that resolvers can have multiple parameter. and you'd need to write a resolver for every combination :)

the resolver already accepts project_name (but it is auto-populated in the case of settings). Also, having a central registry means that we can (well - we could, if we had time) export documentation: list all resolvers and accepted parameters.

@iLLiCiTiT

Copy link
Copy Markdown
Member Author

Ok, still, same question as above, what is StatusesEnumResolver for?

Comment thread ayon_server/enum/resolvers/enum_anatomy.py Fixed
@iLLiCiTiT

iLLiCiTiT commented Jun 12, 2026

Copy link
Copy Markdown
Member Author

Would the current approach work, added entity type param and also added for_type class method for easy usage.

@kalisp kalisp left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

LGTM but probably @martastain should approve too

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

Labels

type: enhancement Improvement of existing functionality or minor addition

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants