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

Add close method to openmc.StatePoint and update docs/examples for best practices #1854

Merged
merged 5 commits into from Jun 30, 2021

Conversation

pshriwise
Copy link
Contributor

Movitation

A recurring issue in the forum is users running into the error

RuntimeError: Failed to open HDF5 file with mode 'w': summary.h5

when working with OpenMC's Python API. This is usually related to an open StatePoint file when OpenMC is being executed. The open HDF5 file handle prevents an overwrite of the summary.h5 file (auto-linked to the StatePoint object by default) and causes OpenMC to crash. This can also happen if OpenMC tries to overwrite a statepoint file with an open handle, so we can see this even if writing the summary file is disabled.

A couple of forum discussions related to this issue:

Changes

This PR adds a openmc.StatePoint.close method that closes the HDF5 files related to the statepoint object. StatePoint file handles are most easily managed using context managers when extracting data, but there are times when these regions may become unreasonably large. The StatePoint.close method is meant to handle these cases.

To increase user awareness, I've also updated the examples to use context managers when possible and always close the StatePoint objects as a matter of best practice if needed.

Copy link
Contributor

@paulromano paulromano left a comment

Choose a reason for hiding this comment

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

Good call on adding this method and updating the examples. Also, thanks for adding something to our long-neglected troubleshooting guide 😄

docs/source/usersguide/troubleshoot.rst Outdated Show resolved Hide resolved
docs/source/usersguide/troubleshoot.rst Outdated Show resolved Hide resolved
examples/jupyter/candu.ipynb Outdated Show resolved Hide resolved
examples/jupyter/mdgxs-part-i.ipynb Outdated Show resolved Hide resolved
examples/jupyter/mg-mode-part-i.ipynb Outdated Show resolved Hide resolved
pshriwise and others added 2 commits June 28, 2021 08:21
Co-authored-by: Paul Romano <paul.k.romano@gmail.com>
@paulromano paulromano merged commit 4239716 into openmc-dev:develop Jun 30, 2021
@paulromano
Copy link
Contributor

Thanks again @pshriwise!

paulromano added a commit to openmc-dev/openmc-notebooks that referenced this pull request Jun 30, 2021
@pshriwise pshriwise deleted the statepoint_close branch November 16, 2021 21:21
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.

None yet

2 participants