Skip to content

Cleanup logic inside open_dataset, mostly extra_kwargs #4462

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Oct 8, 2020
Merged
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
14 changes: 6 additions & 8 deletions xarray/backends/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -457,9 +457,8 @@ def open_dataset(

if backend_kwargs is None:
backend_kwargs = {}
extra_kwargs = {}

def maybe_decode_store(store, chunks, lock=False):
def maybe_decode_store(store, chunks):
ds = conventions.decode_cf(
store,
mask_and_scale=mask_and_scale,
Expand Down Expand Up @@ -543,18 +542,17 @@ def maybe_decode_store(store, chunks, lock=False):
if engine is None:
engine = _autodetect_engine(filename_or_obj)

if engine in ["netcdf4", "h5netcdf"]:
extra_kwargs = {}
if group is not None:
extra_kwargs["group"] = group
if lock is not None:
extra_kwargs["lock"] = lock
elif engine in ["pynio", "pseudonetcdf", "cfgrib"]:
extra_kwargs["lock"] = lock
elif engine == "zarr":

if engine == "zarr":
backend_kwargs = backend_kwargs.copy()
overwrite_encoded_chunks = backend_kwargs.pop(
"overwrite_encoded_chunks", None
)
extra_kwargs["mode"] = "r"
extra_kwargs["group"] = group

opener = _get_backend_cls(engine)
store = opener(filename_or_obj, **extra_kwargs, **backend_kwargs)
Expand Down