Exporting models into pickle

Can someone please tell me how I may export models into pickle files ?

I tried the below approach but got error:
from deeppavlov import build_model, configs

model = build_model(configs.squad.squad, download=False)
from sklearn.externals import joblib
joblib.dump(model,‘pavlov.pkl’)
Traceback (most recent call last):
File “”, line 1, in
File “/usr/local/lib/python3.6/dist-packages/joblib/numpy_pickle.py”, line 505, in dump
NumpyPickler(f, protocol=protocol).dump(value)
File “/usr/lib/python3.6/pickle.py”, line 409, in dump
self.save(obj)
File “/usr/local/lib/python3.6/dist-packages/joblib/numpy_pickle.py”, line 295, in save
return Pickler.save(self, obj)
File “/usr/lib/python3.6/pickle.py”, line 521, in save
self.save_reduce(obj=obj, *rv)
File “/usr/lib/python3.6/pickle.py”, line 634, in save_reduce
save(state)
File “/usr/local/lib/python3.6/dist-packages/joblib/numpy_pickle.py”, line 295, in save
return Pickler.save(self, obj)
File “/usr/lib/python3.6/pickle.py”, line 476, in save
f(self, obj) # Call unbound method with explicit self
File “/usr/lib/python3.6/pickle.py”, line 821, in save_dict
self._batch_setitems(obj.items())
File “/usr/lib/python3.6/pickle.py”, line 847, in _batch_setitems
save(v)
File “/usr/local/lib/python3.6/dist-packages/joblib/numpy_pickle.py”, line 295, in save
return Pickler.save(self, obj)
File “/usr/lib/python3.6/pickle.py”, line 476, in save
f(self, obj) # Call unbound method with explicit self
File “/usr/lib/python3.6/pickle.py”, line 781, in save_list
self._batch_appends(obj)
File “/usr/lib/python3.6/pickle.py”, line 805, in _batch_appends
save(x)
File “/usr/local/lib/python3.6/dist-packages/joblib/numpy_pickle.py”, line 295, in save
return Pickler.save(self, obj)
File “/usr/lib/python3.6/pickle.py”, line 476, in save
f(self, obj) # Call unbound method with explicit self
File “/usr/lib/python3.6/pickle.py”, line 736, in save_tuple
save(element)
File “/usr/local/lib/python3.6/dist-packages/joblib/numpy_pickle.py”, line 295, in save
return Pickler.save(self, obj)
File “/usr/lib/python3.6/pickle.py”, line 521, in save
self.save_reduce(obj=obj, *rv)
File “/usr/lib/python3.6/pickle.py”, line 634, in save_reduce
save(state)
File “/usr/local/lib/python3.6/dist-packages/joblib/numpy_pickle.py”, line 295, in save
return Pickler.save(self, obj)
File “/usr/lib/python3.6/pickle.py”, line 476, in save
f(self, obj) # Call unbound method with explicit self
File “/usr/lib/python3.6/pickle.py”, line 821, in save_dict
self._batch_setitems(obj.items())
File “/usr/lib/python3.6/pickle.py”, line 847, in _batch_setitems
save(v)
File “/usr/local/lib/python3.6/dist-packages/joblib/numpy_pickle.py”, line 295, in save
return Pickler.save(self, obj)
File “/usr/lib/python3.6/pickle.py”, line 521, in save
self.save_reduce(obj=obj, *rv)
File “/usr/lib/python3.6/pickle.py”, line 634, in save_reduce
save(state)
File “/usr/local/lib/python3.6/dist-packages/joblib/numpy_pickle.py”, line 295, in save
return Pickler.save(self, obj)
File “/usr/lib/python3.6/pickle.py”, line 476, in save
f(self, obj) # Call unbound method with explicit self
File “/usr/lib/python3.6/pickle.py”, line 821, in save_dict
self._batch_setitems(obj.items())
File “/usr/lib/python3.6/pickle.py”, line 847, in _batch_setitems
save(v)
File “/usr/local/lib/python3.6/dist-packages/joblib/numpy_pickle.py”, line 295, in save
return Pickler.save(self, obj)
File “/usr/lib/python3.6/pickle.py”, line 496, in save
rv = reduce(self.proto)
TypeError: can’t pickle _thread.RLock objects

Thank you in a advance.

Hi @Bibhuti93,

DeepPavlov pipelines are composed of different models and not every one of them supports pickling.