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 · May be fixed by #3068
Open

Array.read_only incorrect #2949

dstansby opened this issue Apr 3, 2025 · 4 comments · May be fixed by #3068
Labels
bug Potential issues with the zarr-python library

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!

@dstansby dstansby added the bug Potential issues with the zarr-python library label May 18, 2025
@dstansby dstansby added this to the 3.0.8 milestone May 18, 2025
@dstansby dstansby linked a pull request May 18, 2025 that will close this issue
@dstansby dstansby removed this from the 3.0.8 milestone May 19, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Potential issues with the zarr-python library
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants