Skip to content

Using consolidate_metadata with FSStore result in a read-only store #915

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

Closed
jhamman opened this issue Dec 20, 2021 · 0 comments · Fixed by #916
Closed

Using consolidate_metadata with FSStore result in a read-only store #915

jhamman opened this issue Dec 20, 2021 · 0 comments · Fixed by #916
Labels
bug Potential issues with the zarr-python library

Comments

@jhamman
Copy link
Member

jhamman commented Dec 20, 2021

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

import xarray as xr
from zarr.convenience import consolidate_metadata


ds = xr.tutorial.open_dataset('air_temperature')
ds.to_zarr('file://foo.zarr', mode='w', consolidated=False)
consolidate_metadata('file://foo.zarr')

raises:

---------------------------------------------------------------------------
ReadOnlyError                             Traceback (most recent call last)
/tmp/ipykernel_63/1636373769.py in <module>
----> 1 consolidate_metadata('file://foo.zarr')

/srv/conda/envs/notebook/lib/python3.9/site-packages/zarr/convenience.py in consolidate_metadata(store, metadata_key)
   1126         }
   1127     }
-> 1128     store[metadata_key] = json_dumps(out)
   1129     return open_consolidated(store, metadata_key=metadata_key)
   1130 

/srv/conda/envs/notebook/lib/python3.9/site-packages/zarr/storage.py in __setitem__(self, key, value)
   1134     def __setitem__(self, key, value):
   1135         if self.mode == 'r':
-> 1136             raise ReadOnlyError()
   1137         key = self._normalize_key(key)
   1138         path = self.dir_path(key)

ReadOnlyError: object is read-only

Problem description

When using a fsspec compatible string as the store argument, zarr's consolidate_metadata function returns a read-only store, resulting in the error shown above. I believe the expected behavior is to have generate an FSStore object with write privileges (so the consolidated meatadata key can be written).

Version and installation information

Please provide the following:

  • Value of zarr.__version__: 2.10.3
  • Value of numcodecs.__version__: 0.9.1
  • Version of Python interpreter: 3.9
  • Operating system (Linux/Windows/Mac): Linux and OSX
  • How Zarr was installed: conda
@jhamman jhamman added the bug Potential issues with the zarr-python library label Dec 20, 2021
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.

1 participant