Skip to content

Read only array default upon opening #809

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
camFoltz opened this issue Aug 18, 2021 · 5 comments
Open

Read only array default upon opening #809

camFoltz opened this issue Aug 18, 2021 · 5 comments
Labels
enhancement New features or improvements

Comments

@camFoltz
Copy link

camFoltz commented Aug 18, 2021

For bug reports, please follow the template below. For enhancement proposals, feel free
to use whatever template makes sense (major new features should be discussed in the
Zarr specifications repository https://github.com/zarr-developers/zarr-specs).

Minimal, reproducible code sample, a copy-pastable example if possible

src = 'path/to/dir'
z = zarr.open(src)
z.create('array',shape=(1, 1, 1, 1, 2048, 2048),
        chunks=(1, 1, 1, 1, 2048, 2048),
        compressor=Blosc('zstd', clevel=3, shuffle=Blosc.BITSHUFFLE),
        read_only=True)
z['array'][0,4] = 1

## Reload the array after restarting kernel
z_array = zarr.open(src)['array'] ## no longer read_only

Problem description

I am trying to create a zarr store containing an array that is by default read_only. We are moving our raw microscopy data to zarr format and we do not want the user to be able to easily edit the zarr arrays. The default zarr.open(mode='a') overrides any sort of read_only setting put onto the array during creation. This is troublesome because some of our users will not remember to specify mode='r' when browsing the raw data.

Is there a way to have the zarr store/array be read_only by default upon opening?

Version and installation information

Please provide the following:

  • Value of zarr.__version__ = 2.8.3
  • Value of numcodecs.__version__ = 0.7.3
  • python 3.7
  • Mac
  • pip install zarr
@camFoltz camFoltz changed the title Read Only array upon default opening Read only array upon default opening Aug 18, 2021
@camFoltz camFoltz changed the title Read only array upon default opening Read only array default upon opening Aug 18, 2021
@joshmoore
Copy link
Member

Hi @camFoltz. I don't know of a zarr-specific mechanism for recording the read-only setting. As a workaround, have you looked at making it read-only at the underlying storage level?

@camFoltz
Copy link
Author

Hi @joshmoore , thanks for the response. If zarr has no specific mechanism then we will move to dealing with it at the permission level.

@clbarnes
Copy link
Contributor

clbarnes commented Sep 2, 2021

While there isn't (and probably shouldn't be, for simplicity purposes) a mechanism for storing the default access mode on individual containers/ groups/ arrays, would changing the global default mode to "r" be considered in the next major version? h5py did that (somewhat) recently; it would more closely match python's built-in open, and in a post-v3 world where different stores may be readable, writable, and listable, the read-only variant is likely to be the most fundamental and therefore be the simplest assumption to make.

@joshmoore
Copy link
Member

joshmoore commented Sep 2, 2021

@clbarnes : nods and I seem to remember a store (FSStore) recently switching its local default. I'll try to find that commit/PR.

Edit: #546 (comment)

@joshmoore
Copy link
Member

This issue may be fixed by #916

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

No branches or pull requests

4 participants