Opened 8 years ago

Closed 8 years ago

#15168 closed defect (fixed)

Plots not shown in the notebook

Reported by: novoselt Owned by:
Priority: blocker Milestone: sage-5.12
Component: notebook Keywords: plot
Cc: Merged in: sage-5.12.rc0
Authors: Volker Braun Reviewers: Andrey Novoseltsev, Punarbasu Purkayastha
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by ppurka)

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: trac_15168_typeset_displayhook.patch

Attachments (1)

trac_15168_typeset_displayhook.patch (25.0 KB) - added by vbraun 8 years ago.
Updated patch

Download all attachments as: .zip

Change History (21)

comment:1 Changed 8 years ago by vbraun

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.

comment:2 Changed 8 years ago by novoselt

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.

comment:3 Changed 8 years ago by vbraun

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.

comment:4 Changed 8 years ago by novoselt

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 ;-)

comment:5 Changed 8 years ago by novoselt

  • Description modified (diff)
  • Priority changed from critical to blocker

comment:6 Changed 8 years ago by 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:

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

Last edited 8 years ago by ppurka (previous) (diff)

comment:7 Changed 8 years ago by ppurka

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"'

comment:8 follow-up: Changed 8 years ago by ppurka

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.

comment:9 in reply to: ↑ 8 ; follow-up: Changed 8 years ago by novoselt

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.

comment:10 Changed 8 years ago by vbraun

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 

comment:11 in reply to: ↑ 9 Changed 8 years ago by ppurka

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.

comment:12 Changed 8 years ago by vbraun

  • Authors set to Volker Braun
  • Status changed from new to needs_review

comment:13 Changed 8 years ago by ppurka

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
    
  3. 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``.
    
  4. 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'): 
    
  5. 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.
  6. 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. 
    

comment:14 Changed 8 years ago by vbraun

  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
  1. 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.

Changed 8 years ago by vbraun

Updated patch

comment:15 Changed 8 years ago by novoselt

Works for me, thanks Volker!

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

comment:16 Changed 8 years ago by ppurka

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] 

comment:17 Changed 8 years ago by vbraun

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...

comment:18 Changed 8 years ago by ppurka

  • Reviewers set to Andrey Novoseltsev, Punarbasu Purkayastha
  • Status changed from needs_review to positive_review

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!

comment:19 Changed 8 years ago by ppurka

  • Description modified (diff)

comment:20 Changed 8 years ago by jdemeyer

  • Merged in set to sage-5.12.rc0
  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.