Skip to content

Update py-hamt to 3.4.0 - #11

Merged
TheGreatAlgo merged 4 commits into
mainfrom
agent/py-hamt-3-4-0-client-update
Jul 8, 2026
Merged

Update py-hamt to 3.4.0#11
TheGreatAlgo merged 4 commits into
mainfrom
agent/py-hamt-3-4-0-client-update

Conversation

@0xSwego

@0xSwego 0xSwego commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator

Summary

Updates the client to use py-hamt 3.4.0 and adapts IPFS Zarr loading for the new sharded store behavior introduced in dClimate/py-hamt#86.

What changed

  • Bumped py_hamt to >=3.4.0 and refreshed uv.lock to resolve py-hamt 3.4.0.
  • Added optional zarr_group support to dClimateClient.load_dataset() and the legacy CID loader.
  • Auto-opens group "0" when a py-hamt v2 sharded store reports multiple top-level groups and that safe default is available.
  • Suppresses py-hamt legacy v1 deprecation warnings inside the client read path.
  • Keeps post-sharded-open Zarr/group errors from being masked by the HAMT fallback.
  • Documents the new zarr_group option and metadata field.

Why

py-hamt 3.4.0 adds path-aware sharded Zarr v2 support and can require explicit Zarr groups for pyramid/multi-group layouts. The client now handles the common group "0" layout automatically while still allowing callers to specify another group explicitly.

Validation

  • uv run --extra testing pytest tests/test_ipfs_retrieval.py -q
  • uv run --extra dev ruff check dclimate_client_py/ipfs_retrieval.py dclimate_client_py/dclimate_client.py dclimate_client_py/datasets.py tests/test_ipfs_retrieval.py

Summary by CodeRabbit

  • New Features
    • load_dataset() now supports an optional zarr_group argument for loading grouped/pyramid Zarr datasets.
    • Returned dataset metadata can include the selected zarr_group.
  • Bug Fixes
    • Improved handling of multi-group Zarr stores, including defaulting to group "0" when appropriate.
    • Reduced unexpected fallback behavior and suppressed a noisy Zarr deprecation warning.
  • Documentation
    • Updated API docs and examples to demonstrate using zarr_group.
  • Tests
    • Added coverage for group selection, metadata reporting, warning suppression, and fallback behavior.
  • Chores
    • Bumped package version to 0.5.10 and updated the py_hamt dependency constraint.

@coderabbitai

coderabbitai Bot commented Jul 7, 2026

Copy link
Copy Markdown

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 1d983051-90c4-4e0c-b2b9-8a00268bdde3

📥 Commits

Reviewing files that changed from the base of the PR and between 00fd4c7 and 67cd871.

📒 Files selected for processing (2)
  • dclimate_client_py/dclimate_client.py
  • tests/test_ipfs_retrieval.py
🚧 Files skipped from review as they are similar to previous changes (2)
  • tests/test_ipfs_retrieval.py
  • dclimate_client_py/dclimate_client.py

📝 Walkthrough

Walkthrough

This PR adds an optional zarr_group parameter to dClimateClient.load_dataset and the IPFS Zarr loading path, records the selected group in dataset metadata, updates tests and examples, and bumps the py_hamt dependency version.

Changes

zarr_group support

Layer / File(s) Summary
DatasetMetadata contract and dependency bump
dclimate_client_py/datasets.py, pyproject.toml
Adds zarr_group to DatasetMetadata and bumps py_hamt to >=3.4.0.
IPFS Zarr group opening helpers
dclimate_client_py/ipfs_retrieval.py
Adds group normalization/inference helpers, centralized Zarr opening, and warning suppression for sharded store open.
_load_dataset_from_ipfs_cid group-aware loading and fallback changes
dclimate_client_py/ipfs_retrieval.py
Threads zarr_group through sharded and HAMT loading, records _ipfs_zarr_group, changes fallback behavior after sharded open, and updates the legacy wrapper.
dClimateClient.load_dataset zarr_group parameter and metadata propagation
dclimate_client_py/dclimate_client.py
Adds zarr_group to load_dataset, forwards it through both loading paths, and copies _ipfs_zarr_group into returned metadata.
Tests for zarr_group behavior
tests/test_ipfs_retrieval.py
Adds async tests for default/explicit group selection, fallback behavior, warning suppression, and metadata forwarding.
Documentation and README examples
DATASET_CATALOG_USAGE.md, README.md
Updates API docs and examples to show zarr_group=\"0\".

Estimated code review effort: 3 (Moderate) | ~25 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Caller
  participant dClimateClient
  participant IpfsRetrieval as _load_dataset_from_ipfs_cid
  participant Dataset as xarray.Dataset

  Caller->>dClimateClient: load_dataset(cid, zarr_group)
  dClimateClient->>IpfsRetrieval: _load_dataset_from_ipfs_cid(cid, zarr_group)
  IpfsRetrieval->>Dataset: open_zarr(group) and set _ipfs_zarr_group attr
  Dataset-->>dClimateClient: dataset with _ipfs_zarr_group attr
  dClimateClient-->>Caller: metadata with zarr_group
Loading

Possibly related PRs

  • dClimate/dclimate-client-py#7: Both PRs modify _load_dataset_from_ipfs_cid in dclimate_client_py/ipfs_retrieval.py, touching the same loading flow.
🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title matches a real change in the PR: bumping py-hamt to 3.4.0.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch agent/py-hamt-3-4-0-client-update

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai 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.

🧹 Nitpick comments (3)
dclimate_client_py/dclimate_client.py (1)

251-253: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Duplicate zarr_group extraction logic.

The ds.attrs.get("_ipfs_zarr_group") / isinstance check is repeated verbatim for both the direct-CID and STAC-resolved paths. Consider extracting a small helper to keep the two call sites in sync as this logic evolves.

♻️ Suggested helper extraction
+    `@staticmethod`
+    def _apply_zarr_group_metadata(ds: xr.Dataset, metadata: DatasetMetadata) -> None:
+        loaded_zarr_group = ds.attrs.get("_ipfs_zarr_group")
+        if isinstance(loaded_zarr_group, str):
+            metadata["zarr_group"] = loaded_zarr_group

Then replace both occurrences with self._apply_zarr_group_metadata(ds, metadata).

Also applies to: 335-337

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@dclimate_client_py/dclimate_client.py` around lines 251 - 253, The
`_ipfs_zarr_group` extraction is duplicated in both the direct-CID and
STAC-resolved paths, so updates could drift between the two call sites. Extract
the repeated `ds.attrs.get("_ipfs_zarr_group")` and `isinstance(..., str)` logic
into a small helper on `DClimateClient` (for example,
`_apply_zarr_group_metadata`), then call that helper from both locations so
`metadata["zarr_group"]` is set consistently.
tests/test_ipfs_retrieval.py (2)

116-140: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Coverage gap: zarr_group forwarding during a real HAMT fallback isn't tested.

This test covers the "sharded store opens, but the zarr-group open itself fails" no-fallback path. Per the retrieval logic (_load_dataset_from_ipfs_cid), there's a separate scenario where _open_sharded_zarr_store itself fails and the code falls back to HAMT.build + ZarrHAMTStore, also passing zarr_group through to _open_zarr_from_store. None of the added tests exercise that fallback path with an explicit zarr_group, so a regression there (e.g., zarr_group silently dropped on the HAMT branch) wouldn't be caught.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_ipfs_retrieval.py` around lines 116 - 140, The current test only
covers the non-fallback failure path after ShardedZarrStore.open succeeds, but
it does not verify that zarr_group is preserved when _load_dataset_from_ipfs_cid
falls back to HAMT.build and ZarrHAMTStore. Add a test that makes
ShardedZarrStore.open fail, forces the HAMT fallback, and then asserts
_open_zarr_from_store (or xr.open_zarr through it) receives the explicit
zarr_group argument on that branch. Use the existing
_load_dataset_from_ipfs_cid, _open_sharded_zarr_store, HAMT.build, and
_open_zarr_from_store symbols to target the fallback path.

89-140: 📐 Maintainability & Code Quality | 🔵 Trivial | 💤 Low value

Minor duplication across Dummy store stubs.

DummyStore/DummyGroupedStore-style classes are redefined per-test with identical pass bodies. Consider hoisting a shared minimal stub (or a small factory) at module scope to reduce repetition across tests 2-4.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@tests/test_ipfs_retrieval.py` around lines 89 - 140, There is repeated
DummyStore-style test scaffolding with identical empty class bodies across the
IPFS retrieval tests, so consolidate it into a shared minimal stub or small
factory at module scope and reuse it from the affected tests. Update the tests
around _load_dataset_from_ipfs_cid, ShardedZarrStore.open, and HAMT.build so
each case uses the common helper instead of redefining the same placeholder
class inline.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Nitpick comments:
In `@dclimate_client_py/dclimate_client.py`:
- Around line 251-253: The `_ipfs_zarr_group` extraction is duplicated in both
the direct-CID and STAC-resolved paths, so updates could drift between the two
call sites. Extract the repeated `ds.attrs.get("_ipfs_zarr_group")` and
`isinstance(..., str)` logic into a small helper on `DClimateClient` (for
example, `_apply_zarr_group_metadata`), then call that helper from both
locations so `metadata["zarr_group"]` is set consistently.

In `@tests/test_ipfs_retrieval.py`:
- Around line 116-140: The current test only covers the non-fallback failure
path after ShardedZarrStore.open succeeds, but it does not verify that
zarr_group is preserved when _load_dataset_from_ipfs_cid falls back to
HAMT.build and ZarrHAMTStore. Add a test that makes ShardedZarrStore.open fail,
forces the HAMT fallback, and then asserts _open_zarr_from_store (or
xr.open_zarr through it) receives the explicit zarr_group argument on that
branch. Use the existing _load_dataset_from_ipfs_cid, _open_sharded_zarr_store,
HAMT.build, and _open_zarr_from_store symbols to target the fallback path.
- Around line 89-140: There is repeated DummyStore-style test scaffolding with
identical empty class bodies across the IPFS retrieval tests, so consolidate it
into a shared minimal stub or small factory at module scope and reuse it from
the affected tests. Update the tests around _load_dataset_from_ipfs_cid,
ShardedZarrStore.open, and HAMT.build so each case uses the common helper
instead of redefining the same placeholder class inline.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 4261196f-275e-401a-b854-e2d956cd7874

📥 Commits

Reviewing files that changed from the base of the PR and between bc93bb9 and 4dc86a5.

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock
📒 Files selected for processing (7)
  • DATASET_CATALOG_USAGE.md
  • README.md
  • dclimate_client_py/datasets.py
  • dclimate_client_py/dclimate_client.py
  • dclimate_client_py/ipfs_retrieval.py
  • pyproject.toml
  • tests/test_ipfs_retrieval.py

@0xSwego

0xSwego commented Jul 7, 2026

Copy link
Copy Markdown
Collaborator Author

Handled the CodeRabbit review feedback in 6ebada7:

  • extracted _apply_zarr_group_metadata() so direct-CID and STAC paths share the same zarr group metadata handling
  • added HAMT fallback coverage proving an explicit zarr_group is preserved when the sharded-open path falls back
  • consolidated the repeated dummy store test stubs

Validation: uv run --extra testing pytest tests/test_ipfs_retrieval.py -q and uv run --extra dev ruff check dclimate_client_py/dclimate_client.py tests/test_ipfs_retrieval.py.

@TheGreatAlgo
TheGreatAlgo merged commit 1369acd into main Jul 8, 2026
4 checks passed
This was referenced Jul 8, 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.

2 participants