-
-
Notifications
You must be signed in to change notification settings - Fork 1.1k
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
split out CFDatetimeCoder, deprecate use_cftime as kwarg #9901
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like this but since this is adding public API, can you open an issue and see if everyone is on board please
Co-authored-by: Deepak Cherian <dcherian@users.noreply.github.com>
for more information, see https://pre-commit.ci
Can you explicitely write how to change this in the deprecation warning? As is I don't find it obvious what users have to do. ('Use I am also a bit surprised that the CFDateTimeCoder does not imply Is the use of (Removing an arg is always nice but I use this a lot and its much more verbose...) |
@mathause Thanks for sharing your concerns and suggestions.
Yes, this is a bit sparse, how is it with: import xarray as xr
time_coder = xr.coders.CFDatetimeCoder(use_cftime=True)
ds = xr.open_dataset(decode_times=time_coder)
So the current state of affairs is: The default state of
As the current behaviour is preserved, we might skip the DeprecationWarning for now until all I'll rework the DeprecationWarning to more explicit in what to do, but we should decide whether we want to warn from now or postpone this until we have a clear way of how to do things. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think is much easier to adapt to the deprecation with the suggested message.
Does that make sense?
Yes, that makes sense - thanks!
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @kmuehlbauer—I'm also on board with this update. Just a few docstring suggestions, but otherwise this looks good to me.
I assume we'll add something similar for decode_timedelta
and CFTimedeltaCoder
when the time_unit
option is added in #9618?
Co-authored-by: Spencer Clark <spencerkclark@gmail.com>
Co-authored-by: Spencer Clark <spencerkclark@gmail.com>
Yes, that would be a follow-up PR. |
@spencerkclark Thanks for taking the time to review. I've added your suggestions. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This looks great to me! Thanks @kmuehlbauer
Great! If there is anything to be added to this, please open a new issue. I'll continue with #9618 after merging. |
Hi, Please reconsider this. Cheers. |
@st-bender I'm not sure I understand. This will not break code, it just issues a deprecation warning (advertising the new invocation) if used like before, only if the new invocation is used this and All keyword arguments which are related to CF decoding will eventually be deprecated from the function signature along this issue #4490. Could you please a bit more specific what exactly should be reconsidered? |
Hi,
It will break when the deprecation cycle has ended and the keyword version has been finally removed.
I am not particularly a fan of deprecations in general, and of ones that break backwards compatibility in particular. Even less so when keeping compatibility is easy.
I was referring to the deprecation of keyword arguments and their subsequent removal. I, as a user, have developed quite some code that uses xarray extensively. And I am really grateful for all the work you put into it. However, I fear that in the future all that work was for nothing and the code will not run anymore, and that I'd have to spend a considerable time and efforts to keep these programs running with future versions of xarray. Sure, I could pin the version, but that would also mean missing future improvements wrt speed and resource use. Cheers. |
Thanks @st-bender for the details. I agree that downstream code has to actively be adapted to the new usage and that this might also be quite tedious sometimes. In this particular case the deprecation isn't done for nothing but to make xarray capable of using different coders (non CF). Just to show what #4490 has in mind: ds = xr.open_dataset(
fname,
mask_and_scale=True,
decode_times=True,
decode_timedelta=False,
use_cftime=True,
concat_characters=True,
decode_coords='coordinates'
) might be rewritten as dt_coder = xr.coders.CFDatetimeCoder(use_cftime=True)
coder = xr.coders.CFCoders(
mask_and_scale=True,
decode_times=dt_coder,
decode_timedelta=False,
concat_characters=True,
decode_coords='coordinates'
ds = xr.open_dataset(fname, coder=coder) And at the same time it would be possible to use totally different So the deprecation of |
I wish developers would consider the amount of work for downstream developers a bit more.
Why not keep both?
One does not exclude the other, that's basically my point. Cheers. |
Because these keyword arguments are solely for CF Conventions (and might not apply for all backends). To allow for other Conventions to be decoded likewise these keyword arguments have to be removed from the function signature and be combined in dedicated coder classes (or the like). This will also make implementation of new backends easier. You are encouraged to contribute to the discussion in #4490 how these things should be handled. There is not much more to add from my side. Good chance that other @pydata/xarray devs can enhance here. |
whats-new.rst
api.rst
This makes something like this possible: