Skip to content

Commit 1fd607a

Browse files
jrbourbeaujoshmooresanketverma1704
authored
Ensure zarr.create uses writeable mode (zarr-developers#1309)
* Ensure zarr.create uses writeable mode * Update release.rst Added release notes for [zarr-developers#1309](zarr-developers#1309) * Switch to bug fix Co-authored-by: Josh Moore <josh@openmicroscopy.org> Co-authored-by: Sanket Verma <svsanketverma5@gmail.com>
1 parent 876ccf2 commit 1fd607a

File tree

3 files changed

+23
-2
lines changed

3 files changed

+23
-2
lines changed

docs/release.rst

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,15 @@ Release notes
1616
1717
.. _release_2.13.4:
1818

19+
2.13.5
20+
------
21+
22+
Bug fixes
23+
~~~~~~~~~
24+
25+
* Ensure ``zarr.create`` uses writeable mode to fix issue with :issue:`1304`.
26+
By :user:`James Bourbeau <jrbourbeau>` :issue:`1309`.
27+
1928
2.13.4
2029
------
2130

zarr/creation.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -145,7 +145,7 @@ def create(shape, chunks=True, dtype=None, compressor='default',
145145
zarr_version = getattr(chunk_store, '_store_version', DEFAULT_ZARR_VERSION)
146146

147147
# handle polymorphic store arg
148-
store = normalize_store_arg(store, zarr_version=zarr_version)
148+
store = normalize_store_arg(store, zarr_version=zarr_version, mode="w")
149149
zarr_version = getattr(store, '_store_version', DEFAULT_ZARR_VERSION)
150150

151151
# API compatibility with h5py

zarr/tests/test_creation.py

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
from zarr._storage.store import v3_api_available
2020
from zarr._storage.v3 import DirectoryStoreV3, KVStoreV3
2121
from zarr.sync import ThreadSynchronizer
22-
from zarr.tests.util import mktemp
22+
from zarr.tests.util import mktemp, have_fsspec
2323

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

431431

432+
@pytest.mark.skipif(have_fsspec is False, reason="needs fsspec")
433+
@pytest.mark.parametrize('zarr_version', _VERSIONS)
434+
@pytest.mark.parametrize('at_root', [False, True])
435+
def test_create_writeable_mode(zarr_version, at_root, tmp_path):
436+
# Regression test for https://github.com/zarr-developers/zarr-python/issues/1306
437+
import fsspec
438+
kwargs = _init_creation_kwargs(zarr_version, at_root)
439+
store = fsspec.get_mapper(str(tmp_path))
440+
z = create(100, store=store, **kwargs)
441+
assert z.store.map == store
442+
443+
432444
@pytest.mark.parametrize('zarr_version', _VERSIONS)
433445
@pytest.mark.parametrize('at_root', [False, True])
434446
def test_empty_like(zarr_version, at_root):

0 commit comments

Comments
 (0)