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
10 changes: 6 additions & 4 deletions cacholote/extra_encoders.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 1 addition & 1 deletion ci/environment-ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ dependencies:
- sqlalchemy[mypy]
- types-requests
- xarray>=2022.6.0
- zarr<3.0.0
- zarr
- pip:
- pytest-structlog
- types-sqlalchemy-utils
8 changes: 4 additions & 4 deletions tests/test_40_xarray_encoder.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
},
{},
Expand Down Expand Up @@ -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()
Expand Down Expand Up @@ -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",
Expand Down
Loading