Skip to content

Array.read_only incorrect #2949

Closed
Closed

Description

@dstansby
import zarr
import zarr.storage

store = zarr.storage.MemoryStore()
zarr.create((100,), store=store, zarr_format=2, path="a")


arr = zarr.open_array(store=store, path="a", zarr_format=2, mode="r")
print(arr.read_only)
# False

Given the mode is "r", I think .read_only should return True?

Activity

  1. d-v-b commented on Apr 3, 2025

    @d-v-b
    Contributor

    In zarr-python 3, arrays and groups don't have their own read / write permission model, instead all of that is handled by the storage layer.

    Thus the read_only property was added for backwards compatibility with v2, and it doesn't do what you would expect -- it reports whether the array is backed by a read-only store.. So in your example, because you are re-using a store instance, it keeps its original mode (which is probably a). I agree that this is confusing.

  2. dstansby commented on Apr 3, 2025

    @dstansby
    ContributorAuthor

    Hmm, in that case should passing a mode to open_array raise an exception, when the passed mode is different to the mode the store is open with?

  3. d-v-b commented on Apr 3, 2025

    @d-v-b
    Contributor

    i believe open_array has a mode parameter for backwards compatibility reasons. Since we are controlling access modes with the storage layer, IMO it doesn't make sense to pretend that it's also controlled by the array / group layer, and we should deprecate the mode keyword argument.

  4. dstansby commented on Apr 3, 2025

    @dstansby
    ContributorAuthor

    we should deprecate the mode keyword argument.

    👍 - I think it's pretty bad that it silently does nothing at the moment!

  5. added
    bugPotential issues with the zarr-python library
    on May 18, 2025
  6. modified the milestone: 3.0.8 on May 18, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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