lcls-psana / psocake

3 stars 12 forks source link

pyqtgraph related exceptions - traceback not helping #28

Open fredericpoitevin opened 3 years ago

fredericpoitevin commented 3 years ago

On 1/4/21, we started noticing that psocake on ana-4.0.5 was throwing multiple exceptions; they are ignored and do not prevent some of the usage of psocake. They however mess with the display of histograms and small data.

Two TypeErrors messages appear repeatedly in the Traceback:

In addition, when psocake is run in verbose mode (-v 1), an additional error shows up:

It seems that all errors are somewhat related to pyqtgraph, yet the traceback does not really tell us which call triggered what error, which would help hone in on a particular function to debug.

To that effect, we tried the idea explained in this blog post found by Chris: https://fman.io/blog/pyqt-excepthook/ The script was slightly edited to make it look like what is done in psocake: fman.py.zip

Interestingly, running this script in ana-4.0.5 still results in Error3:

(ana-4.0.5) [fpoitevi@psanagpu108 debug]$ python fman.py
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
[… the GUI displays OK…]

Adding the idea of that script to gui.py in psocake unfortunately did not result in a more informative traceback...

valmar commented 3 years ago

Does the version that come with the environment work? (Trying to figure out if the error originates from psocake or pyqtgraph)

fredericpoitevin commented 3 years ago

Unfortunately it throws the same errors

valmar commented 3 years ago

Ok, it must be the library then. That's actually good news. Someone was posting in an email a minimal snippet that could reproduce the error. Do you remember where we can find it please?

fredericpoitevin commented 3 years ago

If you mean for Error 3, it must be this:

(ana-4.0.5) [fpoitevi@psanagpu108 psocake]$ ipython
In [1]: import pyqtgraph as pg
In [2]: pg.plot([1.,2.], [1.,2.], pen=None, symbol='o')
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
Out[2]: <pyqtgraph.graphicsWindows.PlotWindow at 0x7f053dbc6348>
In [3]: pg.plot([1.,2.], [1.,2.], pen=(1,3), symbol='o')
Out[3]: <pyqtgraph.graphicsWindows.PlotWindow at 0x7f053cea3b00>
In [4]: pg.plot([1.,2.], [1.,int(2.)], pen=(1,3), symbol='o')
libGL error: unable to load driver: swrast_dri.so
libGL error: failed to load driver: swrast
Out[4]: <pyqtgraph.graphicsWindows.PlotWindow at 0x7ff97bb19218>
In [5]: quit()
valmar commented 3 years ago

I think that error just means that hardware acceleration could not be enabled

chuckie82 commented 3 years ago

Here's the actual error (below). I've started porting psocake to python3 today, so let me see what I can do. We won't need to worry about this if I get it done.

@fredericpoitevin: if you want to get rid of libGL errors, you will need to do something like: yum install mesa-libGLU.i686 mesa-libGLU.x86_64

(ana-4.0.9) [yoon82@psanagpu103 psocake]$ python Python 2.7.15 | packaged by conda-forge | (default, Mar 5 2020, 14:56:06) [GCC 7.3.0] on linux2 Type "help", "copyright", "credits" or "license" for more information.

import pyqtgraph as pg pg.plot([1.,2.], [1.,2.], pen=None, symbol='o') libGL error: unable to load driver: swrast_dri.so libGL error: failed to load driver: swrast <pyqtgraph.graphicsWindows.PlotWindow object at 0x7fd76c8a79d0> [20:01:14] Ignored exception:

|==============================>>
|  Traceback (most recent call last):
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/widgets/GraphicsView.py", line 161, in paintEvent
|      return QtGui.QGraphicsView.paintEvent(self, ev)
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/debug.py", line 93, in w
|      printExc('Ignored exception:')
|    --- exception caught here ---
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/debug.py", line 91, in w
|      func(*args, **kwds)
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 1033, in paint
|      viewMask = self._maskAt(self.getViewBox().viewRect())
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 1157, in _maskAt
|      w *= px
|  TypeError: Cannot cast ufunc multiply output from dtype('float64') to dtype('int64') with casting rule 'same_kind'
|==============================<<

[20:01:14] Ignored exception:

|==============================>>
|  Traceback (most recent call last):
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/widgets/GraphicsView.py", line 161, in paintEvent
|      return QtGui.QGraphicsView.paintEvent(self, ev)
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/debug.py", line 93, in w
|      printExc('Ignored exception:')
|    --- exception caught here ---
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/debug.py", line 91, in w
|      func(*args, **kwds)
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 1033, in paint
|      viewMask = self._maskAt(self.getViewBox().viewRect())
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 1157, in _maskAt
|      w *= px
|  TypeError: Cannot cast ufunc multiply output from dtype('float64') to dtype('int64') with casting rule 'same_kind'
|==============================<<

[20:01:14] Ignored exception:

|==============================>>
|  Traceback (most recent call last):
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/widgets/GraphicsView.py", line 161, in paintEvent
|      return QtGui.QGraphicsView.paintEvent(self, ev)
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/debug.py", line 93, in w
|      printExc('Ignored exception:')
|    --- exception caught here ---
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/debug.py", line 91, in w
|      func(*args, **kwds)
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 1033, in paint
|      viewMask = self._maskAt(self.getViewBox().viewRect())
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 1157, in _maskAt
|      w *= px
|  TypeError: Cannot cast ufunc multiply output from dtype('float64') to dtype('int64') with casting rule 'same_kind'
|==============================<<

[20:01:14] Ignored exception:

|==============================>>
|  Traceback (most recent call last):
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/widgets/GraphicsView.py", line 161, in paintEvent
|      return QtGui.QGraphicsView.paintEvent(self, ev)
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/debug.py", line 93, in w
|      printExc('Ignored exception:')
|    --- exception caught here ---
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/debug.py", line 91, in w
|      func(*args, **kwds)
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 1033, in paint
|      viewMask = self._maskAt(self.getViewBox().viewRect())
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 1157, in _maskAt
|      w *= px
|  TypeError: Cannot cast ufunc multiply output from dtype('float64') to dtype('int64') with casting rule 'same_kind'
|==============================<<

[20:01:14] Ignored exception:

|==============================>>
|  Traceback (most recent call last):
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/widgets/GraphicsView.py", line 161, in paintEvent
|      return QtGui.QGraphicsView.paintEvent(self, ev)
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/debug.py", line 93, in w
|      printExc('Ignored exception:')
|    --- exception caught here ---
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/debug.py", line 91, in w
|      func(*args, **kwds)
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 1033, in paint
|      viewMask = self._maskAt(self.getViewBox().viewRect())
|    File "/cds/sw/ds/ana/conda1/inst/envs/ana-4.0.9/lib/python2.7/site-packages/pyqtgraph/graphicsItems/ScatterPlotItem.py", line 1157, in _maskAt
|      w *= px
|  TypeError: Cannot cast ufunc multiply output from dtype('float64') to dtype('int64') with casting rule 'same_kind'
|==============================<<
fredericpoitevin commented 3 years ago

Ah yes I tried to extract the relevant part from the whole traceback, but the actual error actually keeps throwing exceptions as we use the GUI. OK will be in standby

detlevn commented 2 years ago

After replacing w *= px and h *= py with w = w * px resp. h = h * py all symbol related properties of ScatterPlotItem will work