Add HDF5 file usage examples#45
Conversation
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
There was a problem hiding this comment.
💡 Codex Review
Here are some automated review suggestions for this pull request.
Reviewed commit: b0b3479e98
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
| # /// script | ||
| # description = "Read a HDF5 file and return a struct of the requested fields" | ||
| # requires-python = ">=3.12, <3.13" | ||
| # dependencies = ["daft[hdf5]>=0.7.16"] |
There was a problem hiding this comment.
Declare real HDF5 dependencies
When these PEP 723 scripts are run in a fresh uv run environment, daft 0.7.16 does not provide an hdf5 extra, so this requirement does not install h5py (or numpy for hdf5_func.py). Both new scripts import h5py immediately, so the advertised self-contained examples fail with ModuleNotFoundError; please list the actual dependencies explicitly or use a published Daft extra that exists.
Useful? React with 👍 / 👎.
|
|
||
| import daft | ||
| from daft import col | ||
| from daft.functions import hdf5_attrs, hdf5_file, hdf5_keys, hdf5_metadata |
There was a problem hiding this comment.
Avoid importing unavailable HDF5 helpers
With the declared daft>=0.7.16 dependency, daft.functions does not export these HDF5 helpers, and even the current HDF5 wrapper surface does not include hdf5_attrs or hdf5_metadata. Running this example therefore fails at import time before the sample file is created; please use exported functions or wrap Hdf5File.attrs() / metadata() in UDFs.
Useful? React with 👍 / 👎.
| import h5py | ||
|
|
||
| import daft | ||
| from daft import DataType, Hdf5File, col |
There was a problem hiding this comment.
Import Hdf5File from its exported module
When this example is run with the declared Daft package, Hdf5File is not exported from the top-level daft module, so from daft import ... Hdf5File ... raises ImportError before the UDF is registered. Import it from the file module that exports it, or avoid the annotation if it is not part of the public top-level API.
Useful? React with 👍 / 👎.
Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
Summary
hdf5_func.py: demonstrates Daft's built-in HDF5 functions (hdf5_file,hdf5_attrs,hdf5_keys,hdf5_metadata) on a locally-created sample filehdf5_udf.py: demonstrates a custom UDF that reads DROID robotics trajectory data from HDF5 files usingHdf5Fileandto_tempfile()Test plan
hdf5_func.pywithuv runto verify sample file creation and built-in function outputhdf5_udf.pywithuv runto verify DROID dataset UDF extraction🤖 Generated with Claude Code