I am wondering whether or not it is possible to store cmdstanr compiled model objects in a persistent manner. Currently it looks like the R6 object contains file paths to executables, however, these seem to be stored in tmp folders, and so that would likely not be persistent.
Is there any straightforward way of saving a compiled model object? The use case here is for using cmdstanr for a separate R package with a model that takes a while to compile, and so it would be preferable to compile once and save it.
Ok I think I’ve solved my own problem. cmstanr has a compile check for the executable. So essentially it stores the executable in a persistent fashion so long as the directory is permanent. There’s no need to save the R6 model object as there is no computational overhead to declare it again if compilation of the Stan code isn’t necessary.
Yes, it seems to be working out pretty well. The fact that cmdstanr checks for the executable on its own makes it really easy to integrate into an R package without needing to worry about bundling C libraries.