Unconstrained forwarding of backend keyword arguments
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 4.2k
- Forks
- 1.4k
- Avg merge
- 2d 15h
- Merged PRs (30d)
- 14
Description
Is your feature request related to a problem?
Currently the backend keyword arguments have to be added to the signatures of open_dataset function of the respective BackendEntrypoint and to the open function of the respective Store. Every once in a while when a backend invents a new keyword argument xarray isn't capable to handle this out of the box and errors out.
There are requests/needs to add keyword arguments every once in a while (here only for netcdf4/h5netcdf backends):
- #9282, #10357 and #10372
- #8423, #8360, #9797, #10049
- #7680
- #3753, #8288 and #9509
- #4570 and #4893
There are other attempts to simplify the calling signature for coders:
- #4490
- #6633/#8051
Describe the solution you'd like
Consume all backend related keyword arguments in backend_kwargs. This is already part of the general api open_-functions. Instead of merging backend_kwargs with kwargs there, forward backend_kwargs to the backend and remove the backend related kwargs from the signature of those backend functions.
Instead check backend_kwargs for keywords known to the backend using the open_dataset_parameters class variable of the backend or similar. In case of yet unknown keywords issue a warning that this backend related keyword is currently not defined in the backend and the use is at own risk. Forward backend_kwargs to the respective backend open function.
Describe alternatives you've considered
-
Keep everything as is and deal with it when issues arise.
Works, but has it's downsides. Users are restricted to keyword arguments already available in the calling signature. No straightforward testing, knowledge of backend code needed.
Additional context
Until now there wasn't a problem with having backend keyword arguments mixed with the other keyword arguments. But in #9282/#10357 we get a naming clash which might not easily be resolved. Although this might be a one time solitary case, it introduces trouble.
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start by tracing the open_dataset flow through each backend's BackendEntrypoint.open_dataset and Store.open signatures, then compare it with the existing open_ functions' backend_kwargs handling. Review how open_dataset_parameters is used or could define known keywords. Done means backend_kwargs are forwarded without signature additions, with unknown keywords warning users about the risk.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- python
- Domain
- backend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100