How to re-load fits saved in cache instead of re-sampling with PyStan

Hello,

I am using PyStan 3.7.0 and httpstan 4.10.1 and Python 3.10.11.
I am running some python scripts on a server that uses a SLURM job scheduling system.

When I run a script using the same Stan model, the program finds the already-compiled model in cache and uses it instead of recompiling it. However, if I run the same fit twice (same model, same data) the program will perform the sampling the first time as well as the second. I was expecting it to just re-load the fit that was saved in cache (I can see the fit saved in the cache folder). I was wondering it I understood something wrong. In case this is the normal behaviour, I was wondering how we can just reload a fit saved in cache in Python.

Thank you very much for your help.

Best
Irene

I partially circumvented this by saving the model and the fit with pickle and pickling them when needed.

There’s not a built-in way to do that. Stan doesn’t have any kind of make/dependency system for not running the model again if you’ve already sampled once.