Skip to content

[v3] creating a new array with path should create a root group node if it doesn't exist #2187

Closed
@jhamman

Description

@jhamman

Zarr version

3.0.0.alpha4

Numcodecs version

N/A

Python Version

3.11

Operating System

Local install

Installation

pip install -e .

Description

The current behavior on the v3 branch diverges from v2 when creating a new array w/ a path. In v2, zarr creates a root group node when creating a new array. But in v3, we only create the array node. This means that you can't do the following:

In [1]: import zarr

In [2]: foo = zarr.create(shape=(3, 1), path='foo', store='/Users/jhamman/workdir/test-store', mode='w')

In [3]: root = zarr.open_group(store='/Users/jhamman/workdir/test-store', mode='r')

In [4]: root['foo']

Steps to reproduce

examining the store contents after creating of the array explains the difference

in v2 👇

In [1]: import zarr

In [2]: x = zarr.create(shape=(3, 0), path='foo')

In [3]: list(x.store.keys())
Out[3]: ['.zgroup', 'foo/.zarray']

in v3 👇

In [1]: import zarr

In [2]: x = zarr.create(shape=(3, 0), path='foo')

In [3]: [_ async for _ in x.store.list()]
Out[3]: ['foo/zarr.json']

Additional output

xref: #2186, dask/dask#11388

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugPotential issues with the zarr-python library

    Type

    No type

    Projects

    Status

    Done

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions