Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Using bothAsyncArray andArray fromFSSpecStore #2909

Open
Labels
bugPotential issues with the zarr-python library
@ilan-gold

Description

@ilan-gold

Zarr version

v3.0.5

Numcodecs version

0.15.1

Python Version

3.13

Operating System

Mac

Installation

uv

Description

Hello! I'm trying to create an api around zarr async and I came across an edge case, maybe. I would like to be able to open the zarr store synchronously (potentially), but then use it asynchronously (hopefully). This seems to be specific to this store and not to zarr async i.e., the following works with a local file instead of an http server. Any advice? It would be great to write code that is synchronous at the top level, but then hooks into async at a lower level.

The weird part is that most of theanndata tests pass with this paradigm - the problem only arises in a script, or ipython sessions. This is likely just specific to remote stores, not some feature of how the program is run. Something to do with the event loop certainly? Any advice?

Steps to reproduce

ran in ipython/jupyter/script

from __future__importannotationsimportasyncioimportzarr.apiimportzarr.api.asynchronousasyncdefmain():g=awaitzarr.api.asynchronous.open_array(store="http://127.0.0.1:8080/242b59a3-7398-4f0d-89fc-73cbc886d1b9.zarr/X/data"    )awaitg.getitem(Ellipsis)# worksg_sync=zarr.open_array("http://127.0.0.1:8080/242b59a3-7398-4f0d-89fc-73cbc886d1b9.zarr/X/data"    )await (awaitzarr.api.asynchronous.open_array(store=g_sync.store)).getitem(Ellipsis    )# failsawaitg_sync._async_array.getitem(())# failsif__name__=="__main__":asyncio.run(main())
Traceback (most recent call last):  File"/Users/ilangold/Projects/Theis/anndata/tester.py", line23, in<module>    asyncio.run(main())~~~~~~~~~~~^^^^^^^^  File"/opt/homebrew/Cellar/python@3.13/3.13.0_1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line194, inrunreturn runner.run(main)~~~~~~~~~~^^^^^^  File"/opt/homebrew/Cellar/python@3.13/3.13.0_1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/runners.py", line118, inrunreturnself._loop.run_until_complete(task)~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^  File"/opt/homebrew/Cellar/python@3.13/3.13.0_1/Frameworks/Python.framework/Versions/3.13/lib/python3.13/asyncio/base_events.py", line721, inrun_until_completereturn future.result()~~~~~~~~~~~~~^^  File"/Users/ilangold/Projects/Theis/anndata/tester.py", line17, inmainawait (await zarr.api.asynchronous.open_array(store=g_sync.store)).getitem(^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File"/Users/ilangold/Projects/Theis/anndata/venv/lib/python3.13/site-packages/zarr/api/asynchronous.py", line1256, inopen_arrayreturnawait AsyncArray.open(store_path,zarr_format=zarr_format)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File"/Users/ilangold/Projects/Theis/anndata/venv/lib/python3.13/site-packages/zarr/core/array.py", line896, inopen    metadata_dict=await get_array_metadata(store_path,zarr_format=zarr_format)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File"/Users/ilangold/Projects/Theis/anndata/venv/lib/python3.13/site-packages/zarr/core/array.py", line177, inget_array_metadata    zarr_json_bytes, zarray_bytes, zattrs_bytes=await gather(^^^^^^^^^^^^^...<3 lines>...    )^  File"/Users/ilangold/Projects/Theis/anndata/venv/lib/python3.13/site-packages/zarr/storage/_common.py", line124, ingetreturnawaitself.store.get(self.path,prototype=prototype,byte_range=byte_range)^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File"/Users/ilangold/Projects/Theis/anndata/venv/lib/python3.13/site-packages/zarr/storage/_fsspec.py", line230, inget    value= prototype.buffer.from_bytes(awaitself.fs._cat_file(path))^^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File"/Users/ilangold/Projects/Theis/anndata/venv/lib/python3.13/site-packages/fsspec/implementations/http.py", line234, in_cat_fileasyncwith session.get(self.encode_url(url),**kw)as r:~~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^^^^^^  File"/Users/ilangold/Projects/Theis/anndata/venv/lib/python3.13/site-packages/aiohttp/client.py", line1425, in__aenter__self._resp: _RetType=awaitself._coro^^^^^^^^^^^^^^^^  File"/Users/ilangold/Projects/Theis/anndata/venv/lib/python3.13/site-packages/aiohttp/client.py", line607, in_requestwith timer:^^^^^  File"/Users/ilangold/Projects/Theis/anndata/venv/lib/python3.13/site-packages/aiohttp/helpers.py", line636, in__enter__raiseRuntimeError("Timeout context manager should be used inside a task")

Additional output

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPotential issues with the zarr-python library

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions


      [8]ページ先頭

      ©2009-2025 Movatter.jp