Skip to content

Commit ed90338

Browse files
authored
Fix hdf5 read with broken links (#904)
* Update hdf5.py Resolves issue with loading Dectris-compressed data (lzf compression if I'm not mistaken). * Update pyproject.toml Added import of hdf5plugin * Update hdf5.py ignore flake8 here. * Update hdf5.py Fighting flake8 * Update CHANGELOG.md Fixed the years of previous changelog entries, and added mine. * Update CHANGELOG.md Fixing a trailing whitespace for flake8's pleasure. * fix to pass broken external HDF5 links less destructively. * Update CHANGELOG.md message on the graceful handling of broken external links in HDF5 files. * getting flake8 to pass in vs code first. * flake8 is more strict on the CI/CD end. * Todo note added with reference to the PR detailing the issue
1 parent 4bc8b6b commit ed90338

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
Write the date in place of the "Unreleased" in the case a new version is released. -->
33
# Changelog
44

5+
56
## 0.1.0-b20 (2025-03-07)
67

78
### Added
@@ -14,6 +15,7 @@ Write the date in place of the "Unreleased" in the case a new version is release
1415
- Added an hdf5plugin import to handle reading lzf-compressed data from Dectris Eiger HDF5 files.
1516
- Removed no-op `?include_data_sources=false` (which is the default) from some
1617
requests issued by the Python client.
18+
- Added a try-except statement to gracefully skip over broken external links in HDF5 files.
1719

1820
### Maintenance
1921

tiled/adapters/hdf5.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,15 @@ def __iter__(self) -> Iterator[Any]:
142142
yield from self._file
143143

144144
def __getitem__(self, key: str) -> Union["HDF5Adapter", ArrayAdapter]:
145-
value = self._file[key]
145+
# TODO: Handle broken external links better in the future. See tiled PR #904.
146+
try:
147+
value = self._file[key]
148+
except KeyError as e:
149+
warnings.warn(
150+
f"KeyError: {e}, probably broken external link. Returning warning as value:"
151+
)
152+
return from_dataset(numpy.array([f"KeyError: {e}"]))
153+
146154
if isinstance(value, h5py.Group):
147155
return HDF5Adapter(value)
148156
else:

0 commit comments

Comments
 (0)