Remove several functions and objects from PyMC root namespace#6973
Remove several functions and objects from PyMC root namespace#6973ricardoV94 wants to merge 32 commits intopymc-devs:v6from
Conversation
9fd14d6 to
ce10976
Compare
|
Depending on how semver-y people feel, this might be best targeted for PyMC v6. |
ce10976 to
e7e8a54
Compare
I think that will be a strong argument not to go on with these changes |
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## v6 #6973 +/- ##
=====================================
Coverage ? 91.89%
=====================================
Files ? 125
Lines ? 20258
Branches ? 0
=====================================
Hits ? 18616
Misses ? 1642
Partials ? 0
🚀 New features to boost your workflow:
|
|
I'll put in a vote against this -- there are enough pymc scripts and libraries out there that don't follow library updates very closely, but would like to continue to benefit from better sampling routines by having liberal version specifications. Probably the right way would be to use some deprecations library that issued a warning for ~a year, and provided a copy/paste upgrade path. I'm not sure the benefits (tidier namespace? are there others?) outweigh the work and downsides. |
| def alias_deprecation(func, alias: str): | ||
| original = func.__name__ | ||
|
|
||
| @functools.wraps(func) | ||
| def wrapped(*args, **kwargs): | ||
| raise FutureWarning( | ||
| f"The function `{alias}` from PyMC was an alias for `{original}` from ArviZ. " | ||
| "It was removed in PyMC 4.0. " | ||
| f"Switch to `pymc.{original}` or `arviz.{original}`." | ||
| ) | ||
|
|
||
| return wrapped | ||
|
|
||
|
|
||
| # Aliases of ArviZ functions | ||
| autocorrplot = alias_deprecation(az.plot_autocorr, alias="autocorrplot") | ||
| forestplot = alias_deprecation(az.plot_forest, alias="forestplot") | ||
| kdeplot = alias_deprecation(az.plot_kde, alias="kdeplot") | ||
| energyplot = alias_deprecation(az.plot_energy, alias="energyplot") | ||
| densityplot = alias_deprecation(az.plot_density, alias="densityplot") | ||
| pairplot = alias_deprecation(az.plot_pair, alias="pairplot") | ||
| traceplot = alias_deprecation(az.plot_trace, alias="traceplot") | ||
| compareplot = alias_deprecation(az.plot_compare, alias="compareplot") |
There was a problem hiding this comment.
It looks to me like this has already been issuing deprecation warnings. Was this working and warning against using everything slated to be removed since v4?
There was a problem hiding this comment.
That was just for utilities whose names have changed. Those could be safely removed by now yes
There was a problem hiding this comment.
Ah, then I agree with @ColCarroll that we should definitely deprecate all the other stuff well in advance of removing it.
There was a problem hiding this comment.
Also why remove the deprecation warning? In case you want to clear up the namespace then you could refactor it into something like https://peps.python.org/pep-0562/
There was a problem hiding this comment.
I removed this deprecation warning because I removed the objects that were being deprecated as well
There was a problem hiding this comment.
These one specifically were deprecated since v4, seems safe no?
There was a problem hiding this comment.
Aren't there still lots of people who use PyMC3 because of the name recognition and all the SEO? Seems pretty low-effort to provide explicit instructions for them.
There was a problem hiding this comment.
Sounds silly. This will not be the thing that people switching from v3 to v5 will find challenging
There was a problem hiding this comment.
Ya, I agree it's silly in the case of these ArviZ warnings, but you could do something similar to provide a transition period for the rest of the stuff. Proof-of-concept: ricardoV94#4
There was a problem hiding this comment.
I agree, I am going to try and do that!
|
I'm in favor. Cruft accumulates in any code base and it requires consistent effort to stem the tide, which this attempts. I don't think many people are using these functions and those can easily adjust their imports. In a version or two we'll all have forgotten about it, just like with aesara and pytensor. |
e7e8a54 to
0584aa8
Compare
|
Check out this pull request on See visual diffs & provide feedback on Jupyter Notebooks. Powered by ReviewNB |
|
re-hydrated this PR. Commits are small and focused so if we want to argue about them we can, and it's easy to drop one. Number of items in the main namespace drops from 305 -> 143. |
0584aa8 to
de73d46
Compare
|
let's add a test to avoid accidental root creep like we did in pymc-devs/pytensor#1863 |
Added, lmk what you think. |
556c541 to
314d5ba
Compare
ricardoV94
left a comment
There was a problem hiding this comment.
Do we want to add a deprecation getter to help with the transition?
I guess if we're being responsible we should. Can we give a firm cut-over date in the warning so it doesn't linger around for 2 years? |
Sure |
…t via `from sampling import *`
e6ae13e to
75c7675
Compare
|
I added the getter in |
|
Looks great @jessegrabowski just some standing minor comments from me and @aloctavodia that you haven't incorporated (and something I spotted now) |
aloctavodia
left a comment
There was a problem hiding this comment.
I added a couple more comments not directly related to the aim of this PR. So happy if they are solved in this PR or a separate one.
|
@aloctavodia tried to address your comments above |
|
Thanks, LGTM! |
|
is anything left to be done here? |
Closes #6761
Also
The following script prints 174 after and 272 before this PR:
The following entries were removed:
📚 Documentation preview 📚: https://pymc--6973.org.readthedocs.build/en/6973/