Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Don't warn in show() when running a non-interactive backened headless. #12267

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

Closed
wants to merge 1 commit into from

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Sep 25, 2018

On Linux, $DISPLAY is unset, then we can't run a GUI toolkit anyways, so
don't warn about that in show().

Delete the Note in the docstring which was redundant with the Parameters
entry.

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 8 compliant
  • New features are documented, with examples if plot related
  • Documentation is sphinx and numpydoc compliant
  • Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

@dstansby
Copy link
Member

Not sure about this; users might still want to be warned about unnecessary calls to show(), even (maybe especially) if they are running headless. Is there a particular use case for this change?

@jklymak
Copy link
Member

jklymak commented Sep 25, 2018

I think the motivation is that this spams the doc builds with thousands of these messages.

I think this is fine. I think the issue the warning addresses is not headless servers, but people running with a monitor who are surprised when show() doesn't do anything because they don't realize that their backend is agg.

@timhoffm
Copy link
Member

Generally, I support the direction this is taking.

@dstansby if you think there needs to be more selective control, one could introduce additional values like „when-headless“.

Btw.: Are there usecases when I want to control the behavior selectively per call? I would probably use the same value for a whole session or program. To me, the whole topic feels like it should rather be a config option than a function parameter.

@anntzer
Copy link
Contributor Author

anntzer commented Sep 26, 2018

I think the motivation is that this spams the doc builds with thousands of these messages.

Yes. (Also CI more generally, specifically https://github.com/anntzer/mplcursors/blob/v0.2.1/tests/test_mplcursors.py#L614)

if you think there needs to be more selective control, one could introduce additional values like „when-headless“.

Let's not. If you really want to control it, just wrap it in your own warnings.catch_warnings...

Are there usecases when I want to control the behavior selectively per call?

Likely not, but it's also exceedingly rare to call show() multiple times so it seems good enough to have the "config" for it as a function kwarg... I think having a global config for it would just make things more convoluted.

@QuLogic
Copy link
Member

QuLogic commented Sep 28, 2018

This may be more pressing since doc builds are now failing due to this warning.

@QuLogic
Copy link
Member

QuLogic commented Sep 28, 2018

I still see this in doc builds though:

generating gallery for gallery/widgets... [ 58%] polygon_selector_demo.py
/home/circleci/project/lib/matplotlib/figure.py:439: UserWarning: Matplotlib is currently using agg, which is a non-GUI backend, so cannot show the figure.

so will it help?

@jklymak
Copy link
Member

jklymak commented Sep 28, 2018

Ooops, hmm!

On Linux, $DISPLAY is unset, then we can't run a GUI toolkit anyways, so
don't warn about that in `show()`.

Delete the Note in the docstring which was redundant with the Parameters
entry.
@anntzer
Copy link
Contributor Author

anntzer commented Sep 28, 2018

rebased, let's see whether the build passes... edit: apparently no...

@anntzer anntzer mentioned this pull request Sep 28, 2018
6 tasks
@tacaswell tacaswell added this to the v3.1 milestone Sep 28, 2018
@QuLogic
Copy link
Member

QuLogic commented Sep 28, 2018

Wasn't this applied as part of #12322?

@anntzer
Copy link
Contributor Author

anntzer commented Sep 29, 2018

Yes.

@anntzer anntzer closed this Sep 29, 2018
@anntzer anntzer deleted the headless-show branch September 29, 2018 10:23
@anntzer anntzer modified the milestones: v3.1, v3.0.x Nov 3, 2018
@anntzer
Copy link
Contributor Author

anntzer commented Nov 3, 2018

(remilestoned to match #12322).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants