nengo / nengo-gui

Nengo interactive visualizer
Other
99 stars 38 forks source link

Nengo GUI inside Jupyter with a .cfg breaks on re-execution #814

Open tcstewar opened 8 years ago

tcstewar commented 8 years ago

If I embed Nengo GUI inside a Jupyter notebook, it runs fine the first time, but if I re-execute the block it fails. If I then re-re-execute the block, it works again.

Here's an example:

import nengo

model = nengo.Network()
with model:
    stim = nengo.Node(0)
    a = nengo.Ensemble(100, 1)
    nengo.Connection(stim, a)    

import nengo_gui.ipython
nengo_gui.ipython.IPythonViz(model, 'a.cfg')

The first time, this works, but on re-execution, I get this error:

---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-6-f8e4763e7672> in <module>()
      8 
      9 import nengo_gui.ipython
---> 10 nengo_gui.ipython.IPythonViz(model, 'a.cfg')

c:\users\terry\documents\github\nengo_gui\nengo_gui\ipython.pyc in __init__(self, model, cfg, height)
     38             cfg = get_ipython().mktempfile()
     39 
---> 40         self._server_thread, server = self.start_server(cfg, model)
     41         self.port = server.server.server_port
     42 

c:\users\terry\documents\github\nengo_gui\nengo_gui\ipython.pyc in start_server(cls, cfg, model)
     60                 "Reusing config. Only the most recent visualization will "
     61                 "update the config."))
---> 62             for page in server.pages:
     63                 page.save_config(force=True)
     64                 page.filename_cfg = get_ipython().mktempfile()

AttributeError: 'BaseGUI' object has no attribute 'pages'

This does not happen if I do this as the last line:

nengo_gui.ipython.IPythonViz(model)
jgosmann commented 8 years ago

Yeah, I came across the same thing and just ignored it for now because re-execution works as a workaround. But thank you for opening the issue, because at some point we should fix this.

studywolf commented 7 years ago

running into this too, doesn't look great on notebooks sent out to others