CDAT / vcs

Visualization Control System
19 stars 13 forks source link

When running plot() function in a Jupyter Notebook, a greyed out window appears. #383

Open downiec opened 5 years ago

downiec commented 5 years ago

If vcs.init() is run in a Jupyter notebook, it should automatically detect and have bg=true to avoid the greyed out window when sidecar is used in a Jupyter Notebook.

scottwittenburg commented 5 years ago

Do we need to detect that we're running in a Jupyter notebook somehow, or can the default just be bg=True?

doutriaux1 commented 5 years ago

no default needs to be bg=False as now. Look for the bit of code I added to detect notebook, for sidecar

doutriaux1 commented 5 years ago

Actually the code should already be in place (I thought I did code this): https://github.com/CDAT/vcs/blob/master/vcs/Canvas.py#L931-L935

I wo der why it's not picking it up

doutriaux1 commented 5 years ago

@scottwittenburg is it related to the new vtk-cdat ?

doutriaux1 commented 5 years ago

I remember seeing a window even with mesalib, maybe it's a similar issue?

scottwittenburg commented 5 years ago

I think I'll need some instructions on how to reproduce this if I'm to be of any help.

doutriaux1 commented 5 years ago

according to @downiec when in a jupyternotebook with the non-mesa env (py3) x=vcs.init();x.plot([1,2,3]) make a window appear

doutriaux1 commented 5 years ago

we do not want the window appear, hence bg=True

downiec commented 5 years ago

Could it be because my conda environment? I just remembered I'm using the old conda environment because that's the one that's currently working. I'll let you know

scottwittenburg commented 5 years ago

Sounds good, thanks @downiec.

downiec commented 5 years ago

What vcs version do I need? I tried pulling from master and then running python setup.py install, but now I'm getting an error and it won't plot anything. AttributeError: module 'vtkmodules.all' has no attribute 'vtkRenderingOpenGLPython'

I emailed a screenshot.

downiec commented 5 years ago

I noticed if I run this command: canvas.plot(clt,"default","default",bg=True) Where I set bg=True, then it works correctly without the error.

downiec commented 5 years ago

Strange... if I run the command, initially it will have the error, but if I keep running a few times (without changing the code or parameters), eventually it works correctly. Is it because something needs to be loaded in the back end?

downiec commented 5 years ago

One last comment. In the JupyterLab Notebook, first time I run the cell, I get: AttributeError: module 'vtkmodules.all' has no attribute 'vtkRenderingOpenGLPython' Second time I run the cell (same exact code, I just run the cell again): ZeroDivisionError: float division by zero Third time I run it, it plots without an error.

scottwittenburg commented 5 years ago

Sorry @downiec, I saw your email about this before I got here, so I responded there. Basically, the AttributeError: module 'vtkmodules.all' has no attribute 'vtkRenderingOpenGLPython' is the one that matters. Based on the stacktrace in your email, it's clear that's an old version of VTKPlots.py (from before we merged the Context2D work). Since you said you checked out vcs master and installed it using python setup.py install, I wonder if you're hitting something I encounter from time to time now that vcs is egg based. Have a look and see if there are multiple vcs egg files in your environment. They would be located somewhere like:

${CONDA_HOME}/envs/${JUPYTER_VCDAT_ENV}/lib/python3.6/site-packages/

If you have more than one for vcs, you can move them out of the way (or just delete them all), and then run python setup.py install again from the vcs repository directory.

downiec commented 5 years ago

@scottwittenburg Thanks for the response, I went ahead and removed the vcs egg files like you said, and then I ran python setup.py install. That all fixed the error, thanks! Unfortunately it doesn't resolve the greyed out window issue. Basically, if I run the following in a Jupyter Lab Notebook: canvas.plot(clt,"default","default") The plot is made, no problem. But then there's also a separate greyed out window that pops up and it can't be closed or minimized etc, it's just there. I tried running: canvas.plot(clt,"default","default",bg=True) And the issue still persists, with a greyed out window popping up. The window only goes away when I restart the kernel.

scottwittenburg commented 5 years ago

@downiec Can you run the following in the same environment you just cleaned up, and see if the window pops up?

import vcs
canvas = vcs.init(bg=1)
canvas.plot([1, 2, 3, 4, 5])
canvas.png("simple.png")

Let me know what happens, thanks.

downiec commented 5 years ago

I didn't see anything get plotted, but the grey window pops whether I run the code in a JupyterLab notebook, or I run it from Python in the console. Also a png named 'simple.png' was created.

Also another thing I notice is the grey window usually pops up after the data has been plotted. Sometimes almost a full second after the graph has already been plotted in the sidecar.