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

Publisher: Support dynamic/cached attribute definitions #55

Open
BigRoy opened this issue Jan 26, 2023 · 2 comments
Open

Publisher: Support dynamic/cached attribute definitions #55

BigRoy opened this issue Jan 26, 2023 · 2 comments
Assignees
Labels
type: enhancement Improvement of existing functionality or minor addition

Comments

@BigRoy
Copy link
Contributor

BigRoy commented Jan 26, 2023

Is your feature request related to a problem? Please describe.

I'd like to expose the primaryPool and secondaryPool to the user in the New Publisher.
I thought of adding this to Collect Deadline Pools:

    @classmethod
    def get_attribute_defs(cls):

        manager = ModulesManager()
        deadline_module = manager.modules_by_name["deadline"]
        pools = deadline_module.get_deadline_pools(deadline_url)

        pools_enum = {key: key for key in pools}

        from openpype.lib import EnumDef
        return [
            EnumDef("primaryPool",
                    label="Primary Pool",
                    default=cls.primary_pool,
                    items=pools_enum),
            EnumDef("secondaryPool",
                    label="Secondary Pool",
                    default=cls.secondary_pool,
                    items=pools_enum),
        ]

However the studio and user could customize the Deadline Webservice URL and the deadline pools would be a dynamic result.

For example this logic is used in maya:

try:
    default_servers = deadline_settings["deadline_urls"]
    project_servers = (
        self._project_settings["deadline"]["deadline_servers"]
    )
    self.deadline_servers = {
        k: default_servers[k]
        for k in project_servers
        if k in default_servers
    }

    if not self.deadline_servers:
        self.deadline_servers = default_servers

except AttributeError:
    # Handle situation were we had only one url for deadline.
    # get default deadline webservice url from deadline module
    self.deadline_servers = self.deadline_module.deadline_urls

Source

Describe the solution you'd like

  • Be able to delay the query of e.g. deadline_module.get_deadline_pools(deadline_url) to when it'd be needed - e.g. so that it updates the Pools list when clicking on the Enum for the first time.
  • Be able to "update" the available pool list e.g. another attribute definition would be changed, like the Deadline URL

Here's some pseudocode:

    @classmethod
    def get_attribute_defs(cls):

        from openpype.lib import EnumDef
        from functools import partial
        
        url_def = EnumDef("url",
                         label="Webservice URL",
                         items=project_deadline_urls)
        
        def get_pools(_url_def):
            """Return pool list based on value of url EnumDef"""
            url = _url_def.value
            manager = ModulesManager()
            deadline_module = manager.modules_by_name["deadline"]
            pools = deadline_module.get_deadline_pools(url)
            return {key: key for key in pools}
        
        fn_get_pools = partial(get_pools, url_def)

        primary_pool_def = EnumDef("primaryPool",
                                   label="Primary Pool",
                                   default=cls.primary_pool,
                                   itemgetter=fn_get_pools)
        secondary_pool_def = EnumDef("secondaryPool",
                                     label="Secondary Pool",
                                     default=cls.secondary_pool,
                                     itemgetter=fn_get_pools)

        url_def.valueChanged.connect(primary_pool_def.updateItems)
        url_def.valueChanged.connect(secondary_pool_def.updateItems)

        return [
            url_def,
            primary_pool_def,
            secondary_pool_def
        ]

Describe alternatives you've considered

Not sure what other approaches there are for the new publisher to expose this.

Additional context

Also mentioned on discord

[cuID:OP-4827]

@iLLiCiTiT iLLiCiTiT changed the title New Publisher: Support dynamic/cached attribute definitions Publisher: Support dynamic/cached attribute definitions Feb 24, 2023
@MustafaJafar MustafaJafar added the type: enhancement Improvement of existing functionality or minor addition label Jul 7, 2023
@BigRoy BigRoy transferred this issue from ynput/OpenPype Jul 29, 2024
@iLLiCiTiT
Copy link
Member

Is the issue described here still relevant? If yes, isn't that deadline issue?

@BigRoy
Copy link
Contributor Author

BigRoy commented Nov 1, 2024

Still relevant - and sure is!

Also, I believe this is now somewhat possible with ynput/ayon-core#935 implemented.

@BigRoy BigRoy transferred this issue from ynput/ayon-core Nov 1, 2024
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

No branches or pull requests

3 participants