Skip to content

Commit

Permalink
Enforce fewer run option defaults to work better on more systems
Browse files Browse the repository at this point in the history
  • Loading branch information
mattwarkentin committed Feb 20, 2024
1 parent 134bc03 commit 717cba5
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 29 deletions.
6 changes: 4 additions & 2 deletions R/R6ClassWorkset.R
Original file line number Diff line number Diff line change
Expand Up @@ -206,9 +206,9 @@ OpenMppWorkset <-
},

#' @description
#' Run scenario
#' Initiate a model run for the model workset/scenario.
#' @param name Run name.
#' @param opts Run options.
#' @param opts Run options. See [opts_run()] for more details.
#' @param wait Logical. Should we wait until the model run is done?
#' @param wait_time Number of seconds to wait between status checks.
#' @param progress Logical. Should a progress bar be shown?
Expand All @@ -219,6 +219,8 @@ OpenMppWorkset <-
rlang::abort('Workset must be read-only to initiate a run.')
}

rlang::check_required(name)

if (name %in% self$ModelRuns$Name) {
rlang::abort('ModelRun name already in use, choose a different name.')
}
Expand Down
38 changes: 20 additions & 18 deletions R/RunOptions.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,44 +2,42 @@
#'
#' @param SimulationCases Number of cases to simulate. Default is 5000.
#' @param SubValues Number of sub values. Default is 12.
#' @param RunStamp Run stamp.
#' @param Tables List of tables to output.
#' @param ... Not currently used.
#' @param RunStamp Run stamp. Default is generated based on the current time.
#' @param Opts Additional options to pass to the `Opts` list component.
#' @param ... Any other run options.
#'
#' @details The default number of `SimulationCases` is low to enable rapid
#' iteration but should be increased when running a model where the results
#' are expected to be robust.
#'
#'
#' @export
opts_run <- function(
SimulationCases = '5000',
SubValues = '12',
RunStamp = NULL,
Tables = list(),
SimulationCases = 5000,
SubValues = 12,
RunStamp = TimeStamp(),
Opts = list(),
...
) {
if (rlang::is_null(RunStamp)) {
RunStamp <- sub('.' , '_', fixed = TRUE, format(Sys.time(),"%Y_%m_%d_%H_%M_%OS3"))
if (!rlang::is_scalar_integerish(SimulationCases)) {
rlang::abort('`SimulationCases` must be a scalar integer.')
}

if (!rlang::is_scalar_integerish(SubValues)) {
rlang::abort('`SubValues` must be a scalar integer.')
}

SimulationCases <- format(SimulationCases, scientific = FALSE)

structure(
list(
RunStamp = RunStamp,
Mpi = list(
Np = 4,
IsNotOnRoot = TRUE
),
Opts = list(
Opts = c(list(
Parameter.SimulationCases = SimulationCases,
OpenM.SubValues = as.character(SubValues),
OpenM.RunStamp = RunStamp,
OpenM.Threads = '4',
OpenM.LogToConsole = 'true'
),
Tables = Tables
), Opts),
...
),
class = c('OpenMppRunOpts', 'list')
)
Expand All @@ -52,3 +50,7 @@ print.OpenMppRunOpts = function(x, ...) {
cli::cat_line('OpenM++ Run Options')
print(jsonlite::toJSON(x, pretty = TRUE, auto_unbox = TRUE))
}

TimeStamp <- function() {
sub('.' , '_', fixed = TRUE, format(Sys.time(),"%Y_%m_%d_%H_%M_%OS3"))
}
4 changes: 2 additions & 2 deletions man/load_workset.Rd

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

14 changes: 7 additions & 7 deletions man/opts_run.Rd

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

0 comments on commit 717cba5

Please sign in to comment.