10000 Creating an `Zarr.group` using `fsspec.FSMap` fails · Issue #1353 · zarr-developers/zarr-python · GitHub
[go: up one dir, main page]

Skip to content
Creating an Zarr.group using fsspec.FSMap fails #1353
Closed
@Swordcat

Description

@Swordcat

Zarr version

v2.14.1

Numcodecs version

v0.11.0

Python Version

3.11

Operating System

MacOs 13.2.1

Installation

using pip into a virtual environment

Description

creating a group using the Zarr.group convenience function with a fsspec.FSMap store fails as mode='w' is not passed to _normalize_store_arg.

This error stems from a change made in #1304 where a fsspec.FSMap is promoted to a fsspec.FSStore within the zarr.storage._normalize_store_arg_v2 function using the default mode of read only.

A fix for array creation (Zarr.create) due to a similar error was implemented with #1309

I propose introducing a similar change to the Zarr.group function, changing the first line of the function from store = _normalize_store_arg(store, zarr_version=zarr_version) to store = _normalize_store_arg(store, zarr_version=zarr_version, mode='w')

Steps to reproduce

The error can be reproduced with the following code

from fsspec.implementations.memory import MemoryFileSystem

import zarr

mfs = MemoryFileSystem()
fsmap = mfs.get_mapper("memory:/tmp/store")
group = zarr.group(store=fsmap)

Console output

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/Users/brandur/Documents/Repositories/zarr-python-dev/zarr/hierarchy.py", line 1355, in group
    init_group(store, overwrite=overwrite, chunk_store=chunk_store,
  File "/Users/brandur/Documents/Repositories/zarr-python-dev/zarr/storage.py", line 648, in init_group
    _init_group_metadata(store=store, overwrite=overwrite, path=path,
  File "/Users/brandur/Documents/Repositories/zarr-python-dev/zarr/storage.py", line 711, in _init_group_metadata
    store[key] = store._metadata_class.encode_group_metadata(meta)  # type: ignore
    ~~~~~^^^^^
  File "/Users/brandur/Documents/Repositories/zarr-python-dev/zarr/storage.py", line 1410, in __setitem__
    raise ReadOnlyError()
zarr.errors.ReadOnlyError: object is read-only

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

      0