Closed Metamess closed 1 year ago
I have created a PR (#349 ) that intends to fix this issue. Please let me know if any changes are required!
On a sidenote, I think the pinned versions in requirements-tests.txt
could really use a bump. Many major packages (numpy, pandas, xarray, even pytest) have had a lot of development happen since March 2020, and the current pinned versions are not operable with python 3.10.
For what it's worth, I did a pip install -r ci/requirements-tests.txt
after removing all version pinning, and all the tests pass with pytest -v
, while pytest -v --flakes
merely complains about some unused imports. So for as far as that is any indication, there seem to be no breaking changes with newer versions of the required packages.
What happened?
The
open_datasets()
function can be supplied with abackend_kwargs
dict, with one of the potentially interesting keys being"grib_errors"
. This keyword argument is used byopen_variable_datasets()
to set theerrors
parameter ofFileStream.__init__()
. (This has the value "warn" by default, but can be set to "raise" to cause an Error to be raised if there is an issue with opening the GRIB file). Thedataset.py::open_file()
function also expects this argument asgrib_errors
.However, the
CfGribBackend.open_dataset()
function expects this argument to be callederrors
, as doesFileStream.__init__()
and several other functions throughout the codebase.Due to this inconsistent naming, and the fact that the key
"grib_errors"
gets propagated unchanged, actually supplying the key"grib_errors"
as part ofbackend_kwargs
toopen_datasets()
will cause a TypeError when the call reachedCfGribBackend.open_dataset()
, which does not allows **kwargs and which calls this parametererrors
and notgrib_errors
Unless there is a specific reason to keep
grib_errors
as backend_kwargs separated fromerrors
, I believe the easiest fix would be to rename the few occurrences ofgrib_errors
toerrors
.What are the steps to reproduce the bug?
Call
open_datasets(filename, backend_kwargs={"grib_errors": "raise"})
wherefilename
is a str pointing to a valid GRIB fileVersion
0.9.10.4
Platform (OS and architecture)
WSL2 Ubuntu 22.04.2 LTS
Relevant log output
Accompanying data
No response
Organisation
No response