diff --git a/cacholote/extra_encoders.py b/cacholote/extra_encoders.py index 76e9086..4717787 100644 --- a/cacholote/extra_encoders.py +++ b/cacholote/extra_encoders.py @@ -282,10 +282,12 @@ def _store_xr_object( filetype: str, ) -> None: if filetype == "application/vnd+zarr": - # Write directly on any filesystem - mapper = fs.get_mapper(urlpath) - with _logging_timer("upload", urlpath=fs.unstrip_protocol(urlpath)): - obj.to_zarr(mapper, consolidated=True) + urlpath = fs.unstrip_protocol(urlpath) + storage_options = fs.storage_options + if isinstance(fs, fsspec.implementations.local.LocalFileSystem): + storage_options = storage_options | {"auto_mkdir": True} + with _logging_timer("upload", urlpath=urlpath): + obj.to_zarr(urlpath, storage_options=storage_options) return # Need a tmp local copy to write on a different filesystem diff --git a/ci/environment-ci.yml b/ci/environment-ci.yml index ed8c6d3..af0de7e 100644 --- a/ci/environment-ci.yml +++ b/ci/environment-ci.yml @@ -30,7 +30,7 @@ dependencies: - sqlalchemy[mypy] - types-requests - xarray>=2022.6.0 -- zarr<3.0.0 +- zarr - pip: - pytest-structlog - types-sqlalchemy-utils diff --git a/tests/test_40_xarray_encoder.py b/tests/test_40_xarray_encoder.py index ecdbd22..1e394ca 100644 --- a/tests/test_40_xarray_encoder.py +++ b/tests/test_40_xarray_encoder.py @@ -55,7 +55,7 @@ def test_dictify_xr_dataset(tmp_path: pathlib.Path) -> None: "type": "application/netcdf", "href": href, "file:checksum": f"{fsspec.filesystem('file').checksum(local_path):x}", - "file:size": 669, + "file:size": 670, "file:local_path": local_path, }, {}, @@ -93,7 +93,7 @@ def test_xr_cacheable( ) -> None: pytest.importorskip(importorskip) - config.set(xarray_cache_type=xarray_cache_type) + config.set(xarray_cache_type=xarray_cache_type, raise_all_encoding_errors=True) # cache-db to check con = config.get().engine.raw_connection() @@ -188,13 +188,13 @@ def test_xr_logging(log: pytest_structlog.StructuredLogCapture) -> None: }, { "urlpath": urlpath, - "size": 22645, + "size": 22646, "event": "start upload", "level": "info", }, { "urlpath": urlpath, - "size": 22645, + "size": 22646, "upload_time": log.events[3]["upload_time"], "event": "end upload", "level": "info",