Variable KeyError when loading from saved network

Description of problem

I am loading a network from a saved file. Each time I load it, I get a KeyError for the key ‘delay’. I’m not sure why or how I can fix this. Before (about a year ago) it used to work, but now it doesn’t. I suspect it has to do with a newer Brian code that removed, added, or changed key names.

Is there a way I can manually add or remove the key (whichever one is causing the issue) in my old network save so it works?

The trace is as follows:

Traceback (most recent call last):
File “/home/david/anaconda3/envs/myEnv/lib/python2.7/multiprocessing/”, line 267, in _bootstrap
File “/home/david/anaconda3/envs/myEnv/lib/python2.7/multiprocessing/”, line 114, in run
self._target(*self._args, **self._kwargs)
File “/home/david//code/brian/stdp_w_stp_general/”, line 760, in my_sim
net.restore(filename = restore_state_filename)
File “/home/david/anaconda3/envs/myEnv/lib/python2.7/site-packages/brian2/core/”, line 278, in device_override_decorated_function
return func(*args, **kwds)
File “/home/david/anaconda3/envs/myEnv/lib/python2.7/site-packages/brian2/core/”, line 578, in restore
File “/home/david/anaconda3/envs/myEnv/lib/python2.7/site-packages/brian2/groups/”, line 594, in _restore_from_full_state
var = self.variables[var_name]
File “/home/david/anaconda3/envs/myEnv/lib/python2.7/site-packages/brian2/core/”, line 1412, in getitem
return self._variables[item]
KeyError: ‘delay’

Unfortunately store/restore is not guaranteed to work between different versions of Brian, so this is probably the problem you’re running up against. However, it’s just a pickled dictionary file, so it should be easy to manipulate with pickle. Try loading the old one as a pickle file (take a look at the code here: brian2/ at master · brian-team/brian2 · GitHub) and see what the keys are. Now save a similar network from the latest version of Brian and see what the new key names are, and I guess it should probably be easy to translate.

Let us know if there’s anything further we can help with or if that solves the problem.