pydata / pydata/xarray

Refactor async datatree loading to reuse open_groups_as_dict_async

Open
#11,131 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
Python
Stars
4.2k
Forks
1.4k
Avg merge
2d 15h
Merged PRs (30d)
14

Description

Summary

Follow-up from PR #10742 (async DataTree loading optimization). As suggested by @keewis in the PR review:

logically I think xr.open_datatree(...) == xr.DataTree.from_dict(xr.open_groups(...)), so it might make sense to have _open_datatree_async call _open_groups_as_dict_async

Current State

After #10742, the zarr backend has two similar async implementations:

  • _open_datatree_from_stores_async() - used by open_datatree()
  • open_groups_as_dict_async() - used by open_groups()

Both do similar work but with some differences:

  • Semaphore usage for concurrency control
  • Index creation handling

Proposed Change

Refactor _open_datatree_from_stores_async to internally call open_groups_as_dict_async, reducing code duplication and ensuring consistent behavior between the two APIs.

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the async entry points _open_datatree_from_stores_async and open_groups_as_dict_async, then review PR #10742 for the existing optimization context. Compare their semaphore and index-creation handling, and verify that datatree loading delegates through the groups-as-dict path with consistent behavior between the two APIs.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
data
Issue type
Refactor
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.