Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update rbmi cache documentation #468

Merged
merged 1 commit into from
Dec 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions R/utilities.R
Original file line number Diff line number Diff line change
Expand Up @@ -574,12 +574,12 @@ get_stan_model <- function() {
cache_dir <- getOption("rbmi.cache_dir")
dir.create(cache_dir, showWarnings = FALSE, recursive = TRUE)
model_file <- file.path(cache_dir, paste0("MMRM_", get_session_hash(), ".stan"))

if (!file.exists(model_file)) {
clear_model_cache()
file.copy(file_loc, model_file, overwrite = TRUE)
}

rstan::stan_model(
file = model_file,
auto_write = TRUE,
Expand All @@ -603,8 +603,18 @@ get_stan_model <- function() {
#'
#' Default = `tools::R_user_dir("rbmi", which = "cache")`
#'
#' Directory to store compiled Stan model in. If not set, a temporary directory is used for
#' the given R session. Can also be set via the environment variable `RBMI_CACHE_DIR`.
#' Directory to store compiled Stan models in to avoid having to re-compile.
#' If the environment variable `RBMI_CACHE_DIR` has been set this will be used
#' as the default value.
#' Note that if you are running rbmi in multiple R processes at the same time
#' (that is say multiple calls to `Rscript` at once) then there is a theoretical
#' risk of the processes breaking each other as they attempt to read/write to the
#' same cache folder at the same time. To avoid this potential issue it is recommended
#' to set the cache directory to a unique folder for each R session e.g.
#'
#' ```
#' options("rbmi.cache_dir" = tempdir(check = TRUE))
#' ```
#'
#'
#' @examples
Expand Down
13 changes: 11 additions & 2 deletions man/rbmi-settings.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading