Skip to content

Add remove_corrupt_h5 utility to clean up interrupted runs - #35

Merged
shimwell merged 2 commits into
mainfrom
remove-corrupt-h5-utility
Jul 23, 2026
Merged

Add remove_corrupt_h5 utility to clean up interrupted runs#35
shimwell merged 2 commits into
mainfrom
remove-corrupt-h5-utility

Conversation

@shimwell

Copy link
Copy Markdown
Member

Problem: interrupted runs can leave silently-corrupt HDF5 files

The generate_* and convert_* scripts support resuming: on a rerun they skip any input (ENDF/ACE) file whose output .h5 already exists in the destination. The resume check tests only for existence, not integrity. Because processing runs in a multiprocessing.Pool, several .h5 files 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 into cross_sections.xml and 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:

remove_corrupt_h5 tendl-2025-hdf5            # remove truncated/corrupt files
remove_corrupt_h5 tendl-2025-hdf5 --deep     # also fully load each with openmc (neutron data)
remove_corrupt_h5 tendl-2025-hdf5 --dry-run  # report only

Opening each file with h5py reliably catches truncated writes; the optional --deep pass additionally loads each file with openmc.data.IncidentNeutron.from_hdf5 for a stronger check.

Wired up as the remove_corrupt_h5 console entry point in pyproject.toml, alongside the other other/ scripts.

Closes #33

shimwell added 2 commits July 23, 2026 22:07
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.
@shimwell
shimwell merged commit 2d54256 into main Jul 23, 2026
3 checks passed
@shimwell
shimwell deleted the remove-corrupt-h5-utility branch July 23, 2026 21:00
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.

Interrupted generate/convert runs can leave silently-corrupt HDF5 files (resume skips by existence, not integrity)

1 participant