Skip to content
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

Deprecators #4464

Closed
wants to merge 9 commits into from
Closed

Deprecators #4464

wants to merge 9 commits into from

Conversation

hmaarrfk
Copy link
Member

Description

@jni, @alexdesiqueira this is the demo that I was talking about regarding how the decorator can be used to basically make the change "once".

In version 1.0, you are left with "zombie" decorators that would basically do nothing.

https://github.com/hmaarrfk/wabisabi/blob/master/wabisabi/kwonly_change.py#L89
I forced push to my old PR, now i can't reopen it.
#3346

Checklist

For reviewers

  • Check that the PR title is short, concise, and will make sense 1 year
    later.
  • Check that new functions are imported in corresponding __init__.py.
  • Check that new features, API changes, and deprecations are mentioned in
    doc/release/release_dev.rst.
  • Consider backporting the PR with @meeseeksdev backport to v0.14.x

@pep8speaks
Copy link

pep8speaks commented Feb 18, 2020

Hello @hmaarrfk! Thanks for updating this PR. We checked the lines you've touched for PEP 8 issues, and found:

Line 9:1: E302 expected 2 blank lines, found 1
Line 118:80: E501 line too long (80 > 79 characters)
Line 230:80: E501 line too long (81 > 79 characters)

Line 381:80: E501 line too long (84 > 79 characters)

Line 319:11: E114 indentation is not a multiple of four (comment)
Line 319:11: E116 unexpected indentation (comment)

Comment last updated at 2020-03-02 00:33:34 UTC

@soupault
Copy link
Member

This is a pretty cool thing for long-term maintenance 👍.

@rfezzani
Copy link
Member

Very cool stuff. What about #4158 then? Close, postpone....

@alexdesiqueira
Copy link
Member

alexdesiqueira commented Feb 26, 2020

A small complaining on the tests, @hmaarrfk:

/home/travis/venv/lib/python3.7/site-packages/skimage/transform/radon_transform.py:docstring of skimage.transform.iradon:57:Inline literal start-string without end-string.

Could you check it, please? :)

@hmaarrfk
Copy link
Member Author

hmaarrfk commented Mar 2, 2020

So if people are in favor of this, I suggest we either:

A. Version wabisabi (well what we need from it)
B. Depend on it

and start doing this kind of deprecation 1 file at a time, taking care of internal warnings at every step of the way.

This is a "one time necessary change" with the change acting as a no-op if the version specified has passed.

@alexdesiqueira
Copy link
Member

I'm +1 here, but I have two questions to help others decide @hmaarrfk:

A. Version wabisabi (well what we need from it)

How difficult (and heavy) would that be?

B. Depend on it

How heavy would that be?

@hmaarrfk
Copy link
Member Author

hmaarrfk commented Mar 2, 2020

The only dependency is numpydoc for documentation mangling.

That said, it is optional, and for many people it will be installed automatically when they install Spyder.

Versioning it would require copying in 3 files or so, maybe more for tests, but the license is already included in the files, and I can give my blessing to provide full copyright to scikit image if it helps.

@rfezzani
Copy link
Member

rfezzani commented Mar 2, 2020

This is a "one time necessary change" with the change acting as a no-op if the version specified has passed.

Even if the decorators acts punctually, I don't think that it is a good idea to keep ghost/useless lines in the code base... Even if it doesn't hurt to keep these lines, it would be a good idea to plan some cleanings at release time...

@hmaarrfk
Copy link
Member Author

hmaarrfk commented Mar 2, 2020

Yes of course, but I don't think it can be considered "technical Dept" just an annoyance in the codebase that would require minimal review to be pushed through

@@ -0,0 +1,2 @@
# Avoid circular imports
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😢 We really need to dive in skimage import strategy to fix it...

Copy link
Member

@rfezzani rfezzani left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you @hmaarrfk really cool ;-)

Edit

What if we move deprecate_kwarg from skimage._shared.utils to wabisabi?
What if we replace skimage._shared.utils.deprecate_kwarg by wabisabi.kwarg_name_change? 😄

@rfezzani rfezzani added ⚖️ Needs decision 🔧 type: Maintenance Refactoring and maintenance of internals labels Mar 5, 2020
Copy link
Member

@jni jni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@hmaarrfk I've suggested a very small change. What's the status with wabisabi? Are you ok making breaking changes there? Overall, I absolutely love the functionality and am now convinced to depend on it.

Having said this, this could not be used nicely for e.g. changes in rescale behaviour. (As far as I can see?) ie you'd need to introduce preserve_ranges everywhere and then remove them eventually, which is double the pain of just changing it at 1.0...

But, in general, I really like this functionality and can see myself using it both in 0.x and in the 1.0->2.0 transition.



def hough_line_peaks(hspace, angles, dists, min_distance=9, min_angle=10,
@kwonly_change('1.0')
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ironically, I think this should be a keyword-only argument. 😂

Suggested change
@kwonly_change('1.0')
@kwonly_change(until_version='1.0')

def iradon(radon_image, theta=None, output_size=None,
@kwonly_change('1.0', previous_arg_order=['radon_image', 'theta',
'output_size', 'filter_name',
'interpolation', 'circle'])
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Whoa. This is a super-cool feature.

@hmaarrfk
Copy link
Member Author

Rescale behavior is a little tougher. We can try to write a spec for itto see how the input output response would look like.

I would rather not make breaking changes there, but I don't think I use the kwonly deprecator in my production code so maybe it is ok to break?

You can suggest a PR there if you like

@jni
Copy link
Member

jni commented Mar 16, 2020

I would rather not make breaking changes there

Aw. But it would be so delightfully meta to use wabisabi on wabisabi itself! 😂 Anyway, I'll have a look. My main proposals right now are:

  • kwonly_change -> update_keyword_only[_args]
  • version -> *, until_version

The function definition itself can be simplified by using toolz.curry and having func be the only positional argument.

@hmaarrfk
Copy link
Member Author

do you really want to depend on toolz?

until_version makes sense

do you want all the functions to start with update_??

@jni
Copy link
Member

jni commented Mar 17, 2020

do you really want to depend on toolz?

Yep, pretty lightweight, pure python, and extremely stable. Dask depends on it so it's not even like it's unmaintained.

do you want all the functions to start with update_??

Maybe? I like my code to read as close to English as possible. And it's equivalent to having them all end with _change. ;)

@grlee77
Copy link
Contributor

grlee77 commented Apr 5, 2021

A deprecate_kwarg utility was merged in #4158 and that same file also has decorators for remove_arg and change_default_value .

Is there additional functionality here that we still want to consider or can this PR be closed?

@grlee77 grlee77 added the 🤖 type: Infrastructure CI, packaging, tools and automation label Apr 5, 2021
@hmaarrfk
Copy link
Member Author

hmaarrfk commented Apr 5, 2021

No. I don't think so. I was following your progress and it seems you added the important features.

@hmaarrfk hmaarrfk closed this Apr 5, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
⚖️ Needs decision 🤖 type: Infrastructure CI, packaging, tools and automation 🔧 type: Maintenance Refactoring and maintenance of internals
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

7 participants