Skip to content

Commit

Permalink
Fix: save an empty Zarr even when open_dataset return a full dataset
Browse files Browse the repository at this point in the history
  • Loading branch information
alexamici committed Nov 9, 2024
1 parent 5f692ed commit 6230609
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions xarray_ecmwf/engine_ecmwf.py
Original file line number Diff line number Diff line change
Expand Up @@ -141,6 +141,9 @@ def cached_empty_dataset(self, request: dict[str, Any]) -> Iterator[xr.Dataset]:
# check again as the retrieve may be long
with xr.backends.locks.get_write_lock(f"{HOSTNAME}-zarr"): # type: ignore
if not os.path.exists(path):
# NOTE: be sure that read_ds is chunked so compute=False only
# writes the metadata. Some open_dataset
read_ds = read_ds.chunk()
read_ds.to_zarr(path, compute=False)
yield xr.open_dataset(path, engine="zarr")

Expand Down

0 comments on commit 6230609

Please sign in to comment.