Skip to content

Commit bfa64e1

Browse files
gauchmXarray-Beam authors
authored andcommitted
Fix ChunksToZarr with PathLike store argument.
PiperOrigin-RevId: 819011497
1 parent c6c7335 commit bfa64e1

2 files changed

Lines changed: 6 additions & 2 deletions

File tree

xarray_beam/_src/zarr.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -375,7 +375,7 @@ def _copy_zarr_store_with_fsspec(
375375
) -> None:
376376
"""Copy a Zarr store from one location to another using fsspec."""
377377
source_mapper = fsspec.get_mapper(source_dir)
378-
dest_mapper = fsspec.get_mapper(dest_store)
378+
dest_mapper = fsspec.get_mapper(os.fspath(dest_store))
379379

380380
def copy_item(key):
381381
dest_mapper[key] = source_mapper[key]

xarray_beam/_src/zarr_test.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
1212
# See the License for the specific language governing permissions and
1313
# limitations under the License.
14+
import pathlib
1415
import re
1516

1617
from absl.testing import absltest
@@ -433,16 +434,19 @@ def test_chunks_to_zarr_with_invalid_shards(self):
433434
)
434435

435436
@parameterized.product(
437+
use_pathlike=[True, False],
436438
stage_locally=[True, False, None],
437439
zarr_format=[2, 3, None],
438440
)
439-
def test_setup_zarr(self, stage_locally, zarr_format):
441+
def test_setup_zarr(self, use_pathlike, stage_locally, zarr_format):
440442
dataset = xarray.Dataset(
441443
{'foo': ('x', np.arange(0, 60, 10))},
442444
coords={'x': np.arange(6)},
443445
)
444446
template = xbeam.make_template(dataset)
445447
temp_dir = self.create_tempdir().full_path
448+
if use_pathlike:
449+
temp_dir = pathlib.Path(temp_dir)
446450
xbeam.setup_zarr(
447451
template,
448452
temp_dir,

0 commit comments

Comments
 (0)