Skip to content

zarr.open_array duplicates path key? #2166

@TomAugspurger

Description

@TomAugspurger

Zarr version

v3

Numcodecs version

n/a

Python Version

n/a

Operating System

n/a

Installation

n/a

Description

I'm looking into some of the xarray tests, and noticed this strange(?) change from V2. It seems like zarr.open_array with path="a" will write the data to a/a/, so that the metadata is at key a/a/zarr.json. I would have expected it to be at a/zarr.json. Is this expected?

Steps to reproduce

# v3
import zarr
import shutil
shutil.rmtree("/tmp/data.zarr", ignore_errors=True)

store = zarr.store.LocalStore(root="/tmp/data.zarr", mode="w")
a = zarr.open_array(store=store, path="a", shape=(4,))
b = zarr.open_array(store=store, path="b", shape=(4,))
[x async for x in store.list()]

gives

['a/a/zarr.json', 'b/b/zarr.json']

and the arrays must be opened with zarr.open_array(store=store, path="a/a").

Contrast that with V2, where you have

import zarr


store = "/tmp/v2.zarr"
a = zarr.open_array(store=store, path="a", shape=(4,))
b = zarr.open_array(store=store, path="b", shape=(4,))

g = zarr.open_group("/tmp/v2.zarr")
list(g.array_keys())

give ['a', 'b'] and you open the arrays with zarr.open_array(store=store, path="a").

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