Skip to content

Fix check for swmr compatibility in h5 files#368

Open
pblowey wants to merge 2 commits into
mainfrom
fix-h5-validation
Open

Fix check for swmr compatibility in h5 files#368
pblowey wants to merge 2 commits into
mainfrom
fix-h5-validation

Conversation

@pblowey
Copy link
Copy Markdown
Contributor

@pblowey pblowey commented May 26, 2026

The validation service checks files to ensure that the h5 files are not compatible with HDF5 versions <= 1.8, with the intention of ensuring that files are written in a SWMR compatible file format (SWMR was introduced in HDF5 1.10). The check (added in #25) operated by trying to open the file using library version bounds of ("earliest", "v108") and would determine a file to be incompatible if an OSError was returned.

With the release of hdf5 library versions > 2.0, which the dials build now uses, the behaviour of with h5py.File(filename, "r", libver=("earliest", "v108")): has changed and will now successfully open files even if they contain/use objects/features incompatible with the older libraries, including swmr. This is because the intention of the libver bounds is to ensure library compatibility of new objects created thereafter and is not supposed to affect initial file access, but this was not implemented correctly in hdf5 < 2.0 (see the discussion here for details).

This PR fixes the check by instead finding the super block version of the hdf5 file. SWMR requires a superblock version >= 3, so this is used to determine whether the file is swmr compatible. The check does not establish whether the file is SWMR mode is enabled in the file.

This PR also adds a test for the SWMR compatibility check.

pblowey added 2 commits May 26, 2026 12:53
Previous check of SWMR compatibility was trying to open the file with
old HDF5 library versions, to see if an error was raised. With HDF5>2.0
this no longer works because a fix was implemented to only raise an
error when trying to create or write new objects that are incompatible
rather than when opening the file.
@pblowey pblowey requested a review from ndevenish May 26, 2026 14:06
@pblowey pblowey self-assigned this May 26, 2026
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.

1 participant