Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions xarray/backends/zarr.py
Original file line number Diff line number Diff line change
Expand Up @@ -1620,6 +1620,7 @@ class ZarrBackendEntrypoint(BackendEntrypoint):

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

def guess_can_open(self, filename_or_obj: T_PathFileOrDataStore) -> bool:
if isinstance(filename_or_obj, str | os.PathLike):
Expand Down
24 changes: 24 additions & 0 deletions xarray/tests/test_backends_datatree.py
Original file line number Diff line number Diff line change
Expand Up @@ -1089,3 +1089,27 @@ def test_write_inherited_coords_true(self, tmpdir, zarr_format) -> None:
expected_child.name = None
with open_datatree(filepath, group="child", engine="zarr") as roundtrip_child:
assert_identical(expected_child, roundtrip_child)

@pytest.mark.xfail(
ON_WINDOWS,
reason="Permission errors from Zarr: https://github.com/pydata/xarray/pull/10793",
)
@pytest.mark.filterwarnings(
"ignore:Failed to open Zarr store with consolidated metadata:RuntimeWarning"
)
def test_zarr_engine_recognised(self, tmpdir, zarr_format) -> None:
"""Test that xarray can guess the zarr backend when the engine is not specified"""
original_dt = DataTree.from_dict(
{
"/": xr.Dataset(coords={"x": [1, 2, 3]}),
"/child": xr.Dataset({"foo": ("x", [4, 5, 6])}),
}
)

filepath = str(tmpdir / "test.zarr")
original_dt.to_zarr(
filepath, write_inherited_coords=True, zarr_format=zarr_format
)

with open_datatree(filepath) as roundtrip_dt:
assert_identical(original_dt, roundtrip_dt)
Loading