stan-dev / httpstan

HTTP interface to Stan, a package for Bayesian inference.
ISC License
40 stars 15 forks source link

module 'httpstan' has no attribute 'cache' #640

Closed irelamb closed 1 year ago

irelamb commented 1 year ago

Hello,

I am using Python 3.10.11, httpstan 4.10.0 and PyStan 3.7.0.

When trying to use httpstan.cache.load_fit to load a model saved in cache Spyder quitted unexpectedly.

When I opened again Spyder and tried the same operation I got the following error message:

Traceback (most recent call last):

  Cell In[5], line 1
    httpstan.cache.load_fit(path)

AttributeError: module 'httpstan' has no attribute 'cache'

So I can import httpstan without problems but it doesn't seem to "recognise" anymore the submodule 'cache'.

Do you have any idea why it happened, or how to fix it?

Best, Irene

ahartikainen commented 1 year ago

Do you have a folder or file named httpstan / httpstan.py

irelamb commented 1 year ago

I don't, at least not to my knowledge. But I have just restarted my computer and now I can import httpstan.cache. The question is whether Spyder will crash again if I try to load the fit a second time...

irelamb commented 1 year ago

It crashed again after fit = httpstan.cache.load_fit(path) fit but when I opened again Spyder I was able to import httpstan.cache and reload the fit (for a third time). What kind of object fit is? it is not pyStan fit object, right?

irelamb commented 1 year ago

So, maybe I am not doing what I would like to do in the right way... Maybe I should just save my pyStan fit object and re-load it when need, instead of using the cached fits.

ahartikainen commented 1 year ago

Hi, I think that sounds reasonable. There is probably some import order thing that causes the issue (coupled with spyder?).

I personally transform my fit objects to arviz.InferenceData and save it to a netcdf format.

Then if there is a need for other methods (logprob etc) I recompile the model+data if needed.