Skip to content

Add store.with_read_only() copy method #3105

Open
@maxrjones

Description

@maxrjones

Thank you for the efforts that have gone into hardening Zarr-Python's approach to read/write modes!

Now that it's no longer possible to open an array in read mode with a store with read_only=False, I'm wondering if it would be possible/advisable to add a public setter method to modify a store's mode? This is the code that I had been working with. It'd be convenient to open a read only array without needing to create a new store instance:

def array_roundtrip(store):
    """
    Round trip an array using a Zarr store

    Args:
        store: Store-Like object
    """
    data = np.ones((3,3))
    arr = zarr.create_array(store=store, overwrite=True, data=data)
    assert isinstance(arr, Array)
    # Read set values
    arr2 = zarr.open_array(store=store, mode="r")
    assert isinstance(arr2, Array)
    np.testing.assert_array_equal(arr[:], data)

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew features or improvements

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions