From 6087e5e422679f0cd4504309d5d4df952686ba05 Mon Sep 17 00:00:00 2001 From: Tom Augspurger Date: Mon, 30 Sep 2024 11:44:14 -0500 Subject: [PATCH] path / key normalization in set_variables --- xarray/backends/zarr.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/xarray/backends/zarr.py b/xarray/backends/zarr.py index 12b6053fe55..a5c4d7a1604 100644 --- a/xarray/backends/zarr.py +++ b/xarray/backends/zarr.py @@ -892,9 +892,13 @@ def set_variables(self, variables, check_encoding_set, writer, unlimited_dims=No else: kwargs["store"] = self.zarr_group.chunk_store + # TODO: see if zarr should normalize these strings. zarr_array = zarr.open( **kwargs, - path=f"{self.zarr_group.name}/{name}", + # path=f"{self.zarr_group.name}/{name}", + path="/".join([self.zarr_group.name.rstrip("/"), name]).lstrip( + "/" + ), write_empty_chunks=self._write_empty, ) else: