Skip to content

Add xarray.open_zarr_async() - #11580

Open
davidbrochart wants to merge 4 commits into
pydata:mainfrom
davidbrochart:open-zarr-async
Open

Add xarray.open_zarr_async()#11580
davidbrochart wants to merge 4 commits into
pydata:mainfrom
davidbrochart:open-zarr-async

Conversation

@davidbrochart

@davidbrochart davidbrochart commented Sep 10, 2026

Copy link
Copy Markdown
Contributor

Description

It looks like Zarr has an async API for opening a store, but xarray doesn't. There is only the sync open_zarr(), which calls the sync Zarr API which runs the async API in an event loop in a separate thread. I understand that this is not in the critical path (it's metadata), but that prevents using xarray in WASM Python, since threads are not supported there.

Checklist

  • Closes #xxxx
  • Tests added
  • User visible changes (including notable bug fixes) are documented in whats-new.rst
  • New functions/methods are listed in api.rst

AI Disclosure

  • This PR contains AI-generated content.
    • I have tested any AI-generated content in my PR.

    • I take responsibility for any AI-generated content in my PR.

      Tools: Codex
      Prompt: "it looks like xarray's open_zarr is a synchronous function that eventually calls zarr's sync API that runs the async API in an event loop in a separate thread, so that won't work for WASM python where threads are not supported. is there a way to open a zarr store asynchronously in xarray? if not, could you make changes that add the async equivalent to open_zarr?"

@github-actions github-actions Bot added topic-backends topic-zarr Related to zarr storage library io labels Sep 10, 2026
@davidbrochart

Copy link
Copy Markdown
Contributor Author

What do you think @shoyer ?

@shoyer

shoyer commented Sep 11, 2026

Copy link
Copy Markdown
Member

To me, a name like open_zarr_async would suggest opening a Zarr store inside native async data structures in Xarray -- which do not exist!

Instead, it might make sense to expose an option to disable running the event loop in a separate thread inside open_zarr itself? If it makes things easier, we could drop support for Zarr Python v2 at this point.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

io topic-backends topic-zarr Related to zarr storage library

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants