diff --git a/doc/whats-new.rst b/doc/whats-new.rst index 2b3e398634c..7bdcd1c38c6 100644 --- a/doc/whats-new.rst +++ b/doc/whats-new.rst @@ -131,6 +131,11 @@ Deprecations :py:func:`xarray.open_mfdataset` when `combine='by_coords'` is specified. Fixes (:issue:`5230`), via (:pull:`5231`, :pull:`5255`). By `Tom Nicholas `_. +- The `lock` keyword argument to :py:func:`open_dataset` and :py:func:`open_dataarray` is now + a backend specific option. It will give a warning if passed to a backend that doesn't support it + instead of being silently ignored. From the next version it will raise an error. + This is part of the refactor to support external backends (:issue:`5073`). + By `Tom Nicholas `_ and `Alessandro Amici `_. Bug fixes diff --git a/xarray/backends/api.py b/xarray/backends/api.py index 8c60c4030a1..29ce46c8c68 100644 --- a/xarray/backends/api.py +++ b/xarray/backends/api.py @@ -449,7 +449,7 @@ def open_dataset( relevant when using dask or another form of parallelism. By default, appropriate locks are chosen to safely read and write files with the currently active dask scheduler. Supported by "netcdf4", "h5netcdf", - "pynio", "pseudonetcdf", "cfgrib". + "scipy", "pynio", "pseudonetcdf", "cfgrib". See engine open function for kwargs accepted by each specific engine. @@ -633,7 +633,7 @@ def open_dataarray( relevant when using dask or another form of parallelism. By default, appropriate locks are chosen to safely read and write files with the currently active dask scheduler. Supported by "netcdf4", "h5netcdf", - "pynio", "pseudonetcdf", "cfgrib". + "scipy", "pynio", "pseudonetcdf", "cfgrib". See engine open function for kwargs accepted by each specific engine. diff --git a/xarray/backends/pydap_.py b/xarray/backends/pydap_.py index 148f32cf982..2372468d934 100644 --- a/xarray/backends/pydap_.py +++ b/xarray/backends/pydap_.py @@ -1,3 +1,5 @@ +import warnings + import numpy as np from ..core import indexing @@ -122,7 +124,16 @@ def open_dataset( use_cftime=None, decode_timedelta=None, session=None, + lock=None, ): + # TODO remove after v0.19 + if lock is not None: + warnings.warn( + "The kwarg 'lock' has been deprecated for this backend, and is now " + "ignored. In the future passing lock will raise an error.", + DeprecationWarning, + ) + store = PydapDataStore.open( filename_or_obj, session=session, diff --git a/xarray/backends/zarr.py b/xarray/backends/zarr.py index a4086eacece..fef7d739d25 100644 --- a/xarray/backends/zarr.py +++ b/xarray/backends/zarr.py @@ -1,5 +1,6 @@ import os import pathlib +import warnings from distutils.version import LooseVersion import numpy as np @@ -721,7 +722,15 @@ def open_dataset( consolidate_on_close=False, chunk_store=None, storage_options=None, + lock=None, ): + # TODO remove after v0.19 + if lock is not None: + warnings.warn( + "The kwarg 'lock' has been deprecated for this backend, and is now " + "ignored. In the future passing lock will raise an error.", + DeprecationWarning, + ) filename_or_obj = _normalize_path(filename_or_obj) store = ZarrStore.open_group(