Hello, I am currently using cmdstanpy to fit a model against a bunch of data sequentially. In particular, I use a pandas .apply() method.
Inside the cmdstanpy function, I have the usual
import cmdstanpy
cmdstanpy.install_cmdstan()
from cmdstanpy import CmdStanModel
and cmdstan is installed if it isn’t installed already.
My question is this: how can I determine if cmdstan is installed without calling install_cmdstan() (I am hitting the server everytime I make the install_cmdstan() call).
the function cmdstan_path() willl do this for you.
here’s the fine print:
CmdStanPy uses environment variable CMDSTAN to keep track of CmdStan install dir.
the default location is in hidden directory .cmdstan in user’s $HOME directory
cmdstan_path logic:
a. check if environment variable CMDSTAN has been set, if set, validate, report current value
b. look for hidden directory .cmdstan, find latest installed version, validate path, set environment variable CMDSTAN accordingly
to use something other than the latest CmdStan release - i.e., a local install built from GitHub sources - than the function set_cmdstan_path will validate and register this location accordingly.
as you say, it’s just a matter of putting the call to cmdstan_path in a tryexcept block. and while it would be only few lines of code to write the is_installed function, by not adding this to the API, the package remains simpler - easier to learn, maintain, and test.