diff --git a/xarray_ecmwf/engine_ecmwf.py b/xarray_ecmwf/engine_ecmwf.py index c495f02..ad55cec 100644 --- a/xarray_ecmwf/engine_ecmwf.py +++ b/xarray_ecmwf/engine_ecmwf.py @@ -122,7 +122,9 @@ def cached_empty_dataset(self, request: dict[str, Any]) -> Iterator[xr.Dataset]: if not os.path.exists(path): with self.retrieve(request, override_cache_file=True) as read_ds: - read_ds.to_zarr(path, compute=False) + # check again as the retrieve may be long + if not os.path.exists(path): + read_ds.to_zarr(path, compute=False) yield xr.open_dataset(path, engine="zarr")