OpenPype icon indicating copy to clipboard operation
OpenPype copied to clipboard

Host Implementation add more options for `get_containers`

Open iLLiCiTiT opened this issue 3 years ago • 2 comments

Short description (written in hurry)

Method to get containers should have more options for filtering returned containers. Default behavior should be still same but there should be also option to return containers for selection or from custom state.

The states should be defined in some enum and method should expected one additional argument which is by default set to None. So the method would look like:

class ReturnType:
    All = object()
    Selection = object()
    RawData = object()

    
def get_containers(self, return_type=ReturnType.All, options=None):
    """Get containers by return type.
    
    Args:
        return_type (ReturnType): Define way how and from where
            are containers taken.
        options (?List[str]): Options related to `return_type` make sense
            only in specific cases.

    Returns:
        List[Dict]: List of containers.
    """

[cuID:2jp1yzu]

iLLiCiTiT avatar Jul 04 '22 16:07 iLLiCiTiT

I'm not entirely sure about being able to filter like that. Would a is_container_selected function equivalent be sufficient? I'm a bit worried about the speed/overhead for get_containers if the logic for it is contained inside the main call for it. I've noticed in the past that it's quite a speed-critical method because you tend to call it e.g. for detecting whether anything is outdated, or to list the scene containers (which could be many!)

BigRoy avatar Jul 04 '22 18:07 BigRoy

Well default function call should do exactly what does now. The filtering is "bonus point" which could make it actually faster when specific return type is requested.

We've discussed this when discussing look manager where this is now hardcoded in the tool itself for maya, which is not possible if we'll change the tool to be usable in more hosts.

@antirotor or @mkolar could explain more and elaborate more use cases.

iLLiCiTiT avatar Jul 06 '22 14:07 iLLiCiTiT