Add remove_corrupt_h5 utility to clean up interrupted runs - #35
Merged
Conversation
The generate_*/convert_* scripts resume by skipping input files whose output .h5 already exists, checking only for existence and not integrity. A run interrupted mid-write can leave a truncated .h5 that is then treated as "done" and silently kept in the library. This adds src/openmc_data/other/remove_corrupt_h5.py, a small utility that scans a directory of .h5 files, opens each with h5py (an optional --deep pass fully loads neutron data with openmc), and removes any that are unreadable so a rerun regenerates them. A --dry-run flag reports without deleting. Wired up as the remove_corrupt_h5 console entry point. Closes #33
The develop branch of openmc now requires Python >=3.12, so installing it under the workflow's Python 3.9 failed with "Package 'openmc' requires a different Python". Bump to 3.12 to match the test_package and test_processing workflows, and update the deprecated checkout@v2 / setup-python@v2 actions to v4 / v5 as used by the other workflows.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem: interrupted runs can leave silently-corrupt HDF5 files
The
generate_*andconvert_*scripts support resuming: on a rerun they skip any input (ENDF/ACE) file whose output.h5already exists in the destination. The resume check tests only for existence, not integrity. Because processing runs in amultiprocessing.Pool, several.h5files are written concurrently, so an interrupt (Ctrl-C, crash, OOM, kill) during a write can leave files truncated / corrupt. On the next run those files look "already processed" and are skipped, so the corrupt file survives intocross_sections.xmland the error only surfaces later in OpenMC.What this adds
src/openmc_data/other/remove_corrupt_h5.py, a small cleanup utility to run before rerunning:Opening each file with
h5pyreliably catches truncated writes; the optional--deeppass additionally loads each file withopenmc.data.IncidentNeutron.from_hdf5for a stronger check.Wired up as the
remove_corrupt_h5console entry point inpyproject.toml, alongside the otherother/scripts.Closes #33