Coreform Cubit Python Scripts

Feel free to share helpful Python scripts with the community here.

Thanks for starting this thread. It will be interesting to see what python scripts people are making using the Python API.

I have just started working on the first version of cad-to-h5m which is a Python package that makes use of the Svalinn Plugin and Coreform Cubits Python API to convert STP or SAT files to h5m files.

The resulting h5m files can then be used in Neutronics simulations with DAGMC enabled codes such as OpenMC

The software is tested on GitHub actions CI that makes use of Coreform learn in the CI. This allows me to test the functionality of software and helps make sure changes don’t break functionality. Producing software that depends on Cubit was a bit difficult prior to Cubit Learn as it was challenging to test it therefore this wouldn’t be possible without Cubit learn.

Perhaps one day we will have native h5m export in Cubit but for now this could help provide a solution to some DAGMC users.

The package can be pip installed with pip install cad-to-h5m

1 Like

@jshimwell – Something else we’ve just recently started is a public-facing GitHub repository for Coreform Cubit utilities. This is still very much in its infancy, but I’m curious to get your thoughts for how we might incorporate utilities like your cad_to_h5m project.

One approach would be to include a list of projects in the README. However, something that I think would be highly beneficial is for everyone is to include our repository in our internal CI/CD pipelines. Perhaps including external projects via submodules? This is a bit out of my wheelhouse, so I’m curious to get your thoughts - as well as the thoughts of the broader Cubit community.

Nice repository :star:

GitHub has a standard way of making repos that are a list of projects called awesome · GitHub Topics which is might be of interest as they get picked up by GitHub automatically. Here is an example one awesome-nuclear

Submodules do sound like the way to go to bring in python packages. My experience of them is quite limited but I look forward to learning more. Would be great to get some packages into your CI/CD pipelines.

It sounds like two repos to me, one for a nice list of packages and one for submodules for use in the CI/CD

It will be nice to add separate cubit.pyi and cubit3.pyi to this or some separate repository. It will give possibility to get descriptions of cubit functions in PyCharm. Assume cubit3.pyi (added to the project or installed from PyPi) contains:

def cmd(input_string: str) -> bool:
    """
    Execute command.

    Args:
        input_string: cmdline.

    Returns:
        Return flag.
    """
    ...

Then in PyCharm (where real cubit package can be unavailable) user will see (Ctrl-Q, more info for Ctrl-Shit-I):

image

Wrong arguments will be highlighted, etc.

It can be done by stubgen.py tool from mypy utility. See stackoverflow for additional details. Of course, cubit.py, cubit3.py (and cubit2.py?) need to be annotated. I hope, it can be done automatically on your side.

We will look into this.

Thanks,
Karl