Stantargets: a new workflow automation package for cmdstanr projects

I am excited to announce a new package on GitHub called stantargets, an extension to targets for cmdstanr-powered projects. stantargets makes it super easy to set up useful targets-powered pipelines to manage the workflow and skip expensive computation when the results are already up to date. It can access all the major methodologies of cmdstanr (MCMC, variational Bayes, optimization), and it supports both single-fit workflows and multi-rep simulation studies. These vignettes have more information.

6 Likes

This is really great, thanks for creating and sharing this!

1 Like

Very cool. Is the check for an outdated executable based purely on the stanfile getting tagged as out-of-date, which in turn is presumably based on file modification time? I’ve been working on a PR for cmdstanr that uses the stanc3 autoformatter to only re-compile when there are true functional changes (i.e. not whitespace nor comment changes), but I wonder if that whole endeavour is better handled outside of cmdstanr through stantargets…

2 Likes

Oh, and more out of curiosity bc I know you have good reasons for things: why the use of concatenated lines in the vignettes to express the models instead of a single string?

2 Likes

Is the check for an outdated executable based purely on the stanfile getting tagged as out-of-date, which in turn is presumably based on file modification time?

For the most part, stantargets relies completely on cmdstanr::cmstan_model() to avoid unnecessary recompilation of Stan model files. But you can include tar_stan_compile() in the pipeline for extra assurance that the model is already compiled before any downstream targets. Related: in functions like tar_stan_mcmc_rep_summary(), you can set compile = "copy" for distributed computing scenarios where the remote nodes do not have access to the file system with the Stan model file.

Oh, and more out of curiosity bc I know you have good reasons for things: why the use of concatenated lines in the vignettes to express the models instead of a single string?

There actually is not a good reason for that one! I should probably make each model a single string. Happy to accept PRs for these small things.

2 Likes