Skip to content

ZipStore.list() fails if store not opened + lack of high-level listing API #3846

@kulvait

Description

@kulvait

Zarr version

v3.1.6 not fixed in 19a383f

Numcodecs version

v0.16.1

Python Version

3.12

Operating System

Linux

Installation

mamba, bug confirmed in latest Git of the project 19a383f

Description

ZipStore.list() uses _lock and _zf
but does not ensure the store is opened
leads to:
AttributeError: 'ZipStore' object has no attribute '_lock' when underlying store is not opened
I do not know if the behavior affects other types of stores.

Expected behavior

list() should ensure the store is opened (similar to _get()), e.g. by calling _sync_open() if needed.

Question

I’m not sure if this affects other store implementations as well, or only ZipStore.

Enhancement / API suggestion

Currently list() exposes raw storage keys (chunks, metadata), which is often not very useful at user level.

It would be helpful to have a higher-level API that lists logical Zarr objects (groups/arrays), for example:

zarr.list_nodes(store)

Steps to reproduce

import zarr
import zarr, asyncio

store = zarr.storage.ZipStore("data.zip", mode="r")

async def main():
return [k async for k in store.list()]

asyncio.run(main())

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