arvoelke / nengolib

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

Make LinearSystem serializable #123

Open arvoelke opened 7 years ago

arvoelke commented 7 years ago

Due to the (intentionally) omitted super call in LinearSystem, objects don't contain the _paramdict field set by Nengo's FrozenObject base class. Normally this doesn't cause any issues, but it did for @psipeter when using this in conjunction with the multiprocessing module.

A hacky workaround is to manually set sys._paramdict = {} on the object before using it. A better fix is to set it at the class level in NengoLinearFilterMixin alongside where I set seed and default_dt, but investigation is needed to see if we can do all of this properly in a way that is less likely to break down the road (e.g., actually making the super call).

arvoelke commented 7 years ago

This happened because the __setstate__ and __getstate__ defined by FrozenObject for serializing/deserializing the object are no compatible with the object.

arvoelke commented 6 years ago

Also see #109.

arvoelke commented 6 years ago

This is getting complicated. So far this supports nengo versions 2.1 through 2.6. However, parameters have a different interface between these two versions (validate versus coerce). I need to make my own parameter in order to for each instance to become a serializable FrozenObject, but can't readily do so in a way that is compatible across nengo version.

tbekolay commented 6 years ago

Is the goal to be able to serialize something with Nengo 2.1 and deserialize with 2.6? Or serialize/deserialize within the same version? If within the same version, you can use a different parameter implementations depending on the Nengo version.

arvoelke commented 6 years ago

The goal is within the same version. And yep you are right. Half of it is that I'm being lazy and would like the solution to require as little maintenance/work as possible. No worries.