diff --git a/R/model.R b/R/model.R index 289558f0..0b4ba47e 100644 --- a/R/model.R +++ b/R/model.R @@ -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, @@ -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), @@ -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, @@ -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, @@ -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, @@ -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, @@ -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), @@ -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) { diff --git a/R/options.R b/R/options.R index b5e39663..575ff27f 100644 --- a/R/options.R +++ b/R/options.R @@ -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`. @@ -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 diff --git a/man-roxygen/model-common-args.R b/man-roxygen/model-common-args.R index ca609ebe..f65eb21c 100644 --- a/man-roxygen/model-common-args.R +++ b/man-roxygen/model-common-args.R @@ -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., diff --git a/man/cmdstanr_global_options.Rd b/man/cmdstanr_global_options.Rd index dda64c88..d6435165 100644 --- a/man/cmdstanr_global_options.Rd +++ b/man/cmdstanr_global_options.Rd @@ -19,13 +19,15 @@ even if there were no Stan code changes since last compiled? See using the \code{\link[=fit-method-summary]{$print()}} method. The default is 10. \item \code{cmdstanr_no_ver_check}: Should the check for a more recent version of CmdStan be disabled? The default is \code{FALSE}. +\item \code{cmdstanr_output_dir}: The directory where CmdStan should write its output +CSV files when fitting models. The default is a temporary directory. \item \code{cmdstanr_verbose}: Should more information be printed when compiling or running models, including showing how CmdStan was called internally? The default is \code{FALSE}. \item \code{cmdstanr_warn_inits}: Should a warning be thrown if initial values are only provided for a subset of parameters? The default is \code{TRUE}. \item \code{cmdstanr_write_stan_file_dir}: The directory where \code{\link[=write_stan_file]{write_stan_file()}} -should write Stan files. The default is \code{\link[=tempdir]{tempdir()}}. +should write Stan files. The default is a temporary directory. \item \code{mc.cores}: The number of cores to use for various parallelization tasks (e.g. running MCMC chains, installing CmdStan). The default depends on the use case and is documented with the methods that make use of \code{mc.cores}. diff --git a/man/model-method-diagnose.Rd b/man/model-method-diagnose.Rd index 99043501..631ce6f6 100644 --- a/man/model-method-diagnose.Rd +++ b/man/model-method-diagnose.Rd @@ -9,7 +9,7 @@ diagnose( data = NULL, seed = NULL, init = NULL, - output_dir = NULL, + output_dir = getOption("cmdstanr_output_dir"), output_basename = NULL, epsilon = NULL, error = NULL @@ -68,7 +68,8 @@ its output CSV files. For MCMC there will be one file per chain; for other methods there will be a single file. For interactive use this can typically be left at \code{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 \code{output_dir} is as follows: +fitted model objects. This can be set for an entire \R session using +\code{options(cmdstanr_output_dir)}. The behavior of \code{output_dir} is as follows: \itemize{ \item If \code{NULL} (the default), then the CSV files are written to a temporary directory and only saved permanently if the user calls one of the \verb{$save_*} diff --git a/man/model-method-generate-quantities.Rd b/man/model-method-generate-quantities.Rd index 23acba19..21ce47a2 100644 --- a/man/model-method-generate-quantities.Rd +++ b/man/model-method-generate-quantities.Rd @@ -9,7 +9,7 @@ generate_quantities( 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), @@ -62,7 +62,8 @@ its output CSV files. For MCMC there will be one file per chain; for other methods there will be a single file. For interactive use this can typically be left at \code{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 \code{output_dir} is as follows: +fitted model objects. This can be set for an entire \R session using +\code{options(cmdstanr_output_dir)}. The behavior of \code{output_dir} is as follows: \itemize{ \item If \code{NULL} (the default), then the CSV files are written to a temporary directory and only saved permanently if the user calls one of the \verb{$save_*} diff --git a/man/model-method-laplace.Rd b/man/model-method-laplace.Rd index 253d67f5..2ebb00b3 100644 --- a/man/model-method-laplace.Rd +++ b/man/model-method-laplace.Rd @@ -11,7 +11,7 @@ laplace( 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, @@ -83,7 +83,8 @@ its output CSV files. For MCMC there will be one file per chain; for other methods there will be a single file. For interactive use this can typically be left at \code{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 \code{output_dir} is as follows: +fitted model objects. This can be set for an entire \R session using +\code{options(cmdstanr_output_dir)}. The behavior of \code{output_dir} is as follows: \itemize{ \item If \code{NULL} (the default), then the CSV files are written to a temporary directory and only saved permanently if the user calls one of the \verb{$save_*} diff --git a/man/model-method-optimize.Rd b/man/model-method-optimize.Rd index b9b53454..dbed1150 100644 --- a/man/model-method-optimize.Rd +++ b/man/model-method-optimize.Rd @@ -11,7 +11,7 @@ optimize( 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, @@ -97,7 +97,8 @@ its output CSV files. For MCMC there will be one file per chain; for other methods there will be a single file. For interactive use this can typically be left at \code{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 \code{output_dir} is as follows: +fitted model objects. This can be set for an entire \R session using +\code{options(cmdstanr_output_dir)}. The behavior of \code{output_dir} is as follows: \itemize{ \item If \code{NULL} (the default), then the CSV files are written to a temporary directory and only saved permanently if the user calls one of the \verb{$save_*} diff --git a/man/model-method-pathfinder.Rd b/man/model-method-pathfinder.Rd index 41504358..d16ad170 100644 --- a/man/model-method-pathfinder.Rd +++ b/man/model-method-pathfinder.Rd @@ -11,7 +11,7 @@ pathfinder( 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, @@ -102,7 +102,8 @@ its output CSV files. For MCMC there will be one file per chain; for other methods there will be a single file. For interactive use this can typically be left at \code{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 \code{output_dir} is as follows: +fitted model objects. This can be set for an entire \R session using +\code{options(cmdstanr_output_dir)}. The behavior of \code{output_dir} is as follows: \itemize{ \item If \code{NULL} (the default), then the CSV files are written to a temporary directory and only saved permanently if the user calls one of the \verb{$save_*} diff --git a/man/model-method-sample.Rd b/man/model-method-sample.Rd index 526c9c88..51b4ce45 100644 --- a/man/model-method-sample.Rd +++ b/man/model-method-sample.Rd @@ -11,7 +11,7 @@ sample( 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, @@ -115,7 +115,8 @@ its output CSV files. For MCMC there will be one file per chain; for other methods there will be a single file. For interactive use this can typically be left at \code{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 \code{output_dir} is as follows: +fitted model objects. This can be set for an entire \R session using +\code{options(cmdstanr_output_dir)}. The behavior of \code{output_dir} is as follows: \itemize{ \item If \code{NULL} (the default), then the CSV files are written to a temporary directory and only saved permanently if the user calls one of the \verb{$save_*} diff --git a/man/model-method-sample_mpi.Rd b/man/model-method-sample_mpi.Rd index ca7203da..078461bb 100644 --- a/man/model-method-sample_mpi.Rd +++ b/man/model-method-sample_mpi.Rd @@ -13,7 +13,7 @@ sample_mpi( 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), @@ -114,7 +114,8 @@ its output CSV files. For MCMC there will be one file per chain; for other methods there will be a single file. For interactive use this can typically be left at \code{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 \code{output_dir} is as follows: +fitted model objects. This can be set for an entire \R session using +\code{options(cmdstanr_output_dir)}. The behavior of \code{output_dir} is as follows: \itemize{ \item If \code{NULL} (the default), then the CSV files are written to a temporary directory and only saved permanently if the user calls one of the \verb{$save_*} diff --git a/man/model-method-variational.Rd b/man/model-method-variational.Rd index 1b2d9a74..87decfd9 100644 --- a/man/model-method-variational.Rd +++ b/man/model-method-variational.Rd @@ -11,7 +11,7 @@ variational( 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, @@ -98,7 +98,8 @@ its output CSV files. For MCMC there will be one file per chain; for other methods there will be a single file. For interactive use this can typically be left at \code{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 \code{output_dir} is as follows: +fitted model objects. This can be set for an entire \R session using +\code{options(cmdstanr_output_dir)}. The behavior of \code{output_dir} is as follows: \itemize{ \item If \code{NULL} (the default), then the CSV files are written to a temporary directory and only saved permanently if the user calls one of the \verb{$save_*}