Skip to content
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

[v3] Open a zarr v2 group without specifying zarr_version fails with zarr v3 #1958

Open
will-moore opened this issue Jun 11, 2024 · 1 comment
Labels
bug Potential issues with the zarr-python library V3 Affects the v3 branch
Milestone

Comments

@will-moore
Copy link

Zarr version

2.16.2.dev137+gcf37b134

Numcodecs version

0.12.1

Python Version

3.10.14

Operating System

Mac

Installation

pip install . (from origin/v3 branch at * ee30347 (HEAD, origin/v3, origin/HEAD) Feature: Top level V3 API (#1884)

Description

I'd like to be able to open a zarr group without having to know specify that it's zarr_version. E.g. 2 or 3.

See code below to reproduce

Steps to reproduce

test_read_v2.py

import zarr
import os
from zarr.v2 import open_group

path = "test.zarr"
if os.path.exists(path):
    import shutil
    shutil.rmtree(path)

# create v2 group
root = open_group(path, mode='w')
root.attrs["test"] = "v2"
foo = root.create_group('foo')
root2 = open_group(path, mode='a')
print('root2', root2)

# specify zarr_format - works
root = zarr.open(store=path, zarr_format=2)
print("root", root)

# try to guess zarr_format - fails
root = zarr.open(store=path)
print("root", root)

Additional output

$ python test_read_v2.py 
root2 <zarr.v2.hierarchy.Group '/'>
root Group(_async_group=<AsyncGroup file://test.zarr>)
Traceback (most recent call last):
  File "/Users/wmoore/opt/anaconda3/envs/zarr_v3/lib/python3.10/site-packages/zarr/api/asynchronous.py", line 198, in open
    return await open_array(store=store_path, zarr_format=zarr_format, **kwargs)
  File "/Users/wmoore/opt/anaconda3/envs/zarr_v3/lib/python3.10/site-packages/zarr/api/asynchronous.py", line 865, in open_array
    raise e
  File "/Users/wmoore/opt/anaconda3/envs/zarr_v3/lib/python3.10/site-packages/zarr/api/asynchronous.py", line 860, in open_array
    return await AsyncArray.open(store_path, zarr_format=zarr_format)
  File "/Users/wmoore/opt/anaconda3/envs/zarr_v3/lib/python3.10/site-packages/zarr/array.py", line 337, in open
    raise KeyError(store_path)  # filenotfounderror?
KeyError: StorePath(LocalStore, 'file://test.zarr')

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "/Users/wmoore/Desktop/ZARR/scripts/test_read_v2.py", line 23, in <module>
    root = zarr.open(store=path)
  File "/Users/wmoore/opt/anaconda3/envs/zarr_v3/lib/python3.10/site-packages/zarr/api/synchronous.py", line 45, in open
    obj = sync(
  File "/Users/wmoore/opt/anaconda3/envs/zarr_v3/lib/python3.10/site-packages/zarr/sync.py", line 92, in sync
    raise return_result
  File "/Users/wmoore/opt/anaconda3/envs/zarr_v3/lib/python3.10/site-packages/zarr/sync.py", line 51, in _runner
    return await coro
  File "/Users/wmoore/opt/anaconda3/envs/zarr_v3/lib/python3.10/site-packages/zarr/api/asynchronous.py", line 200, in open
    return await open_group(store=store_path, zarr_format=zarr_format, **kwargs)
  File "/Users/wmoore/opt/anaconda3/envs/zarr_v3/lib/python3.10/site-packages/zarr/abc/store.py", line 203, in set_or_delete
    await byte_setter.set(value)
  File "/Users/wmoore/opt/anaconda3/envs/zarr_v3/lib/python3.10/site-packages/zarr/store/core.py", line 40, in set
    await self.store.set(self.path, value)
  File "/Users/wmoore/opt/anaconda3/envs/zarr_v3/lib/python3.10/site-packages/zarr/store/local.py", line 128, in set
    self._check_writable()
  File "/Users/wmoore/opt/anaconda3/envs/zarr_v3/lib/python3.10/site-packages/zarr/abc/store.py", line 29, in _check_writable
    raise ValueError("store mode does not support writing")
ValueError: store mode does not support writing
@will-moore will-moore added the bug Potential issues with the zarr-python library label Jun 11, 2024
@jhamman
Copy link
Member

jhamman commented Jun 11, 2024

Thanks for the report here @will-moore. I can look into this.

@jhamman jhamman added this to the 3.0.0 milestone Jun 12, 2024
@jhamman jhamman added the V3 Affects the v3 branch label Oct 18, 2024
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 V3 Affects the v3 branch
Projects
None yet
Development

No branches or pull requests

2 participants