Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork7.9k
Move IPython backend mapping to Matplotlib and support entry points#27948
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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Uh oh!
There was an error while loading.Please reload this page.
Conversation
The macOS-specific backend works now. The name of the backend remains as matplotlib.use("macosx") works on all permutations of In IPython, %matplotlibosx works of all the permutations. In addition %matplotlibmacosx works if using both of the Matplotlib and IPython There is a The |
e8306d9
to530fbbc
CompareThis is WIP to move IPython's backend mapping into Matplotlib andextends it to allow backends to register themselves via [entrypoints](https://setuptools.pypa.io/en/latest/userguide/entry_point.html#entry-points-for-plugins).It is a coordinated effort across Matplotlib, IPython, matplotlib-inlineand ipympl.Closes#14311. Most of the work is in Matplotlib(matplotlib/matplotlib#27948) but I will repeat the relevant pointshere.When using a Matplotlib magic command of the form `%matplotlibsomething` the identification of the Matplotlib backend and GUI loop arenow performed in Matplotlib not IPython. This supports:1. Matplotlib backends that IPython already supports such as `qtagg` and`tkagg`.2. Other built-in Matplotlib backends such as `qtcairo`.3. Backends that use `module://something` syntax such as`module://mplcairo.qt`.4. Backends that self-register using entry points, currently `inline`and `widget`/`ipympl`.Implementation details:1. The magic command is now explicitly `%matplotlib gui_or_backend`rather than `%matplotlib gui`. This is already effectively the case ase.g. `%matplotlib ipympl` is really a backend not GUI name. WithinMatplotlib the `gui_or_backend` is checked first to see if it is a GUIname and then falls back to checking if it is a backend name.2. If you select the `inline` backend the corresponding GUI is now`None` not `inline`. All backends which do not have a GUI loop return`None`, otherwise we have to keep explicit checks within IPython forparticular backends.3. `backends` and `backend2gui` are now deprecated but are stillexposed, with a deprecation warning, if required. If using Matplotlib,ipympl, etc releases that include the corresponding changes to this PRthen they are not needed as Matplotlib deals with it all. But forbackward compatibility they must still be available for a while alongwith the remainder of the existing backend-handling code.4. I haven't yet updated the documentation but we need to keepinformation about valid GUI frameworks and I propose that we shouldremove all lists of valid Matplotlib backends, replacing them withinstructions on how to obtain the current list (pointing to theMatplotlib docs and using `%matplotlib --list`). If we keep any liststhen they will inevitably become out of date. This extends to the`backend_keys` in IPython/core/shellapp.py.Because the four related projects are loosely coupled without directdependencies on each other (except for `ipython` and`matplotlib-inline`), backward compatibility requires all possiblecombinations of projects before and after the new functionality (I willcall these "old" and "new" from now on) to continue to work. I havetested these all locally, and the CI of this PR will test new IPythonagainst old Matplotlib for example, but I need to add one or more newtemporary CI runs to test new IPython against new Matplotlib etc. Theidentification of new versus old depends on version checks on the otherlibraries, so here is a table that I will update showing the currentstatus of progress in the 4 projects:| Project | Relevant PRs | Possible release version || --- | --- | --- || matplotlib-inline |ipython/matplotlib-inline#34,ipython/matplotlib-inline#35 | 0.1.7 || ipympl |matplotlib/ipympl#549 | 0.9.4 || Matplotlib |matplotlib/matplotlib#27948 | 3.9.1 || IPython |#14371 (this) | 8.24.0 |The two widget projects can be released soon, once we are happy with theentry point approach. The other two projects' PRs will have to besynchronised as each includes version checks on each other.To do- [ ] Add CI runs against the new PR branches of the other projects.- [ ] Add comments for conditions required for backward-compatibilitycode blocks to be removed.- [ ] Update documentation, including removal of lists of validbackends.- [ ] Update version checks before merging.
Fixes#14401 which has been a bug in the 8.22.x and 8.23.x releases.When I removed the multiple initialisation of Matplotlib backends in#14330 it broke use of the following:```bashipython --matplotlibipython --matplotlib=autoipython --pylabipython --pylab=auto```by failing to display Matplotlib plot. If you specify a particular GUIevent loop such as using```bashipython --pylab=qt```then it was and is fine. So for anyone finding this, the workarounduntil the next release is to specify a GUI loop rather than relying onthe auto selection.I didn't notice this as I've been concentrating on moving the Matplotlibbackend logic from IPython to Matplotlib, and with those changes(matplotlib/matplotlib#27948) the above use cases all work OK.The fix is to reintroduce the early import of `matplotlib-inline` butonly if both the gui loop is not specified and the Matplotlib version isbefore the movement of the backend logic across to it.There are no explicit tests for this. In the future I will try to thinkof some tests for some of this IPython-Matplotlib functionality thatdon't involve installing complicated backend dependencies or addingimage comparison tests.
This is now ready for review, barring a few CI tweaks.
rather than checking the version of Matplotlib installed, hence avoiding hard-coding the check of a version that hasn't been decided yet. Ideally this targets Matplotlib 3.9.1 rather than waiting for 3.10.0. It is adding to the |
I think we should consider sneaking this is for 3.9.0 if we can get the reviews done ASAP. |
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
lib/matplotlib/backends/registry.py Outdated
"headless": "agg", | ||
"osx": "macosx", |
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.
Why did this change from macosx to osx? Actually, what would check that?
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 changed it because IPython usesosx
for the GUI framework andmacosx
for the backend. I thought this was fine for non-IPython Matplotlib but that isn't correct asFigureCanvasMac.required_interactive_framework = "macosx"
. I have been lucky to get away with these two different names for the same GUI framework; non-IPython Matplotlib never looks at this code, it only needs therequired_interactive_framework
to be consistent withcbook._get_running_interactive_framework
. But it cannot stay like this, we can't have a declaration that the macOS GUI framework isosx
when sometimes it isn't.
It would be possible to special case theosx
GUI framework to meanmacosx
on input, but on output we have no way of knowing if the caller prefersosx
tomacosx
. So I think the least bad solution here is to change this back tomacosx
and be entirely consistent within Matplotlib, and I will special case theosx
<->macosx
in IPython.
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.
Done. I'll submit the IPython PR shortly.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
}, | ||
{ | ||
"data": { | ||
"image/png": "iVBORw0KGgoAAAANSUhEUgAAARwAAADFCAYAAACGsk2zAAAAPnRFWHRTb2Z0d2FyZQBNYXRwbG90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03yoqKkhLS8PDw6Ohymxwjf11MoXU1NRG9RopikJERATr1q1j9+7d+Pj43HUfk7xO9e1qq2HlypWKnZ2dEhMToxw9elR55plnFGdnZyU3N1dRFEV56qmnlFdffbVq/P79+xVra2vlgw8+UI4dO6a88cYbio2NjZKWlqbWIfyGscf01ltvKdu3b1dOnz6tHDp0SHniiScUe3t7JSMjQ61D+I2CggIlJSVFSUlJUQBl4cKFSkpKinL+/HlFURTl1VdfVZ566qmq8WfOnFEcHByUl156STl27JiyePFixcrKStm2bZtah1CNsccTHR2trF+/Xjl58qSSlpamzJkzR9FqtcrOnTvVOoTfmDlzpqLT6ZS9e/cqOTk5VVtRUVHVmIZ4P1lU4CiKonz88cdK+/btFVtbW2XAgAHKwYMHq/5t2LBhyrRp06qN//bbb5Vu3boptra2Ss+ePZXNmzebueK7M+aY5s6dWzXWzc1NGTt2rJKcnKxC1TX75WPh/95+OY5p06Ypw4YN+80+AQEBiq2trdKpUyflyy+/NHvdNTH2eP7+978rnTt3Vuzt7RUXFxdl+PDhyu7du9UpvgZ3Oh6g2v97Q7yf5Ho4QgizsZgejhDC8kngCCHMRgJHCGE2EjhCCLORwBFCmI0EjhDCbCRwhBBmI4EjhDAbCRwhhNlI4AghzEYCRwhhNv8PCRnDMpOE+9MAAAAASUVORK5CYII=", |
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.
Do we need to commit this whole output?
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.
No, I can clean the notebook to remove the outputs. I kept it in to be consistent withtest_nbagg_01.ipynb
, which is what this is based on. But neither actually compare the output image pixels.
As an aside it would be great to have some image-comparison testing of some combination of Matplotlib and IPython/Jupyter, but I cannot find a good place to put them. There is an excellent image-based testing framework used in Jupyter projects but it would bring in some complicated test dependencies so it is not appropriate here.
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.
Done
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.
It would be best if this were removed on the initial commit instead of a later one, unless you intend for this entire PR to be squashed.
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'll squash.
b022a5f
to29c7688
CompareThe macOS failures of
are now expected when using latest IPython (8.24.0) but will not be errors whenipython/ipython#14420 is merged and released (I manually checked this now on my dev machine). I am already version-checking the result according to IPython < 8.24 or >= 8.24: so I could just expand this and check for different results for IPython < 8.24, == 8.24 and > 8.24. |
I have:
I've restarted the AppVeyor run as it was failing to get |
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.
Take or leave the comments about "headless"/extraif
condition.
I do not particularly wish to block on either of these.
Summary of small action items if you wish:
- remove extra condition
is_valid_backend
- remove reference to "headless" in docstrings for the return of both
resolve_[gui_or_]backend
methods. - make
reg.resolve_gui_or_backend("headless")
return('agg', None)
rather than('agg', 'headless')
(or potentially error if you do not want headless to be valid)
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
Uh oh!
There was an error while loading.Please reload this page.
I've done all 3 of these. |
2ba8545
intomatplotlib:mainUh oh!
There was an error while loading.Please reload this page.
…lib and support entry points
…948-on-v3.9.xBackport PR#27948 on branch v3.9.x (Move IPython backend mapping to Matplotlib and support entry points)
This is a correction to the code that moves backend handling toMatplotlib, which came to light during the review ofmatplotlib/matplotlib#27948. The GUI framework of macOSX is called `osx`in IPython but `macosx` in Matplotlib.It would be possible to allow passing a GUI framework of `osx` toMatplotlib and internally converting it to `macosx`, but the reversedirection is problematic as we would like the answer to be `osx` if weare using IPython and `macosx` if using pure Matplotlib. Therefore thesimplest solution is to do the translation in IPython. It is not idealas we want to minimise such Matplotlib-related implementation details inIPython, but the changes here are small and simple and hence I thinkthey are acceptable.There are two new private functions `_convert_gui_to_matplotlib` and`_convert_gui_from_matplotlib` to do the required checking andconversion, and these are called whenever a GUI framework name is passedto or from Matplotlib. There are only 3 places in the code where this iscurrently required.Inevitably this comes to light just after the release of IPython 8.24.0!But it is not a problem for end users until the next Matplotlib releasewhich containsmatplotlib/matplotlib#27948. If that occurs reallyquickly (sometime in May?) perhaps we could release an IPython 8.24.1just beforehand, otherwise the usual planned release at the end of nextmonth would be fine.
Uh oh!
There was an error while loading.Please reload this page.
This is WIP to move IPython's backend mapping into Matplotlib and extends it to allow backends to register themselves viaentry points. It is a coordinated effort across Matplotlib, IPython, matplotlib-inline and ipympl.Closes#27663.
The only functional changes to pure (non-IPython) Matplotlib are:
QtAgg
thenget_backend()
will now returnqtagg
.BackendRegistry.list_all()
function to list all known (built-in and dynamically-loaded) backends as this is needed by IPython. This could be made more public by exposing it inpyplot
or the top-levelmatplotlib.__init__.py
if desired.Functional improvements for IPython:
svg
,pdf
,qtcairo
,tkcairo
, etc.module://some.backend
such asmodule://mplcairo.qt
.inline
andwidget
/ipympl
.agg
) in pure IPython in that they can export to PNG, etc, but do not display an interactive window.Jupyter inherits all these IPython benefits, displaying plots that use GUI frameworks in separate windows and the others within the notebook.
Because the four related projects are loosely coupled without direct dependencies on each other (except for
ipython
andmatplotlib-inline
), backward compatibility requires all possible combinations of projects before and after the new functionality (I will call these "old" and "new" from now on) to continue to work. I have tested these all locally, and the CI of this PR will test new Matplotlib against old IPython for example, but I need to add one or more new temporary CI runs to test new Matplotlib against new IPython etc. The identification of new versus old depends on version checks on the other libraries, so here is a table that I will update showing the current status of progress in the 4 projects:The two widget projects can be released soon, once we are happy with the entry point approach. The other two projects' PRs will have to be synchronised as each includes version checks on each other.
Implementation details:
cbook._backend_module_name
has moved toBackendRegistry
. It was private, but if there are concerns about downstream use of this function I can put a shim back in.notebook
fornbagg
,qt6agg
forqtagg
andqt6cairo
forqtcairo
. I am happy withnotebook
(it is a better name thannbagg
anyway) but theqt6
ones are unfortunate as we are connecting a version-specific IPython GUI event loop (qt6
) to a somewhat version-agnostic Matplotlibqtagg
backend.module://
backend then the entry points are not needed. They are if you calllist_all()
.To do
backend2gui
which is now performed in Matplotlib.