ram error when saving model even after I passed db='pickle'

111 views
Skip to first unread message

Mohamed Sherif

unread,
Aug 24, 2021, 10:50:35 AM8/24/21
to hddm-users
Hi,

I am getting an error when trying to save the model from the HDDM tutorial running on my Ubuntu 20.04 machine.

The following are the package versions I am using on:
python 3.6
hddm 0.8.0
kabuki 0.6.3


The following is the code I am trying:
m = hddm.HDDM(data) 
m.find_starting_values()
m.sample(2000, burn=20, dbname='traces.db', db='pickle') # took 156.6 seconds to run

m.save('~/data/hddm/2021aug24_modelSample_2000_burn20')
The error I am getting is: 
ValueError: db is 'ram'. Saving a model requires a database on disk.


Trying to debug from an ipython shell:
In [16]: %debug
> /home/mohdsh/anaconda3/envs/pyHDDM/lib/python3.6/site-packages/kabuki/hierarchical.py(373)__getstate__()
    371             dbname = d['mc'].db.__name__
    372             if (dbname == 'ram'):
--> 373                     raise ValueError("db is 'ram'. Saving a model requires a database on disk.")
    374             elif (dbname == 'pickle'):
    375                     d['dbname'] = d['mc'].db.filename

ipdb> eval("d['mc'].db.__name__")
'ram'

Seems that the db is still 'ram' despite that I have passed the argument db='pickle'.

Any help is appreciated.

Thanks a lot.

Mohamed.

Alexander Fengler

unread,
Aug 27, 2021, 1:09:23 PM8/27/21
to hddm-users
Hey Mohammed,
 
are the lines of code you show in exactly this sequence with nothing in-between or might there be some code in-between that redefines 'm' ?
This can happen for example if you run sampling once without the db and dbname arguments and then try to continue sampling supplying these arguments. 
It will be set only once (the first time) in this case.
If the code is as shown this seems suspicious indeed.

Best,
Alex

Mohamed Sherif

unread,
Aug 30, 2021, 1:25:01 PM8/30/21
to hddm-users
Hey Alex,

Thank you for pointing this out. The case was as you described. When I tried on a new instance of the model, it worked.

Thanks again.

Mohamed.

Reply all
Reply to author
Forward
0 new messages