Skip to content

perf: add sparse decode option - #13

Merged
TheGreatAlgo merged 4 commits into
mainfrom
perf/sparse-decode
Jul 10, 2026
Merged

perf: add sparse decode option#13
TheGreatAlgo merged 4 commits into
mainfrom
perf/sparse-decode

Conversation

@cmanna75

@cmanna75 cmanna75 commented Jul 10, 2026

Copy link
Copy Markdown
Collaborator

Exposes the new py-hamt sparse shard decoding option when loading datasets from IPFS.

The "full" option remains the default to preserve existing behavior.

Summary by CodeRabbit

  • New Features

    • Added a shard_read_mode option for dataset loading to control how sharded Zarr shards are decoded.
    • Supports full and sparse, defaulting to sparse.
    • Applies consistently for datasets loaded directly or via STAC resolution.
  • Bug Fixes

    • Improved sharded dataset retrieval behavior for sparse reading, including correct end-to-end propagation through the loading pipeline.
  • Chores

    • Updated the package version to 0.5.11.

@coderabbitai

coderabbitai Bot commented Jul 10, 2026

Copy link
Copy Markdown

Review Change Stack

Important

Review skipped

Review was skipped due to path filters

⛔ Files ignored due to path filters (1)
  • uv.lock is excluded by !**/*.lock

CodeRabbit blocks several paths by default. You can override this behavior by explicitly including those paths in the path filters. For example, including **/dist/** will override the default block on the dist directory, by removing the pattern from both the lists.

⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: c12d8e72-f1b2-4958-a364-4cd413bd4ff4

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

load_dataset now accepts "full" or "sparse" shard read modes and forwards the selected mode through direct-CID and STAC-based IPFS loading into sharded Zarr store opening. Tests update mocks and verify sparse-mode propagation. The package version and minimum py_hamt dependency are also updated.

Changes

Shard read mode

Layer / File(s) Summary
Public loading API
dclimate_client_py/dclimate_client.py
load_dataset exposes the typed shard_read_mode parameter, documents its behavior, and forwards it through both loading paths.
Sharded retrieval and validation
dclimate_client_py/ipfs_retrieval.py, tests/test_ipfs_retrieval.py
IPFS retrieval passes shard read mode to ShardedZarrStore.open; tests update stubs and assert sparse-mode propagation.
Release metadata
pyproject.toml
The package version changes to 0.5.11, and the minimum py_hamt version changes to 3.4.1.

Estimated code review effort: 2 (Simple) | ~10 minutes

Sequence Diagram(s)

sequenceDiagram
  participant Client as dClimateClient.load_dataset
  participant Loader as _load_dataset_from_ipfs_cid
  participant Store as ShardedZarrStore.open
  Client->>Loader: shard_read_mode
  Loader->>Store: shard_read_mode
Loading

Possibly related PRs

🚥 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 clearly matches the main change: adding a sparse decode option for dataset loading.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% which is sufficient. The required threshold is 80.00%.
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 unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch perf/sparse-decode

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.

Actionable comments posted: 1

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

250-264: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Document shard_read_mode in the internal loader docstring.

The signature adds this argument, but the Args section stops at zarr_group. Document its allowed values and default so the internal contract matches the implementation.

🤖 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/ipfs_retrieval.py` around lines 250 - 264, The internal
loader’s docstring omits the shard_read_mode argument. Update the Args section
for the loader function to document shard_read_mode, including its allowed
values and default of "full", matching the signature and implementation.
dclimate_client_py/dclimate_client.py (1)

322-322: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Cover the STAC forwarding branch.

The supplied test exercises cid=VALID_CID, proving only the direct-CID forwarding at Line 243. Add or verify a STAC-path test that asserts "sparse" reaches _load_dataset_from_ipfs_cid at this separate call site.

🤖 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` at line 322, The STAC forwarding path
must preserve the requested shard read mode. Add or update a test for the STAC
branch in the relevant dataset-loading flow, using a STAC identifier rather than
a direct CID, and assert that _load_dataset_from_ipfs_cid receives
shard_read_mode="sparse" at the call site containing
shard_read_mode=shard_read_mode.
tests/test_ipfs_retrieval.py (1)

54-55: 🎯 Functional Correctness | 🔵 Trivial | ⚡ Quick win

Assert the forwarded mode in a sharded-store test.

These stubs accept shard_read_mode but ignore it, so the suite would still pass if the forwarding at dclimate_client_py/ipfs_retrieval.py:324 were removed. Capture the argument in one sparse-mode case and assert the default path receives "full".

Also applies to: 72-73, 96-97, 120-121, 142-148, 175-176

🤖 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 54 - 55, The sharded-store test
stubs ignore the forwarded shard mode, so forwarding regressions are undetected.
Update the relevant sharded_open stubs to capture shard_read_mode, then assert
the sparse-mode case receives the expected sparse value and the default path
receives "full"; apply this across all referenced test cases.
🤖 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.

Inline comments:
In `@dclimate_client_py/ipfs_retrieval.py`:
- Line 19: The py-hamt dependency version does not support ShardReadMode or the
shard_read_mode argument used by ShardedZarrStore.open. Update ipfs_retrieval.py
to use the API exposed by the pinned py-hamt version, removing or replacing the
unsupported import and argument, or bump the dependency to a compatible version
and update its pin consistently.

---

Nitpick comments:
In `@dclimate_client_py/dclimate_client.py`:
- Line 322: The STAC forwarding path must preserve the requested shard read
mode. Add or update a test for the STAC branch in the relevant dataset-loading
flow, using a STAC identifier rather than a direct CID, and assert that
_load_dataset_from_ipfs_cid receives shard_read_mode="sparse" at the call site
containing shard_read_mode=shard_read_mode.

In `@dclimate_client_py/ipfs_retrieval.py`:
- Around line 250-264: The internal loader’s docstring omits the shard_read_mode
argument. Update the Args section for the loader function to document
shard_read_mode, including its allowed values and default of "full", matching
the signature and implementation.

In `@tests/test_ipfs_retrieval.py`:
- Around line 54-55: The sharded-store test stubs ignore the forwarded shard
mode, so forwarding regressions are undetected. Update the relevant sharded_open
stubs to capture shard_read_mode, then assert the sparse-mode case receives the
expected sparse value and the default path receives "full"; apply this across
all referenced test cases.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: d25ed968-ebd0-427c-b15e-c63aa9493fcf

📥 Commits

Reviewing files that changed from the base of the PR and between 54b8dab and 8bb255b.

📒 Files selected for processing (3)
  • dclimate_client_py/dclimate_client.py
  • dclimate_client_py/ipfs_retrieval.py
  • tests/test_ipfs_retrieval.py

Comment thread dclimate_client_py/ipfs_retrieval.py

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

Actionable comments posted: 1

🤖 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.

Inline comments:
In `@pyproject.toml`:
- Line 9: Regenerate uv.lock after updating the project version and py_hamt
requirement so it records version 0.5.11 and resolves py_hamt to at least 3.4.1;
commit the resulting lockfile with the changes.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: bae23ba7-7827-4113-916b-28eab7030b28

📥 Commits

Reviewing files that changed from the base of the PR and between 4f00cb5 and 1a7feed.

📒 Files selected for processing (1)
  • pyproject.toml

Comment thread pyproject.toml
@TheGreatAlgo
TheGreatAlgo merged commit ab67dd8 into main Jul 10, 2026
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.

2 participants