arvoelke / nengolib

Nengo library of additional extensions
Other
29 stars 6 forks source link

nengolib.patch throws gui error #99

Closed studywolf closed 7 years ago

studywolf commented 7 years ago

I was playing around with the nengolib and I add the import nenglib; nengolib.patch() line in a file opened in nengo_gui (most recent branch), and this was thrown in the console:

ERROR:nengo_gui.guibackend:Error during websocket communication. Traceback (most recent call last): File "/home/wolf/Dropbox/code/nengo_gui/nengo_gui/guibackend.py", line 230, in ws_default component.update_client(self.ws) File "/home/wolf/Dropbox/code/nengo_gui/nengo_gui/components/netgraph.py", line 399, in update_client self.expand_network(network, client) File "/home/wolf/Dropbox/code/nengo_gui/nengo_gui/components/netgraph.py", line 507, in expand_network self.create_object(client, net, obj_type='net', parent=parent) File "/home/wolf/Dropbox/code/nengo_gui/nengo_gui/components/netgraph.py", line 523, in create_object pos = self.page.config[obj].pos File "/home/wolf/Dropbox/code/nengo/nengo/config.py", line 362, in getitem "configures('%(name)s') first." % {'name': type(key).name}) nengo.exceptions.ConfigError: Type 'EnsembleArray' is not set up for configuration. Call configures('EnsembleArray') first.

arvoelke commented 7 years ago

Cannot reproduce using newest versions of nengo and nengo_gui.

However, I get a separate issue related to some peculiarities in nengo_gui. I found that when running the same network multiple times, you need to add nengolib.unpatch() to the very end of your file.

Alternatively, you could try replacing nengo.Network with nengolib.Network. This has all the same advantages of the monkey-patch, except no automatic biases.

arvoelke commented 7 years ago

Note I've pushed a couple compatibility fixes with the newest Nengo. Let me know if this is still an issue.

studywolf commented 7 years ago

hmm, looks like i only get it if i use the ensemble array, and i get it if i do nengolib.Network also

import nengo

import nengolib
nengolib.patch()

model = nengo.Network()
with model:
    ea = nengo.networks.EnsembleArray(100, 3) 
arvoelke commented 7 years ago

working

Working for me on most recent branches of nengo, nengo_gui, and nengolib. Can you print out those versions?

studywolf commented 7 years ago
In [2]: nengo.__version__
Out[2]: '2.4.1.dev0'
In [4]: nengo_gui.__version__
Out[4]: '0.3.1.dev0'
In [6]: nengolib.__version__
Out[6]: '0.1.0-dev'
arvoelke commented 7 years ago

Are you printing this out in jupyter? The versions that appear there aren't necessarily the same as those picked up by nengo_gui, especially if you've ever done a pip install at some point. Add the print statements to nengo_gui as in my screenshot. Otherwise this is really strange.

studywolf commented 7 years ago

hmm, that was ipython. i printed from a nengo script and they're the same, and they're all installed via repo cloning, this is my pip freeze:

-e git+https://github.com/nengo/nengo@0d60f77f1551b9193d5ee13da072b45dd8fc4852#egg=nengo
-e git+https://github.com/nengo/nengo_gui.git@d81ca324a826b106f3d9a78d46596a665fb9dd5e#egg=nengo_gui
-e git+https://github.com/arvoelke/nengolib.git@ddb7a9bb8b1cf7d0c1a04f19828916c64e675e07#egg=nengolib

on Ubuntu 14.04.5, Google Chrome 57.0.2987.110

studywolf commented 7 years ago

copied from nengo gui console for this script:

import nengo; print(nengo.__version__)
import nengo_gui; print(nengo_gui.__version__)
import nengolib; print(nengolib.__version__)

model = nengo.Network()
with model:
    stim = nengo.Node([0])
    a = nengo.Ensemble(n_neurons=50, dimensions=1)
    nengo.Connection(stim, a)

2.4.1.dev0 0.3.1.dev0 0.1.0-dev

arvoelke commented 7 years ago

Weeeeeeird. I even tried doing a fresh install on a new environment and I could still not reproduce with the EnsembleArray. Could it have anything to do with changes to your nengorc file? What version of Python are you using? Is there an easy way for you to try Python 2.7 if you aren't already?

arvoelke commented 7 years ago

Oh.... so I just noticed I'm getting this error in the console (the command line, not the browser; sorry didn't realize you said that earlier!). However... it happens whether or not I'm using nengolib, and doesn't seem to affect the functionality of the network...

arvoelke commented 7 years ago

There's something very odd about this error. I can't get it to consistently reproduce in either case. If you can find a consistent way to reproduce it, it should probably be filed as a nengo_gui bug (although I'm not sure if it even matters).

studywolf commented 7 years ago

hm, so for me this error throws in the not the browser command line every time i refresh it / it tries to load, i tried it out in the 2.7 python same thing... any thoughts on what it should be filed as under nengo_gui or any details i should add?

tbekolay commented 7 years ago

I believe that this occurs because EnsembleArray inherits from nengo.Network, which happens at module import time. If nengolib.patch happens before nengo_gui makes its config (which happens here) then it will set up nengolib.Network for configuration rather than nengo.Network. EnsembleArray isn't a subclass of nengolib.Network so it can't be configured.

arvoelke commented 7 years ago

Hmm.. but if that's the case then @studywolf shouldn't have seen the error when using with nengolib.Network() instead of applying the patch. Unless he forgot to restart the GUI when he tried that? That may be the case since your explanation sounds right. But I'm trying to investigate this further and can only reproduce on one of my machines for some reason.

I'm thinking patching is not the recommended approach, and Travis should try using nengolib.Network() again instead (but make sure to restart the server process, and don't let it try to patch at any point).

studywolf commented 7 years ago

I will try these things and report back!

On Mon, May 8, 2017 at 5:00 PM, Aaron Russell Voelker < notifications@github.com> wrote:

Hmm.. but if that's the case then Travis shouldn't have seen the error when using with nengolib.Network() instead of applying the patch. Unless he forgot to restart the GUI when he tried that? That may be the case since your explanation sounds right. But I'm trying to investigate this further and can only reproduce on one of my machines for some reason.

I'm thinking patching is not the recommended approach, and Travis should try using nengolib.Network() again instead (but make sure to restart the server process, and don't let it try to patch at any point).

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/arvoelke/nengolib/issues/99#issuecomment-299989439, or mute the thread https://github.com/notifications/unsubscribe-auth/ACW8iaV2SI1vxiO-OgIAZmRRWq7Yb5KOks5r34JrgaJpZM4NSdK2 .

arvoelke commented 7 years ago

Any update?

studywolf commented 7 years ago

aight, no errors are thrown in browser or console when i use nengolib.Network() and no patch!

arvoelke commented 7 years ago

Cool thanks for helping test this out. I've moved the issue to #110.