Skip to content

FIX: do not consider webagg and nbagg "interactive" for fallback #15512

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

Merged
merged 6 commits into from
Oct 31, 2019

Conversation

tacaswell
Copy link
Member

PR Summary

There is logic in pyplot to determine if the user has is some way
selected a backend which is incompatible with the interactive
framework that we detect is running. This helps prevent issues where
the user is already using one GUI frame work (ex tk) before Matplotlib
is imported and has Matplotlib configured to use Qt. The other place
this behavior is desired is if Matplotlib is configured to use a GUI
framework by default, but is then imported on a headless server. By
detecting there is no DISPLAY we fall back to Agg rather than failing
to import.

From the point of view of having UI events, webagg and nbagg are
interactive backends, however from the point of view of requiring
DISPLAY they are not.

This is the minimal fix, filtering out these two backends in pyplot
rather than changing this in rcsetup, incase anyone is relying on
those lists for other purposes.

closes #14903

This will backport badly due to the change in line light below this one but 🤷‍♀️

Will work on a test tomorrow.

@tacaswell tacaswell added this to the v3.1.2 milestone Oct 25, 2019
@tacaswell tacaswell force-pushed the fix_webagg_fallback branch from 73c0df7 to 58b8743 Compare October 25, 2019 12:27
@tacaswell
Copy link
Member Author

force pushed to fix syntax.

@tacaswell
Copy link
Member Author

env's don't work the same in windows?

@tacaswell tacaswell force-pushed the fix_webagg_fallback branch from b797f29 to 70ad7f7 Compare October 28, 2019 04:14
@jklymak jklymak requested a review from story645 October 29, 2019 19:46
@jklymak jklymak added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Oct 29, 2019
tacaswell and others added 5 commits October 30, 2019 22:00
There is logic in pyplot to determine if the user has is some way
selected a backend which is incompatible with the interactive
framework that we detect is running.  This helps prevent issues where
the user is already using one GUI frame work (ex tk) before Matplotlib
is imported and has Matplotlib configured to use Qt.  The other place
this behavior is desired is if Matplotlib is configured to use a GUI
framework by default, but is then imported on a headless server.  By
detecting there is no DISPLAY we fall back to Agg rather than failing
to import.

From the point of view of having UI events, webagg and nbagg are
interactive backends, however from the point of view of requiring
DISPLAY they are not.

This is the minimal fix, filtering out these two backends in pyplot
rather than changing this in rcsetup, incase anyone is relying on
those lists for other purposes.

closes matplotlib#14903
Co-Authored-By: Elliott Sales de Andrade <quantum.analyst@gmail.com>
@tacaswell tacaswell force-pushed the fix_webagg_fallback branch from 70ad7f7 to fd9f102 Compare October 31, 2019 02:00
Comment on lines 17 to 18
ret = subprocess.call(
[sys.executable, "-c", test_code],
Copy link
Member

Choose a reason for hiding this comment

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

on windows these two lines work fine/return 'WebAgg' and 'nbAgg' respectively.

)
ret = subprocess.call(
[sys.executable, "-c", test_code],
env={"MPLBACKEND": backend, "DISPLAY": ""}
Copy link
Member

@story645 story645 Oct 31, 2019

Choose a reason for hiding this comment

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

this line, even just env={"MPLBACKEND": backend} or env={"DISPLAY": ""} triggers the windows failures

from the Python docs:

Note
If specified, env must provide any variables required for the program to execute. On Windows, in order to run a side-by-side assembly the specified env must include a valid SystemRoot.

thanks to @story645 for sorting this out
@jklymak
Copy link
Member

jklymak commented Oct 31, 2019

I think this stuff really needs some docs somewhere or we will forget why we made this change.

@tacaswell
Copy link
Member Author

@jklymak There is a long explanation in the commit message which we will see in the future when we check git blame.

Copy link
Contributor

@dopplershift dopplershift left a comment

Choose a reason for hiding this comment

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

Looks sane to me.

@dopplershift dopplershift merged commit 126de7f into matplotlib:master Oct 31, 2019
@lumberbot-app
Copy link

lumberbot-app bot commented Oct 31, 2019

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
$ git checkout v3.1.x
$ git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
$ git cherry-pick -m1 126de7f92cf2f7cf32279bb60736ea5c115dd122
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
$ git commit -am 'Backport PR #15512: FIX: do not consider webagg and nbagg "interactive" for fallback'
  1. Push to a named branch :
git push YOURFORK v3.1.x:auto-backport-of-pr-15512-on-v3.1.x
  1. Create a PR against branch v3.1.x, I would have named this PR:

"Backport PR #15512 on branch v3.1.x"

And apply the correct labels and milestones.

Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon!

If these instruction are inaccurate, feel free to suggest an improvement.

@lumberbot-app
Copy link

lumberbot-app bot commented Oct 31, 2019

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
$ git checkout v3.2.x
$ git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
$ git cherry-pick -m1 126de7f92cf2f7cf32279bb60736ea5c115dd122
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
$ git commit -am 'Backport PR #15512: FIX: do not consider webagg and nbagg "interactive" for fallback'
  1. Push to a named branch :
git push YOURFORK v3.2.x:auto-backport-of-pr-15512-on-v3.2.x
  1. Create a PR against branch v3.2.x, I would have named this PR:

"Backport PR #15512 on branch v3.2.x"

And apply the correct labels and milestones.

Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon!

If these instruction are inaccurate, feel free to suggest an improvement.

@tacaswell tacaswell deleted the fix_webagg_fallback branch November 1, 2019 00:53
story645 pushed a commit to story645/matplotlib that referenced this pull request Nov 1, 2019
FIX: do not consider webagg and nbagg "interactive" for fallback
story645 pushed a commit to story645/matplotlib that referenced this pull request Nov 1, 2019
…"interactive" for fallback'

FIX: do not consider webagg and nbagg "interactive" for fallback
story645 pushed a commit to story645/matplotlib that referenced this pull request Nov 1, 2019
…"interactive" for fallback'

FIX: do not consider webagg and nbagg "interactive" for fallback
story645 pushed a commit to story645/matplotlib that referenced this pull request Nov 1, 2019
story645 pushed a commit to story645/matplotlib that referenced this pull request Nov 1, 2019
story645 pushed a commit to story645/matplotlib that referenced this pull request Nov 1, 2019
story645 pushed a commit to story645/matplotlib that referenced this pull request Nov 1, 2019
timhoffm added a commit that referenced this pull request Nov 1, 2019
jklymak added a commit that referenced this pull request Nov 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
GUI: nbagg GUI: webagg Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

'MPLBACKEND=webagg' is overwritten by agg when $DISPLAY is not set on Linux
5 participants