Skip to content

Commit

Permalink
Pop out overwrite_encoded_chunks after shallow copy backend_kwargs dict
Browse files Browse the repository at this point in the history
Don't pop the backend_kwargs dict as per pydata#4003 (comment), 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".
  • Loading branch information
weiji14 committed Jun 29, 2020
1 parent afbcf78 commit cba93c3
Showing 1 changed file with 6 additions and 7 deletions.
13 changes: 6 additions & 7 deletions xarray/backends/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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):
Expand Down Expand Up @@ -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"]:
Expand Down

0 comments on commit cba93c3

Please sign in to comment.