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

houdini: port to use stubgenlib #13

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

chadrik
Copy link
Collaborator

@chadrik chadrik commented Oct 14, 2024

Previously this used an alternative approach, mostly focused on docstrings. In the new approach we rely heavily on the C++ types embedded in the annotations.

Previously this used an alternative approach, mostly focused on docstrings.  In the new approach we rely heavily on the C++ types embedded in the annotations
@isohedronpipeline
Copy link

We'll need to do a bit of revision here. I can't load the diff to make comments on specific lines of the hou.pyi, so I'll just leave comments in here with the things I notice.

@isohedronpipeline
Copy link

Enumerated values have gotten lost:
Old:

class parmBakeChop:
    thisown: Any = ...
    @staticmethod
    def __init__(*args, **kwargs) -> None: ...
    __swig_destroy__: Any = ...

    CreateDeleteChop: EnumValue = ...  ## Added by typing stub update
    DisableExportFlag: EnumValue = ...  ## Added by typing stub update
    KeepExportFlag: EnumValue = ...  ## Added by typing stub update
    Off: EnumValue = ...  ## Added by typing stub update

new:

class parmBakeChop:
   """

   hou.parmBakeChop

   Enumeration of Bake Chop modes.

   See hou.Parm.keyframesRefit.

   VALUES


       Off
       KeepExportFlag
       DisableExportFlag
       CreateDeleteChop


   """
   thisown: Incomplete
   def __init__(self, *args, **kwargs) -> None: ...
   __swig_destroy__: Incomplete

@isohedronpipeline
Copy link

Houdini's hou module has a lot of namespace classes that have class/static methods, but this change has converted them into instance methods:
old:

class hda:
    thisown: Any = ...
    @staticmethod
    def __init__(*args, **kwargs) -> None: ...
    __swig_destroy__: Any = ...
    @staticmethod
    def installFile(file_path: str, oplibraries_file: Optional[str]=None, change_oplibraries_file: bool=True, force_use_assets: bool=False) -> None: ...
    ```

new:
```python
class hda:
    """

    hou.hda

    Module containing functions related to Houdini Digital Assets.


    """
    thisown: Incomplete
    def __init__(self, *args, **kwargs) -> None: ...
    __swig_destroy__: Incomplete
    @staticmethod
    def installFile(self, file_path: str, oplibraries_file: Optional[str] = None, change_oplibraries_file: bool = True, force_use_assets: bool = False) -> None:

As you can see, the self argument is present in the new one.

@isohedronpipeline
Copy link

isohedronpipeline commented Oct 16, 2024

There are some methods that are not represented or documented in hou.py that still work, but have been lost:
old:

class hda:
    @staticmethod
    def reloadHDAModule(hda_module: HDAModule) -> None: ...  ## Added by typing stub update

and this function is missing entirely from the replacement. You can see the list of methods I've added by hand in MISSING_FUNCTION_DEFINITIONS in hou_pyi_update.py

Some of those functions are not actually missing, but the docstrings were incorrect, so I redefined them, but each replacement will have a comment like "Redefine" or "Backwards compatibility" or "Missing". I think the ones we care about specifically are the "Missing", but we should do an audit of the backwards compatibility and redefine ones as well.

Any of the functions that have been touched in this way will have a comment of ## Added by typing stub update in the original as well.

@isohedronpipeline
Copy link

I think the handling of optional types may have been compromised as well. Example: hou.node() no longer returns hou.Node | None and instead returns hou.Node

old:

def node(path: str) -> Optional[Node]: ...

new:

def node(path: str) -> Node:
    '''

    hou.node

    Given a path string, return a Node object. Return None if the path does
    not refer to a node.

    USAGE
      node(path) -> hou.OpNode or None
      """

@isohedronpipeline
Copy link

I think it would also be good if the docstrings trimmed their whitespace, if possible. It's pretty excessive :-)

def simulationEnabled() -> bool:
    """

    hou.simulationEnabled

    USAGE
      simulationEnabled() -> bool

    Returns True if Houdini is currently set to update simulations. The user
    can choose to disable simulation updates to improve interactivity using
    the simulation menu in the bottom right corner of the main window. Use
    hou.setSimulationEnabled to enable or disable simulation updates
    programmatically.

    RELATED

      * hou.setSimulationEnabled


    """

@chadrik
Copy link
Collaborator Author

chadrik commented Oct 17, 2024

There are some methods that are not represented or documented in hou.py that still work, but have been lost: old:

class hda:
    @staticmethod
    def reloadHDAModule(hda_module: HDAModule) -> None: ...  ## Added by typing stub update

and this function is missing entirely from the replacement. You can see the list of methods I've added by hand in MISSING_FUNCTION_DEFINITIONS in hou_pyi_update.py

Some of those functions are not actually missing, but the docstrings were incorrect, so I redefined them, but each replacement will have a comment like "Redefine" or "Backwards compatibility" or "Missing". I think the ones we care about specifically are the "Missing", but we should do an audit of the backwards compatibility and redefine ones as well.

Any of the functions that have been touched in this way will have a comment of ## Added by typing stub update in the original as well.

This should be easy to transfer over. I'll take care of that on my flight home.

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 this pull request may close these issues.

2 participants