Skip to content

feat(hdf5): add native HDF5 file type - #1955

Draft
yathomasi wants to merge 1 commit into
mainfrom
yathomasi/1909-hdf5-file-type
Draft

feat(hdf5): add native HDF5 file type#1955
yathomasi wants to merge 1 commit into
mainfrom
yathomasi/1909-hdf5-file-type

Conversation

@yathomasi

Copy link
Copy Markdown
Contributor

Summary

Adds a native HDF5 type so datasets can be inspected and sliced through DataChain without reading the whole file in a generator. Mirrors Zarr: metadata as columns for pushdown, plus a lazy region handle for later reads / image preview.

Details

  • Hdf5File (File subclass) opened via read_storage(..., type="hdf5") or File.as_hdf5_file(); h5py uses the existing streaming handle (read/seek/tell)
  • Hdf5Dataset exposes shape, chunks, dtype, attrs; Hdf5Selection is a lazy slice materialized with read() / read_bytes() (PNG for Studio)
  • Models live in datachain.lib.hdf5 and are not re-exported, so import datachain does not load h5py (same pattern as Zarr)
  • Optional extra: pip install 'datachain[hdf5]' (h5py>=3.11)

Out of scope: NetCDF4 / LeRobot layouts (files still load as plain HDF5); no read_hdf5() reader (one file = one object); Will follow up on studio preview wiring.

- Hdf5File streams file handle, fetches dataset/slice without full read (h5py: read/seek/tell via FileWrapper)
- Hdf5Dataset columns: shape, chunks, dtype, attrs for pushdown; Hdf5Selection = lazy region, becomes image bytes for preview
- cast h5py attrs (ndarray, np scalar, bytes) to Python for JSON column
- access: read_storage(type="hdf5") or File.as_hdf5_file(); no extra reader (HDF5 = one object)
- models not re-exported, so import datachain skips h5py (like zarr)
- optional [hdf5] extra; no version gate, h5py wheels 3.10-3.14

- implements #1909
@cloudflare-workers-and-pages

Copy link
Copy Markdown

Deploying datachain with  Cloudflare Pages  Cloudflare Pages

Latest commit: faa399f
Status: ✅  Deploy successful!
Preview URL: https://b6743678.datachain-2g6.pages.dev
Branch Preview URL: https://yathomasi-1909-hdf5-file-typ.datachain-2g6.pages.dev

View logs

@codecov

codecov Bot commented Aug 24, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 96.55172% with 4 lines in your changes missing coverage. Please review.

Files with missing lines Patch % Lines
src/datachain/lib/hdf5.py 96.19% 3 Missing and 1 partial ⚠️

📢 Thoughts on this report? Let us know!

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