Skip to content
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

Plots not shown in the notebook #15168

Closed
novoselt opened this issue Sep 6, 2013 · 22 comments
Closed

Plots not shown in the notebook #15168

novoselt opened this issue Sep 6, 2013 · 22 comments

Comments

@novoselt
Copy link
Member

novoselt commented Sep 6, 2013

I observe this bahaviour in Sage-5.12.beta4: after checking "Typeset" things that generate a plot show its text representation only. Adding .show() in the end does show the plot, but it is definitely annoying and unclear for new users, so would be nice if it did not hit 5.12.

This may be related to #14469 and corresponding upgrade to sagenb-0.10.7.2 in #15016.

On the same machine with the same settings running 5.11 + sagenb-0.10.7.1 works fine.


Apply to devel/sage: attachment: trac_15168_typeset_displayhook.patch

Component: notebook

Keywords: plot

Author: Volker Braun

Reviewer: Andrey Novoseltsev, Punarbasu Purkayastha

Merged: sage-5.12.rc0

Issue created by migration from https://trac.sagemath.org/ticket/15168

@novoselt novoselt added this to the sage-5.12 milestone Sep 6, 2013
@vbraun
Copy link
Member

vbraun commented Sep 6, 2013

comment:1

What exactly are you doing to start the notebook? notebook(server_pool=['vbraun@localhost']) works for me, plots are displayed immediately. Both the compute server and the notebook web server version of Sage must match.

@novoselt
Copy link
Member Author

novoselt commented Sep 6, 2013

comment:2

Are you running the notebook as vbraun as well? I use two separate accounts in the same group and they do run on the same machine, so versions of sage for the notebook and worker are the same.

@vbraun
Copy link
Member

vbraun commented Sep 6, 2013

comment:3

It also works if I use a different account, i.e. notebook(server_pool=['other@localhost']) works with the current git and with vanilla sage-5.12.beta3.

@novoselt
Copy link
Member Author

novoselt commented Sep 6, 2013

comment:4

OK, I am not completely out of my mind, it just takes more effort to trigger it: all was ok in my freshly started beta4, until I checked "Typeset", which prints a string for a plot. Unchecking it did not help - still prints a string. Unchecking AND restarting the worksheet lets plots show up again.

This is actually not related to multi-user setup or anything with security, I think it is a blocker then, but probably should not be hard to fix for people in the know ;-)

@novoselt

This comment has been minimized.

@ppurka
Copy link
Member

ppurka commented Sep 7, 2013

comment:6

Ok. I wonder if it is really #14358 that introduced this. I can confirm that this does not work in a server pool setup. I get the following in my console where I started the server:

2013-09-07 16:28:29+0800 [HTTPChannel,2,127.0.0.1] got EOF subprocess must have crashed...
2013-09-07 16:28:29+0800 [HTTPChannel,2,127.0.0.1] ssh: Could not resolve hostname b: Name or service not known
2013-09-07 16:28:29+0800 [HTTPChannel,2,127.0.0.1] 
2013-09-07 16:28:29+0800 [HTTPChannel,2,127.0.0.1] import os;os.chdir("/tmp/tmpSFPXPO");
2013-09-07 16:28:29+0800 [HTTPChannel,2,127.0.0.1] execfile("_sage_input_2.py")
2013-09-07 16:28:29+0800 [HTTPChannel,2,127.0.0.1] 
2013-09-07 16:28:29+0800 [HTTPChannel,2,127.0.0.1] got EOF subprocess must have crashed...
2013-09-07 16:28:29+0800 [HTTPChannel,2,127.0.0.1] 
2013-09-07 16:28:29+0800 [HTTPChannel,2,127.0.0.1] import os;os.chdir("/tmp/tmpCAq4xl");
2013-09-07 16:28:29+0800 [HTTPChannel,2,127.0.0.1] execfile("_sage_input_1.py")
2013-09-07 16:28:29+0800 [HTTPChannel,2,127.0.0.1] ssh: Could not resolve hostname t: Name or service not known
2013-09-07 16:28:29+0800 [HTTPChannel,2,127.0.0.1] 

This is the output after I run plot(x).show() in a worksheet. It does not get the correct hostname??

Edit: Ticket is #14469 not #14358

@ppurka
Copy link
Member

ppurka commented Sep 7, 2013

comment:7

More error after trying to plot many times. I am using the git version of sage; I will retry with a prerelease version to find out if this error is from the git version of sage.

2013-09-07 16:32:36+0800 [HTTPChannel,2,127.0.0.1] 
2013-09-07 16:32:36+0800 [HTTPChannel,2,127.0.0.1] 
2013-09-07 16:32:36+0800 [HTTPChannel,2,127.0.0.1] got EOF subprocess must have crashed...
2013-09-07 16:32:36+0800 [HTTPChannel,2,127.0.0.1] usage: ssh [-1246AaCfgKkMNnqsTtVvXxYy] [-b bind_address] [-c cipher_spec]
2013-09-07 16:32:36+0800 [HTTPChannel,2,127.0.0.1]            [-D [bind_address:]port] [-e escape_char] [-F configfile]
2013-09-07 16:32:36+0800 [HTTPChannel,2,127.0.0.1]            [-I pkcs11] [-i identity_file]
2013-09-07 16:32:36+0800 [HTTPChannel,2,127.0.0.1]            [-L [bind_address:]port:host:hostport]
2013-09-07 16:32:36+0800 [HTTPChannel,2,127.0.0.1]            [-l login_name] [-m mac_spec] [-O ctl_cmd] [-o option] [-p port]
2013-09-07 16:32:36+0800 [HTTPChannel,2,127.0.0.1]            [-R [bind_address:]port:host:hostport] [-S ctl_path]
2013-09-07 16:32:36+0800 [HTTPChannel,2,127.0.0.1]            [-W host:port] [-w local_tun[:remote_tun]]
2013-09-07 16:32:36+0800 [HTTPChannel,2,127.0.0.1]            [user@]hostname [command]
2013-09-07 16:32:36+0800 [HTTPChannel,2,127.0.0.1] 
2013-09-07 16:32:37+0800 [HTTPChannel,2,127.0.0.1] ERROR initializing compute process:
2013-09-07 16:32:37+0800 [HTTPChannel,2,127.0.0.1] 
2013-09-07 16:32:37+0800 [HTTPChannel,2,127.0.0.1] unable to start subprocess using command 'sage-native-execute ssh -t @ "/home/punarbasu/Installations/sage/sage -python"'
2013-09-07 16:32:37+0800 [-] WSGI application error
	Traceback (most recent call last):
	  File "/home/punarbasu/Installations/sage/local/lib/python2.7/site-packages/Twisted-13.1.0-py2.7-linux-x86_64.egg/twisted/python/threadpool.py", line 212, in _worker
	    o = self.q.get()
	  File "/home/punarbasu/Installations/sage/local/lib/python2.7/site-packages/Twisted-13.1.0-py2.7-linux-x86_64.egg/twisted/python/context.py", line 118, in callWithContext
	    return self.currentContext().callWithContext(ctx, func, *args, **kw)
	  File "/home/punarbasu/Installations/sage/local/lib/python2.7/site-packages/Twisted-13.1.0-py2.7-linux-x86_64.egg/twisted/python/context.py", line 83, in callWithContext
	    self.contexts.pop()
	  File "/home/punarbasu/Installations/sage/local/lib/python2.7/site-packages/Twisted-13.1.0-py2.7-linux-x86_64.egg/twisted/web/wsgi.py", line 340, in run
	    self.started = True
	--- <exception caught here> ---
	  File "/home/punarbasu/Installations/sage/local/lib/python2.7/site-packages/Twisted-13.1.0-py2.7-linux-x86_64.egg/twisted/web/wsgi.py", line 315, in run
	    appIterator = self.application(self.environ, self.startResponse)
	  File "/home/punarbasu/Installations/sage/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1836, in __call__
	    return self.wsgi_app(environ, start_response)
	  File "/home/punarbasu/Installations/sage/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1820, in wsgi_app
	    response = self.make_response(self.handle_exception(e))
	  File "/home/punarbasu/Installations/sage/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1403, in handle_exception
	    reraise(exc_type, exc_value, tb)
	  File "/home/punarbasu/Installations/sage/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1817, in wsgi_app
	    response = self.full_dispatch_request()
	  File "/home/punarbasu/Installations/sage/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1477, in full_dispatch_request
	    rv = self.handle_user_exception(e)
	  File "/home/punarbasu/Installations/sage/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1381, in handle_user_exception
	    reraise(exc_type, exc_value, tb)
	  File "/home/punarbasu/Installations/sage/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1475, in full_dispatch_request
	    rv = self.dispatch_request()
	  File "/home/punarbasu/Installations/sage/local/lib/python2.7/site-packages/Flask-0.10.1-py2.7.egg/flask/app.py", line 1461, in dispatch_request
	    return self.view_functions[rule.endpoint](**req.view_args)
	  File "/home/punarbasu/Installations/sage/local/lib/python2.7/site-packages/sagenb-0.10.7.2-py2.7.egg/sagenb/flask_version/decorators.py", line 22, in wrapper
	    return f(*args, **kwds)
	  File "/home/punarbasu/Installations/sage/local/lib/python2.7/site-packages/sagenb-0.10.7.2-py2.7.egg/sagenb/flask_version/worksheet.py", line 46, in wrapper
	    return f(username, id, **kwds)
	  File "/home/punarbasu/Installations/sage/local/lib/python2.7/site-packages/sagenb-0.10.7.2-py2.7.egg/sagenb/flask_version/worksheet.py", line 135, in wrapper
	    return f(*args, **kwds)
	  File "/home/punarbasu/Installations/sage/local/lib/python2.7/site-packages/sagenb-0.10.7.2-py2.7.egg/sagenb/flask_version/worksheet.py", line 443, in worksheet_cell_update
	    worksheet.check_comp()
	  File "/home/punarbasu/Installations/sage/local/lib/python2.7/site-packages/sagenb-0.10.7.2-py2.7.egg/sagenb/notebook/worksheet.py", line 3308, in check_comp
	    C.set_output_text(out, html, sage=self.sage())
	  File "/home/punarbasu/Installations/sage/local/lib/python2.7/site-packages/sagenb-0.10.7.2-py2.7.egg/sagenb/notebook/worksheet.py", line 3049, in sage
	    self.initialize_sage()
	  File "/home/punarbasu/Installations/sage/local/lib/python2.7/site-packages/sagenb-0.10.7.2-py2.7.egg/sagenb/notebook/worksheet.py", line 2996, in initialize_sage
	    raise RuntimeError, msg
	exceptions.RuntimeError: unable to start subprocess using command 'sage-native-execute ssh -t @ "/home/punarbasu/Installations/sage/sage -python"'

@ppurka
Copy link
Member

ppurka commented Sep 7, 2013

comment:8

Verified that the errors in my comment:6 occurs in the prerelease version of sage-5.12.beta4. Haven't seen the exceptions in comment:7.

@novoselt
Copy link
Member Author

novoselt commented Sep 7, 2013

comment:9

Replying to @ppurka:

Ok. I wonder if it is really #14358 that introduced this. I can confirm that this does not work in a server pool setup. I get the following in my console where I started the server:

Was #14358 a typo? It is a new ticket for an issue that existed for a while (but hopefully will be fixed as well, of course ;-)). Sorry for not mentioning clearly that here I have problems even with 2D-plots, like

plot(sin(x))

and as discovered yesterday thanks to Volker - it is present even in a single user setup on http://localhost.

@vbraun
Copy link
Member

vbraun commented Sep 7, 2013

comment:10

This has nothing to do with the sagenb code, the pretty_print_default command in Sage doesn't clean up after itself:

sage: plot(sin)   # works as expected, displays graphics

sage: pretty_print_default(True)
sage: plot(sin)
Graphics object consisting of 1 graphics primitive
sage: pretty_print_default(False)
sage: plot(sin)
Graphics object consisting of 1 graphics primitive 

@ppurka
Copy link
Member

ppurka commented Sep 7, 2013

comment:11

Replying to @novoselt:

Was #14358 a typo? It is a new ticket for an issue that existed for a while (but hopefully will be fixed as well, of course ;-)).

Yes, indeed it was a typo. I meant to quote vbraun's ticket - #14469.

@vbraun
Copy link
Member

vbraun commented Sep 8, 2013

Author: Volker Braun

@ppurka
Copy link
Member

ppurka commented Sep 9, 2013

comment:13

A couple of comments regarding the patch

  1. There are lots of trailing whitespace :)
  2. Can you format #14466 using the :trac: format
265	        In #14466 we override IPython's special printing of ``type`` objects
  1. In set_display, the INPUT should mention the default input.
285	        - ``mode`` -- string. One of ``simple``, ``ascii_art``, or ``typeset``.

- to -

285	        - ``mode`` -- string (default: ``simple``). One of ``simple``, ``ascii_art``, or ``typeset``.
  1. In set_display, the default keyword value should be simple in keeping with the default mode="simple".
279	    def set_display(self, mode='ascii_art'): 
  1. The method try_format_graphics does not return a boolean, contrary to what its documentation says. The method seems to work because if None fails when the display is not graphics.
  2. Should we remove pretty_print_default from the global namespace? I am referring to this comment:
2447	    This function is pretty useless without the notebook, it shoudn't 
2448	    be in the global namespace. 

@vbraun
Copy link
Member

vbraun commented Sep 9, 2013

comment:14
  1. Easy to solve: M-x whitespace-mode RET ;-)

2., 3.: I've removed the default, its not a method thats intended to be called directly by the user so we might just as well require library code to be explicit.

  1. Fixed

  2. The notebook calls pretty_print_default, so we first need to fix that in the notebook (including new notebook spkg version). In the interest of fixing plotting asap I think we should leave that for later.

@vbraun
Copy link
Member

vbraun commented Sep 9, 2013

Attachment: trac_15168_typeset_displayhook.patch.gz

Updated patch

@novoselt
Copy link
Member Author

novoselt commented Sep 9, 2013

comment:15

Works for me, thanks Volker!

(I'll leave nitpicking for ppurka ;-))

@ppurka
Copy link
Member

ppurka commented Sep 10, 2013

comment:16

Sorry this patch works on normal notebook setup, but plots still don't work for me for server pool setup. This is the output I get on evaluating plot(x)

~/tmp/sagenb_test» ~/Installations/sage-5.12.beta4/sage -n port=8888 accounts=True interface='' "server_pool=['sagenb@localhost']" openid=True automatic_login=False port_tries=0 directory=./a.sagenb
┌────────────────────────────────────────────────────────────────────┐
│ Sage Version 5.12.beta4, Release Date: 2013-08-30                  │
│ Type "notebook()" for the browser-based notebook interface.        │
│ Type "help()" for help.                                            │
└────────────────────────────────────────────────────────────────────┘
┏━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┓
┃ Warning: this is a prerelease version, and it may be unstable.     ┃
┗━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━┛

Please wait while the Sage Notebook server starts...
notebook(port=8888,accounts=True,interface=r'''''',server_pool=r'''['sagenb@localhost']''',openid=True,automatic_login=False,port_tries=0,directory=r'''./a.sagenb''')
**********************************************************************
WARNING: Running the notebook insecurely not on localhost is dangerous
because its possible for people to sniff passwords and gain access to
your account. Make sure you know what you are doing.
**********************************************************************
The notebook files are stored in: a.sagenb
**********************************************************************
WARNING: Insecure notebook server listening on external interface.
Unless you are running this via ssh port forwarding, you are
**crazy**!  You should run the notebook with the option secure=True.
**********************************************************************
**************************************************
*                                                *
* Open your web browser to http://localhost:8888 *
*                                                *
**************************************************
Executing twistd  --pidfile="a.sagenb/sagenb.pid" -ny "a.sagenb/twistedconf.tac"
2013-09-10 13:51:18+0800 [-] Log opened.
2013-09-10 13:51:18+0800 [-] twistd 13.1.0 (/home/punarbasu/Installations/sage-5.12.beta4/local/bin/python 2.7.5) starting up.
2013-09-10 13:51:18+0800 [-] reactor class: twisted.internet.epollreactor.EPollReactor.
2013-09-10 13:51:18+0800 [-] QuietSite starting on 8888
2013-09-10 13:51:18+0800 [-] Starting factory <__builtin__.QuietSite instance at 0x671e5a8>
2013-09-10 13:51:34+0800 [HTTPChannel,8,127.0.0.1] got EOF subprocess must have crashed...
2013-09-10 13:51:34+0800 [HTTPChannel,8,127.0.0.1] ssh: Could not resolve hostname a: Name or service not known
2013-09-10 13:51:34+0800 [HTTPChannel,8,127.0.0.1] 
2013-09-10 13:51:34+0800 [HTTPChannel,8,127.0.0.1] import os;os.chdir("/tmp/tmpQBuIjM");
2013-09-10 13:51:34+0800 [HTTPChannel,8,127.0.0.1] execfile("_sage_input_2.py")
2013-09-10 13:51:34+0800 [HTTPChannel,8,127.0.0.1] 
2013-09-10 13:51:34+0800 [HTTPChannel,8,127.0.0.1] import os;os.chdir("/tmp/tmpHowNpR");
2013-09-10 13:51:34+0800 [HTTPChannel,8,127.0.0.1] execfile("_sage_input_3.py")
2013-09-10 13:51:34+0800 [HTTPChannel,8,127.0.0.1] 
2013-09-10 13:51:34+0800 [HTTPChannel,8,127.0.0.1] import os;os.chdir("/tmp/tmpVyZzb5");
2013-09-10 13:51:34+0800 [HTTPChannel,8,127.0.0.1] execfile("_sage_input_4.py")
2013-09-10 13:51:34+0800 [HTTPChannel,8,127.0.0.1] 



# ALso another one
2013-09-10 13:54:15+0800 [HTTPChannel,15,127.0.0.1] got EOF subprocess must have crashed...
2013-09-10 13:54:15+0800 [HTTPChannel,15,127.0.0.1] 
2013-09-10 13:54:15+0800 [HTTPChannel,15,127.0.0.1] import os;os.chdir("/tmp/tmpWS7Rb9");
2013-09-10 13:54:15+0800 [HTTPChannel,15,127.0.0.1] execfile("_sage_input_1.py")
2013-09-10 13:54:15+0800 [HTTPChannel,15,127.0.0.1] ssh: Could not resolve hostname n: Name or service not known
2013-09-10 13:54:15+0800 [HTTPChannel,15,127.0.0.1] 
2013-09-10 13:54:15+0800 [HTTPChannel,16,127.0.0.1] got EOF subprocess must have crashed...
2013-09-10 13:54:15+0800 [HTTPChannel,16,127.0.0.1] 
2013-09-10 13:54:15+0800 [HTTPChannel,16,127.0.0.1] import os;os.chdir("/tmp/tmpE2UNNA");
2013-09-10 13:54:15+0800 [HTTPChannel,16,127.0.0.1] execfile("_sage_input_1.py")
2013-09-10 13:54:15+0800 [HTTPChannel,16,127.0.0.1] ssh: Could not resolve hostname n: Name or service not known
2013-09-10 13:54:15+0800 [HTTPChannel,16,127.0.0.1] 
2013-09-10 13:54:16+0800 [HTTPChannel,16,127.0.0.1] got EOF subprocess must have crashed...
2013-09-10 13:54:16+0800 [HTTPChannel,16,127.0.0.1] 
2013-09-10 13:54:16+0800 [HTTPChannel,16,127.0.0.1] import os;os.chdir("/tmp/tmpBPZ8ZZ");
2013-09-10 13:54:16+0800 [HTTPChannel,16,127.0.0.1] execfile("_sage_input_1.py")
2013-09-10 13:54:16+0800 [HTTPChannel,16,127.0.0.1] ssh: Could not resolve hostname  "/home/punarbasu/Installations/sage-5.12.beta4/sage -python": Name or service not known
2013-09-10 13:54:16+0800 [HTTPChannel,16,127.0.0.1] 

@vbraun
Copy link
Member

vbraun commented Sep 10, 2013

comment:17

The server_pool should be a list of strings, not a string that evaluates to a list of strings:

notebook(server_pool=['sagenb@localhost'])

Though some argument checking would have been nice...

@ppurka
Copy link
Member

ppurka commented Sep 10, 2013

Reviewer: Andrey Novoseltsev, Punarbasu Purkayastha

@ppurka
Copy link
Member

ppurka commented Sep 10, 2013

comment:18

Oops. So sorry. It does work. I had to quote it because of the shell and apparently it is passed in quoted to the python process that actually launches the notebook.

I had tested it on sage/{misc,groups/matrix_gps} and it passed all tests. Since the patchbot was also ok with the previous patch (except for some weird startup stuff) it should be good to go. Thanks for the quick fix!

@ppurka

This comment has been minimized.

@jdemeyer
Copy link

jdemeyer commented Oct 1, 2013

Merged: sage-5.12.rc0

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

No branches or pull requests

4 participants