dwave-system icon indicating copy to clipboard operation
dwave-system copied to clipboard

Make DWaveSampler picklable

Open pgawron opened this issue 6 years ago • 1 comments

DWaveSampler is not picklable. It should be in order to integrate for example with sklearn.

In [1]: from dwave.system.samplers import DWaveSampler

In [2]: import pickle

In [3]: annealer = DWaveSampler()

In [4]: pickle.dumps(annealer)
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-4-bef1022bace0> in <module>()
----> 1 pickle.dumps(annealer)

TypeError: can't pickle _thread.lock objects

pgawron avatar Jul 17 '18 15:07 pgawron

This basically translates to making dwave.cloud.Client picklable (in dwave-cloud-client package). Currently it isn't by default, because thread pools and mutexes would have to be recreated manually.

Can you show here the exact example that requires the DWaveSampler to be picklable? Thanks.

randomir avatar Jul 18 '18 18:07 randomir