Skip to content

Commit 017713b

Browse files
authored
Merge branch 'main' into fix-netcdf4-remote-zarr-detection
2 parents c07e7ea + badb6f1 commit 017713b

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

xarray/backends/zarr.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1620,6 +1620,7 @@ class ZarrBackendEntrypoint(BackendEntrypoint):
16201620

16211621
description = "Open zarr files (.zarr) using zarr in Xarray"
16221622
url = "https://docs.xarray.dev/en/stable/generated/xarray.backends.ZarrBackendEntrypoint.html"
1623+
supports_groups = True
16231624

16241625
def guess_can_open(self, filename_or_obj: T_PathFileOrDataStore) -> bool:
16251626
if isinstance(filename_or_obj, str | os.PathLike):

xarray/tests/test_backends_datatree.py

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1089,3 +1089,27 @@ def test_write_inherited_coords_true(self, tmpdir, zarr_format) -> None:
10891089
expected_child.name = None
10901090
with open_datatree(filepath, group="child", engine="zarr") as roundtrip_child:
10911091
assert_identical(expected_child, roundtrip_child)
1092+
1093+
@pytest.mark.xfail(
1094+
ON_WINDOWS,
1095+
reason="Permission errors from Zarr: https://github.com/pydata/xarray/pull/10793",
1096+
)
1097+
@pytest.mark.filterwarnings(
1098+
"ignore:Failed to open Zarr store with consolidated metadata:RuntimeWarning"
1099+
)
1100+
def test_zarr_engine_recognised(self, tmpdir, zarr_format) -> None:
1101+
"""Test that xarray can guess the zarr backend when the engine is not specified"""
1102+
original_dt = DataTree.from_dict(
1103+
{
1104+
"/": xr.Dataset(coords={"x": [1, 2, 3]}),
1105+
"/child": xr.Dataset({"foo": ("x", [4, 5, 6])}),
1106+
}
1107+
)
1108+
1109+
filepath = str(tmpdir / "test.zarr")
1110+
original_dt.to_zarr(
1111+
filepath, write_inherited_coords=True, zarr_format=zarr_format
1112+
)
1113+
1114+
with open_datatree(filepath) as roundtrip_dt:
1115+
assert_identical(original_dt, roundtrip_dt)

0 commit comments

Comments
 (0)