Skip to content

Commit

Permalink
add option cmdstanr_output_dir
Browse files Browse the repository at this point in the history
closes #945
  • Loading branch information
jgabry committed Apr 17, 2024
1 parent 262c320 commit 4da28a7
Show file tree
Hide file tree
Showing 12 changed files with 41 additions and 27 deletions.
16 changes: 8 additions & 8 deletions R/model.R
Original file line number Diff line number Diff line change
Expand Up @@ -1123,7 +1123,7 @@ sample <- function(data = NULL,
refresh = NULL,
init = NULL,
save_latent_dynamics = FALSE,
output_dir = NULL,
output_dir = getOption("cmdstanr_output_dir"),
output_basename = NULL,
sig_figs = NULL,
chains = 4,
Expand Down Expand Up @@ -1334,7 +1334,7 @@ sample_mpi <- function(data = NULL,
refresh = NULL,
init = NULL,
save_latent_dynamics = FALSE,
output_dir = NULL,
output_dir = getOption("cmdstanr_output_dir"),
output_basename = NULL,
chains = 1,
chain_ids = seq_len(chains),
Expand Down Expand Up @@ -1484,7 +1484,7 @@ optimize <- function(data = NULL,
refresh = NULL,
init = NULL,
save_latent_dynamics = FALSE,
output_dir = NULL,
output_dir = getOption("cmdstanr_output_dir"),
output_basename = NULL,
sig_figs = NULL,
threads = NULL,
Expand Down Expand Up @@ -1622,7 +1622,7 @@ laplace <- function(data = NULL,
refresh = NULL,
init = NULL,
save_latent_dynamics = FALSE,
output_dir = NULL,
output_dir = getOption("cmdstanr_output_dir"),
output_basename = NULL,
sig_figs = NULL,
threads = NULL,
Expand Down Expand Up @@ -1769,7 +1769,7 @@ variational <- function(data = NULL,
refresh = NULL,
init = NULL,
save_latent_dynamics = FALSE,
output_dir = NULL,
output_dir = getOption("cmdstanr_output_dir"),
output_basename = NULL,
sig_figs = NULL,
threads = NULL,
Expand Down Expand Up @@ -1908,7 +1908,7 @@ pathfinder <- function(data = NULL,
refresh = NULL,
init = NULL,
save_latent_dynamics = FALSE,
output_dir = NULL,
output_dir = getOption("cmdstanr_output_dir"),
output_basename = NULL,
sig_figs = NULL,
opencl_ids = NULL,
Expand Down Expand Up @@ -2060,7 +2060,7 @@ CmdStanModel$set("public", name = "pathfinder", value = pathfinder)
generate_quantities <- function(fitted_params,
data = NULL,
seed = NULL,
output_dir = NULL,
output_dir = getOption("cmdstanr_output_dir"),
output_basename = NULL,
sig_figs = NULL,
parallel_chains = getOption("mc.cores", 1),
Expand Down Expand Up @@ -2125,7 +2125,7 @@ CmdStanModel$set("public", name = "generate_quantities", value = generate_quanti
diagnose <- function(data = NULL,
seed = NULL,
init = NULL,
output_dir = NULL,
output_dir = getOption("cmdstanr_output_dir"),
output_basename = NULL,
epsilon = NULL,
error = NULL) {
Expand Down
5 changes: 4 additions & 1 deletion R/options.R
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,9 @@
#' * `cmdstanr_no_ver_check`: Should the check for a more recent version of
#' CmdStan be disabled? The default is `FALSE`.
#'
#' * `cmdstanr_output_dir`: The directory where CmdStan should write its output
#' CSV files when fitting models. The default is a temporary directory.
#'
#' * `cmdstanr_verbose`: Should more information be printed
#' when compiling or running models, including showing how CmdStan was called
#' internally? The default is `FALSE`.
Expand All @@ -29,7 +32,7 @@
#' only provided for a subset of parameters? The default is `TRUE`.
#'
#' * `cmdstanr_write_stan_file_dir`: The directory where [write_stan_file()]
#' should write Stan files. The default is [tempdir()].
#' should write Stan files. The default is a temporary directory.
#'
#' * `mc.cores`: The number of cores to use for various parallelization tasks
#' (e.g. running MCMC chains, installing CmdStan). The default depends on the
Expand Down
3 changes: 2 additions & 1 deletion man-roxygen/model-common-args.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,8 @@
#' methods there will be a single file. For interactive use this can typically
#' be left at `NULL` (temporary directory) since CmdStanR makes the CmdStan
#' output (posterior draws and diagnostics) available in \R via methods of the
#' fitted model objects. The behavior of `output_dir` is as follows:
#' fitted model objects. This can be set for an entire \R session using
#' `options(cmdstanr_output_dir)`. The behavior of `output_dir` is as follows:
#' * If `NULL` (the default), then the CSV files are written to a temporary
#' directory and only saved permanently if the user calls one of the `$save_*`
#' methods of the fitted model object (e.g.,
Expand Down
4 changes: 3 additions & 1 deletion man/cmdstanr_global_options.Rd

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

5 changes: 3 additions & 2 deletions man/model-method-diagnose.Rd

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

5 changes: 3 additions & 2 deletions man/model-method-generate-quantities.Rd

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

5 changes: 3 additions & 2 deletions man/model-method-laplace.Rd

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

5 changes: 3 additions & 2 deletions man/model-method-optimize.Rd

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

5 changes: 3 additions & 2 deletions man/model-method-pathfinder.Rd

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

5 changes: 3 additions & 2 deletions man/model-method-sample.Rd

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

5 changes: 3 additions & 2 deletions man/model-method-sample_mpi.Rd

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

5 changes: 3 additions & 2 deletions man/model-method-variational.Rd

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

0 comments on commit 4da28a7

Please sign in to comment.