leginon-org / leginon-redmine-archive

1 stars 0 forks source link

makeDEAlignedSum.py requires display setting to produce summary image #4188

Open leginonbot opened 7 months ago

leginonbot commented 7 months ago

Author Name: Anchi Cheng (@anchi2c) Original Redmine Issue: 4188, https://emg.nysbc.org/redmine/issues/4188 Original Date: 2016-05-19 Original Assignee: Scott Stagg


Our alignment clussterm runs headless.

Running from command line without ssh -X gives

Traceback (most recent call last):
  File "/opt/myamisnap/bin/makeDEAlignedSum.py", line 3, in <module>
    from appionlib import makeDEAlignedSumLib
  File "/opt/myamisnap/lib/appionlib/makeDEAlignedSumLib.py", line 10, in <module>
    from matplotlib import pyplot
  File "/usr/lib64/python2.6/site-packages/matplotlib/pyplot.py", line 78, in <module>
    new_figure_manager, draw_if_interactive, show = pylab_setup()
  File "/usr/lib64/python2.6/site-packages/matplotlib/backends/__init__.py", line 25, in pylab_setup
    globals(),locals(),[backend_name])
  File "/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_gtkagg.py", line 10, in <module>
    from matplotlib.backends.backend_gtk import gtk, FigureManagerGTK, FigureCanvasGTK,\
  File "/usr/lib64/python2.6/site-packages/matplotlib/backends/backend_gtk.py", line 8, in <module>
    import gtk; gdk = gtk.gdk
  File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 64, in <module>
    _init()
  File "/usr/lib64/python2.6/site-packages/gtk-2.0/gtk/__init__.py", line 52, in _init
    _gtk.init_check()
RuntimeError: could not open display
leginonbot commented 7 months ago

Original Redmine Comment Author Name: Scott Stagg (Scott Stagg) Original Date: 2016-05-19T12:20:21Z


Ugh. Well, I guess matplotlib isn't going to work. I'm on vacation for a week, so Anchi can you just make the skip_summary_image option True all the time for now until I can figure out a better solution?

leginonbot commented 7 months ago

Original Redmine Comment Author Name: Anchi Cheng (@anchi2c) Original Date: 2016-05-19T12:21:47Z


r19778 is an workaround to avoid importing pyplot unless the image is produced and only make summary image when requested until it is properly fixed.

Enjoy the vacation

leginonbot commented 7 months ago

Original Redmine Comment Author Name: Anchi Cheng (@anchi2c) Original Date: 2016-05-19T12:46:44Z


apCtf.ctfdisplay would have the same problem. Will need a solution.

leginonbot commented 7 months ago

Original Redmine Comment Author Name: Anchi Cheng (@anchi2c) Original Date: 2016-05-19T17:31:18Z


Comment from Bill Rice

Looks like replace gtk_init with __gtk_init_check() should solve the problem:

from https://developer.gnome.org/gtk3/stable/gtk3-General.html#gtk-init-check
gtk_init_check (int argc,
char **argv);
This function does the same work as gtk_init() with only a single change: It does not terminate the program if the windowing system can’t be initialized. Instead it returns FALSE on failure.

This way the application can fall back to some other means of communication with the user - for example a curses or command line interface.

The main issue is that appionPBS.py runs on head node. so far the terminal never close, but Bill and future users will be doing remote log in and -X option does not allow nohup since it will lose the terminal. apCtf.ctfdisplay does not have this issue because it would be executed through the submitted job.

leginonbot commented 7 months ago

Original Redmine Comment Author Name: Neil Voss (@vosslab) Original Date: 2016-05-19T17:49:28Z


The only display ctfdisplay needs is matplotlib, I use the line:

from matplotlib import use
use('Agg')
from matplotlib import pyplot

to avoid the gtk requirement.