Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 9 additions & 0 deletions docs/release.rst
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,15 @@ Release notes

.. _release_2.13.4:

2.13.5
------

Bug fixes
~~~~~~~~~

* Ensure ``zarr.create`` uses writeable mode to fix issue with :issue:`1304`.
By :user:`James Bourbeau <jrbourbeau>` :issue:`1309`.

2.13.4
------

Expand Down
2 changes: 1 addition & 1 deletion zarr/creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -145,7 +145,7 @@ def create(shape, chunks=True, dtype=None, compressor='default',
zarr_version = getattr(chunk_store, '_store_version', DEFAULT_ZARR_VERSION)

# handle polymorphic store arg
store = normalize_store_arg(store, zarr_version=zarr_version)
store = normalize_store_arg(store, zarr_version=zarr_version, mode="w")
zarr_version = getattr(store, '_store_version', DEFAULT_ZARR_VERSION)

# API compatibility with h5py
Expand Down
14 changes: 13 additions & 1 deletion zarr/tests/test_creation.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
from zarr._storage.store import v3_api_available
from zarr._storage.v3 import DirectoryStoreV3, KVStoreV3
from zarr.sync import ThreadSynchronizer
from zarr.tests.util import mktemp
from zarr.tests.util import mktemp, have_fsspec

_VERSIONS = ((None, 2, 3) if v3_api_available else (None, 2))
_VERSIONS2 = ((2, 3) if v3_api_available else (2, ))
Expand Down Expand Up @@ -429,6 +429,18 @@ def test_create_in_dict(zarr_version, at_root):
assert isinstance(a.store, expected_store_type)


@pytest.mark.skipif(have_fsspec is False, reason="needs fsspec")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is fsspec needed to reproduce this bug? In my reading of the code, it it should only affect stores that have a mode argument in their constructor. That is:

  • FSStore
  • ZipStore
  • DBMStore

The fact that not all stores accept the mode keyword it, to me, a Zarr code smell.

@pytest.mark.parametrize('zarr_version', _VERSIONS)
@pytest.mark.parametrize('at_root', [False, True])
def test_create_writeable_mode(zarr_version, at_root, tmp_path):
# Regression test for https://github.com/zarr-developers/zarr-python/issues/1306
import fsspec
kwargs = _init_creation_kwargs(zarr_version, at_root)
store = fsspec.get_mapper(str(tmp_path))
z = create(100, store=store, **kwargs)
assert z.store.map == store


@pytest.mark.parametrize('zarr_version', _VERSIONS)
@pytest.mark.parametrize('at_root', [False, True])
def test_empty_like(zarr_version, at_root):
Expand Down