Skip to content

Wrapper stores don't support with_read_only #3699

@BorisTheBrave

Description

@BorisTheBrave

Zarr version

v3.1.3

Numcodecs version

N/A

Python Version

3.11.11

Operating System

Linux

Installation

uv

Description

LoggingStore, LatencyStore and CacheStore all don't support with_read_only.

This is a pain to work with. Particularly with xarray, which defaults to needing a readonly store.

Steps to reproduce

# /// script
# requires-python = ">=3.11"
# dependencies = [
#   "zarr@git+https://github.com/zarr-developers/zarr-python.git@main",
#    "xarray",
# ]
# ///
#

from zarr.storage import LocalStore, LoggingStore
import xarray as xr

store = LocalStore(root="tmp", read_only=False)
store = LoggingStore(store)
dataset = xr.open_dataset(store, engine="zarr", mode="w") # Works
dataset = xr.open_dataset(store, engine="zarr") # Fails

Fails with

ValueError: Store is not read-only but mode is 'r'. Unable to create a read-only copy of the store. Please use a read-only store or a storage class that implements .with_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