From cba93c333ff3c8965976544d7b6ab9ac41335fca Mon Sep 17 00:00:00 2001 From: Wei Ji Date: Tue, 30 Jun 2020 11:51:20 +1200 Subject: [PATCH] Pop out overwrite_encoded_chunks after shallow copy backend_kwargs dict Don't pop the backend_kwargs dict as per https://github.com/pydata/xarray/pull/4003#discussion_r441979810, make a shallow copy of the backend_kwargs dictionary first. Also removed `overwrite_encoded_chunks` as a top level kwarg of `open_dataset`. Instead, pass it to `backend_kwargs` when using engine="zarr". --- xarray/backends/api.py | 13 ++++++------- 1 file changed, 6 insertions(+), 7 deletions(-) diff --git a/xarray/backends/api.py b/xarray/backends/api.py index 154cfa6acda..610731568df 100644 --- a/xarray/backends/api.py +++ b/xarray/backends/api.py @@ -388,9 +388,6 @@ def open_dataset( {'days', 'hours', 'minutes', 'seconds', 'milliseconds', 'microseconds'} into timedelta objects. If False, leave them encoded as numbers. If None (default), assume the same value of decode_time. - overwrite_encoded_chunks: bool, optional - Whether to drop the zarr chunks encoded for each variable when a - dataset is loaded with specified chunk sizes (default: False) Returns @@ -479,9 +476,10 @@ def maybe_decode_store(store, lock=False): if isinstance(filename_or_obj, MutableMapping) and engine == "zarr": # on ZarrStore, mode='r', synchronizer=None, group=None, # consolidated=False. - overwrite_encoded_chunks = backend_kwargs.pop("overwrite_encoded_chunks", None) + _backend_kwargs = backend_kwargs.copy() + overwrite_encoded_chunks = _backend_kwargs.pop("overwrite_encoded_chunks", None) store = backends.ZarrStore.open_group( - filename_or_obj, group=group, **backend_kwargs + filename_or_obj, group=group, **_backend_kwargs ) elif isinstance(filename_or_obj, str): @@ -514,11 +512,12 @@ def maybe_decode_store(store, lock=False): elif engine == "zarr": # on ZarrStore, mode='r', synchronizer=None, group=None, # consolidated=False. - overwrite_encoded_chunks = backend_kwargs.pop( + _backend_kwargs = backend_kwargs.copy() + overwrite_encoded_chunks = _backend_kwargs.pop( "overwrite_encoded_chunks", None ) store = backends.ZarrStore.open_group( - filename_or_obj, group=group, **backend_kwargs + filename_or_obj, group=group, **_backend_kwargs ) else: if engine not in [None, "scipy", "h5netcdf"]: