Skip to content

Array.read_only incorrect #2949

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
dstansby opened this issue Apr 3, 2025 · 4 comments
Open

Array.read_only incorrect #2949

dstansby opened this issue Apr 3, 2025 · 4 comments

Comments

@dstansby
Copy link
Contributor

dstansby commented Apr 3, 2025

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?

@d-v-b
Copy link
Contributor

d-v-b commented Apr 3, 2025

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.

@dstansby
Copy link
Contributor Author

dstansby commented Apr 3, 2025

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?

@d-v-b
Copy link
Contributor

d-v-b commented Apr 3, 2025

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.

@dstansby
Copy link
Contributor Author

dstansby commented Apr 3, 2025

we should deprecate the mode keyword argument.

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants