diff --git a/docs/release.rst b/docs/release.rst index 7ffd751696..d6692a01d9 100644 --- a/docs/release.rst +++ b/docs/release.rst @@ -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 ` :issue:`1309`. + 2.13.4 ------ diff --git a/zarr/creation.py b/zarr/creation.py index 00d2c40030..cc191e3734 100644 --- a/zarr/creation.py +++ b/zarr/creation.py @@ -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 diff --git a/zarr/tests/test_creation.py b/zarr/tests/test_creation.py index 0f12fc5613..4c9c292734 100644 --- a/zarr/tests/test_creation.py +++ b/zarr/tests/test_creation.py @@ -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, )) @@ -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") +@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):