diff --git a/src/zarr/api/asynchronous.py b/src/zarr/api/asynchronous.py index 94ecfee4d6..965efbbc76 100644 --- a/src/zarr/api/asynchronous.py +++ b/src/zarr/api/asynchronous.py @@ -317,10 +317,11 @@ async def open( try: return await open_array(store=store_path, zarr_format=zarr_format, mode=mode, **kwargs) - except (KeyError, NodeTypeValidationError): + except (KeyError, NodeTypeValidationError, FileNotFoundError): # KeyError for a missing key # NodeTypeValidationError for failing to parse node metadata as an array when it's # actually a group + # FileNotFoundError for v2 when opening a group return await open_group(store=store_path, zarr_format=zarr_format, mode=mode, **kwargs) diff --git a/tests/test_v2.py b/tests/test_v2.py index 94aa513ce8..8d036829ef 100644 --- a/tests/test_v2.py +++ b/tests/test_v2.py @@ -11,7 +11,7 @@ import zarr import zarr.storage from zarr import Array -from zarr.storage import MemoryStore, StorePath +from zarr.storage import LocalStore, MemoryStore, StorePath @pytest.fixture @@ -35,6 +35,13 @@ def test_simple(store: StorePath) -> None: assert np.array_equal(data, a[:, :]) +def test_simple_group(tmp_path) -> None: + store = LocalStore(tmp_path, mode="w") + zarr.group(store=store, zarr_format=2) + root_group = zarr.open(tmp_path, zarr_format=2) + assert root_group is not None + + @pytest.mark.parametrize( ("dtype", "fill_value"), [