I have had problems getting *reliably* R graphics from the Sage notebook.

This works with no (reproductible) problems from a server launched by "sage 
-n" from an X11 terminal. The problems start when I try to use a 
pre-launched server, whether from the same machine or from another machine 
through a ssh port redirection. To make a long story short, I have been 
able to reduce the problem to the following test case :

Let S be a server and L an laptop client. Both are runing Debian (mostly) 
wheezy. The server has a 5.6 installation of Sage (with 
trac#14008<http://trac.sagemath.org/sage_trac/ticket/14008>installed) in the 
home directory of the "sage" user.

in L : create a ssh redirection from L to S on some suitably chosen port 
xxxxx :
L : ssh -f -N -L:xxxxx:localhost:xxxxx SSS.SSS.SSS.SSS

login to S from L *with an ssh connection relaying X* :
L$: ssh -Y s...@sss.sss.sss.sss

In this terminal, start the sage server :
sage -n directory=/home/sage/sage_notebooks.sagenb/ port=xxxxx 
automatic_login=False &
DO NOT LOGOUT FROM THI SSH SESSION NOW !

in L, start a browser and go to localhost:xxxxx
Log in
Create a small test worksheet :
first cell :
r('capabilities("png")')
you get the R answer :

   png 
  TRUE 

Second cell : an idiotic test :
r.png()
r.plot(r.rnorm(1000,0,1),r.rnorm(1000,0,1),xlab='X',ylab="Y")
you get first the answer to r.png :

  null device 
            1 

then a graph :

(BTW, this graph demonstrates a problem with r.plot which I have to explore 
more fully before reporting...).

This is OUTPUT 1 from now on.

Then, go back to your terminal and disconnect your ssh session from S.
Go back to tour worksheet, and use the "action" menu to 1) Restart the 
worksheet and 2) Evaluate all.
The first cell now gives :
         

  png 
FALSE 

   And the second (after expansion) :
        

Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "_sage_input_3.py", line 10, in <module>
    exec compile(u'open("___code___.py","w").write("# -*- coding: utf-8 -*-\\n" 
+ 
_support_.preparse_worksheet_cell(base64.b64decode("ci5wbmcoKQpyLnBsb3Qoci5ybm9ybSgxMDAwLDAsMSksci5ybm9ybSgxMDAwLDAsMSkseGxhYj0nWCcseWxhYj0iWSIp"),globals())+"\\n");
 execfile(os.path.abspath("___code___.py"))
  File "", line 1, in <module>
    
  File "/tmp/tmpFygLc1/___code___.py", line 3, in <module>
    r.png()
  File 
"/home/sage/sage-5.6/local/lib/python2.7/site-packages/sage/interfaces/r.py", 
line 364, in png
    raise RuntimeError, "R was not compiled with PNG support"
RuntimeError: R was not compiled with PNG support


This is OUTPUT 2 from now on.

Now, go back to your terminal and reconect to S *without X relay* :
L$: ssh s...@sss.sss.sss.sss

Going back to the browser, restart the worksheet and evaluate all cells. 
You get OUTPUT TWO (modulo the points of the graph, of course).

In the terminal : logout from S then reconnect to it *with X relay*. In the 
browser, restart the worksheet and evaluate all cells : you get OUTPUT 1 
again.
 
!!!!!

The converse experiment (start the server in a non-X-relayed terminal, then 
connect with X relay) does not work : in all cases, you get OUTPUT 2.

I also tried to start my port redirection with X relay, to no avail. : you 
get OUTPUT 2...

Former experiments (not formalized yet) let me think that you get OUTPUT 1 
as long as the sage user has a connexion to an X server : my first tries 
were from a VNC server with a terminal where I sudo'd to the sage user to 
start the server and left it open. More on this after more formal 
experiment.

>From this brief trial, I conclude that the Sage server must be started in 
an environment where X is accessible *AND* must have some access to X to be 
able to produce png graphs.

A couple more data points : when running "sage -R" from an X-enabled ssh 
connection :
> capabilities()
    jpeg      png     tiff    tcltk      X11     aqua http/ftp  sockets 
    TRUE     TRUE    FALSE     TRUE     TRUE    FALSE     TRUE     TRUE 
  libxml     fifo   cledit    iconv      NLS  profmem    cairo 
    TRUE     TRUE     TRUE     TRUE     TRUE    FALSE    FALSE 

whereas "native R" (as packaged by Dirk Ettelbuettel for Debian unstable) :
> capabilities()
    jpeg      png     tiff    tcltk      X11     aqua http/ftp  sockets 
    TRUE     TRUE     TRUE     TRUE     TRUE    FALSE     TRUE     TRUE 
  libxml     fifo   cledit    iconv      NLS  profmem    cairo 
    TRUE     TRUE     TRUE     TRUE     TRUE     TRUE     TRUE 


When running "sage -R" from a X-disabled ssh connection :
> capabilities()
    jpeg      png     tiff    tcltk      X11     aqua http/ftp  sockets 
   FALSE    FALSE    FALSE     TRUE    FALSE    FALSE     TRUE     TRUE 
  libxml     fifo   cledit    iconv      NLS  profmem    cairo 
    TRUE     TRUE     TRUE     TRUE     TRUE    FALSE    FALSE 

 "native R":
> capabilities()
    jpeg      png     tiff    tcltk      X11     aqua http/ftp  sockets 
    TRUE     TRUE     TRUE     TRUE    FALSE    FALSE     TRUE     TRUE 
  libxml     fifo   cledit    iconv      NLS  profmem    cairo 
    TRUE     TRUE     TRUE     TRUE     TRUE     TRUE     TRUE 

"Native R" keeps png (and jpeg, tiff, tcltk cairo) capabilities when ran 
without X access... The problem might be at least partially on Sage's 
side...

I plan to try to find a workaround for this problem (maybe starting a VNC 
server starting the sage server, but this sounds a bit ridiculous), then 
find relevant tickets (8868, 11249, 12057 seem relevant, beut some of them 
are "fixed, resolved"...) and start digging (but not rigt now...).

I'd like to collect your experiences about this problem : When you have 
experienced the "no PNG capability" problem :

   - had your server had access at start time ? ?
   - had you X access at time of use ?
   - had your server X access at time of use ?


Any turther comments, toughts, ideas (barbs if deserved) are, of course, 
welcome.

Sincerely yours,

                                                                                
    
Emmanuel Charpentier

-- 
You received this message because you are subscribed to the Google Groups 
"sage-support" group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.


Reply via email to