Skip to content

Add HDF5 file usage examples#45

Merged
everettVT merged 2 commits into
mainfrom
everettVT/hdf5-file-usage
Jun 30, 2026
Merged

Add HDF5 file usage examples#45
everettVT merged 2 commits into
mainfrom
everettVT/hdf5-file-usage

Conversation

@everettVT

Copy link
Copy Markdown
Contributor

Summary

  • Adds hdf5_func.py: demonstrates Daft's built-in HDF5 functions (hdf5_file, hdf5_attrs, hdf5_keys, hdf5_metadata) on a locally-created sample file
  • Adds hdf5_udf.py: demonstrates a custom UDF that reads DROID robotics trajectory data from HDF5 files using Hdf5File and to_tempfile()

Test plan

  • Run hdf5_func.py with uv run to verify sample file creation and built-in function output
  • Run hdf5_udf.py with uv run to verify DROID dataset UDF extraction

🤖 Generated with Claude Code

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>

@chatgpt-codex-connector chatgpt-codex-connector Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 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".

Comment thread examples/files/hdf5_func.py Outdated
# /// 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"]

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P2 Badge 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>
@everettVT everettVT merged commit 3fa57cf into main Jun 30, 2026
2 of 3 checks passed
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