From 6ba41de5cf4da93befd1b51a91deb7023c65d4b7 Mon Sep 17 00:00:00 2001 From: TomNicholas Date: Tue, 9 Apr 2024 18:50:08 -0400 Subject: [PATCH] try explicitly separating files from directories --- virtualizarr/tests/test_zarr.py | 2 -- virtualizarr/xarray.py | 9 ++++++--- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/virtualizarr/tests/test_zarr.py b/virtualizarr/tests/test_zarr.py index b8e37049..2faf43c7 100644 --- a/virtualizarr/tests/test_zarr.py +++ b/virtualizarr/tests/test_zarr.py @@ -25,5 +25,3 @@ def test_zarr_v3_roundtrip(tmpdir): roundtrip = open_virtual_dataset(tmpdir / "store.zarr", filetype="zarr_v3", indexes={}) xrt.assert_identical(roundtrip, original) - - assert False diff --git a/virtualizarr/xarray.py b/virtualizarr/xarray.py index b3c26cb1..1fa83577 100644 --- a/virtualizarr/xarray.py +++ b/virtualizarr/xarray.py @@ -152,14 +152,17 @@ def open_virtual_dataset_from_v3_store( ds_attrs = attrs_from_zarr_group_json(_storepath / "zarr.json") # TODO recursive glob to create a datatree + # Note: this .is_file() check should not be necessary according to the pathlib docs, but tests fail on github CI without it + # see https://github.com/TomNicholas/VirtualiZarr/pull/45#discussion_r1547833166 + all_paths = _storepath.glob("*/") + directory_paths = [p for p in all_paths if not p.is_file()] + vars = {} - for array_dir in _storepath.glob("*/"): + for array_dir in directory_paths: var_name = array_dir.name if var_name in drop_variables: break - print(array_dir) - zarray, dim_names, attrs = metadata_from_zarr_json(array_dir / "zarr.json") manifest = ChunkManifest.from_zarr_json(str(array_dir / "manifest.json"))