Skip to content

Add backend_inline to non_interactive_bk list #14181

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

Conversation

jstpierref
Copy link

It tackles #14171. By adding module://ipykernel.pylab.backend_inline to the list of non interactive backends, the Jupyter notebook warning don't show up anymore. Let me know what you think!

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

@tacaswell tacaswell added this to the v3.2.0 milestone May 11, 2019
@tacaswell
Copy link
Member

The failure definitely looks real so that will need to be addressed.

I do not understand why this change suppresses the warning. The issue seems to be that in Figure.show() we are warning if a) the manager.show() raises NonGuiException and b) we are not on a headless linux system. This change is to the list of backends we ship as part of Matplotlib on the rcparams file which is only used to validate that a backend name is valid.

I think the correct fix for this is to change what manager.show() does in the inline backend (which lives at https://github.com/ipython/ipykernel/blob/master/ipykernel/pylab/backend_inline.py ). Probably can not update it to use the new helper machinery (as they will need to support old versions of Matplotlib).

@tacaswell
Copy link
Member

Also, thank you for your work on this! Sorry my previous comment is mostly negative.

@jstpierref
Copy link
Author

jstpierref commented May 12, 2019

You're right! I got confused by using the warn=False param in the show method while experimenting. Because ipynb backends are defined in the ipykernel project, do you think putting a condition on ipynb backends before the warning is raised would be a viable solution?

At figure.py#L440, it would look like:

if manager is not None: 
    try:
        manager.show()
        return
    except NonGuiException:
        pass
    if (backends._get_running_interactive_framework() != "headless"
        and get_backend() != "module://ipykernel.pylab.backend_inline"
        and warn):
        cbook._warn_external('Matplotlib is currently using %s, which is '
                                 'a non-GUI backend, so cannot show the '
                                 'figure.' % get_backend())

@anntzer
Copy link
Contributor

anntzer commented May 13, 2019

As suggested by @tacaswell above, I think the correct fix lives on ipykernel's side, as matplotlib can't possibly keep track of each and every backend that exists out there.

@jstpierref
Copy link
Author

Yes, makes sense!

@tacaswell tacaswell modified the milestones: v3.2.0, unassigned May 13, 2019
@tacaswell
Copy link
Member

I'm going to close this @nitrofortin please let us know if you need any help over on the iptyhon/jupyter side!

Hope we hear from you again.

@tacaswell tacaswell closed this May 13, 2019
@jstpierref
Copy link
Author

Thank you, I will investigate on the ipython side how this could be fixed :)

@tacaswell
Copy link
Member

Was an issue / PR ever opened on the jupyter side?

@jstpierref
Copy link
Author

No!

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

Successfully merging this pull request may close these issues.

3 participants