From 6288a5d90de0a5c245cc2456d23de01d30016062 Mon Sep 17 00:00:00 2001 From: Will Landau Date: Mon, 7 Aug 2023 09:39:38 -0400 Subject: [PATCH 1/2] Propose pre-compiled models in R packages --- vignettes/cmdstanr-internals.Rmd | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/vignettes/cmdstanr-internals.Rmd b/vignettes/cmdstanr-internals.Rmd index 164b80085..dc9703071 100644 --- a/vignettes/cmdstanr-internals.Rmd +++ b/vignettes/cmdstanr-internals.Rmd @@ -470,6 +470,22 @@ CmdStanR can of course be used for developing other packages that require compil and running Stan models as well as using new or custom Stan features available through CmdStan. +### Pre-compiled Stan models in R packages + +You may compile a Stan model at runtime (e.g. just before sampling), +or you may compile all the models inside the package file system in advance at installation time. +The latter avoids repeated compilations at runtime. +To pre-compile all the models in a package, +you may create top-level scripts `configure` and `configure.win` +which run `cmdstan_model()` with `compile = TRUE` and save the compiled executables +somewhere inside the `inst/` folder of the package source. +The [`instantiate`](https://wlandau.github.io/instantiate/) package helps follow +this configuration pattern and documents other topics like CRAN submission and +administering CmdStan in centralized R enviroinments. +Kevin Ushey's [`configure`](https://github.com/kevinushey/configure) package helps write +configuration files more generally. + + ### Troubleshooting and debugging When developing or testing new features it might be useful to have more From 8505f1c35950e1e41aff5dd08b1705229408d1a3 Mon Sep 17 00:00:00 2001 From: Will Landau Date: Mon, 7 Aug 2023 09:49:09 -0400 Subject: [PATCH 2/2] Edit pre-compiled model section --- vignettes/cmdstanr-internals.Rmd | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/vignettes/cmdstanr-internals.Rmd b/vignettes/cmdstanr-internals.Rmd index dc9703071..792eac01f 100644 --- a/vignettes/cmdstanr-internals.Rmd +++ b/vignettes/cmdstanr-internals.Rmd @@ -474,16 +474,18 @@ through CmdStan. You may compile a Stan model at runtime (e.g. just before sampling), or you may compile all the models inside the package file system in advance at installation time. -The latter avoids repeated compilations at runtime. +The latter avoids compilations at runtime, which matters in centrally managed R installations +where users should not compile their own software. + To pre-compile all the models in a package, you may create top-level scripts `configure` and `configure.win` which run `cmdstan_model()` with `compile = TRUE` and save the compiled executables somewhere inside the `inst/` folder of the package source. -The [`instantiate`](https://wlandau.github.io/instantiate/) package helps follow -this configuration pattern and documents other topics like CRAN submission and -administering CmdStan in centralized R enviroinments. -Kevin Ushey's [`configure`](https://github.com/kevinushey/configure) package helps write -configuration files more generally. +The [`instantiate`](https://wlandau.github.io/instantiate/) package helps developers +configure packages this way, +and it documents other topics such as submitting to CRAN and administering CmdStan. +Kevin Ushey's [`configure`](https://github.com/kevinushey/configure) package helps +create and manage package configuration files in general. ### Troubleshooting and debugging