diff --git a/DESCRIPTION b/DESCRIPTION index e176f97..31ce8fd 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -9,7 +9,8 @@ Depends: R (>= 3.3.0) Imports: dplyr, - utils + utils, + orderly2 Suggests: knitr, rmarkdown, diff --git a/R/orderly_utils.R b/R/orderly_utils.R index effa613..7bfe894 100644 --- a/R/orderly_utils.R +++ b/R/orderly_utils.R @@ -39,8 +39,8 @@ execute_checks <- function(start, end, parallel) { if (parallel) { num_cores <- parallel::detectCores() - 1 # Use all but one core cl <- parallel::makeCluster(num_cores) + on.exit(parallel::stopCluster(cl), add = TRUE) # Ensure the cluster is stopped even if there's an error results <- parallel::parLapply(cl, start:end, check_parameter_set) - parallel::stopCluster(cl) } else { results <- lapply(start:end, check_parameter_set) } @@ -60,7 +60,7 @@ execute_checks <- function(start, end, parallel) { #' @return None. This function prints a summary of the results and detailed information if `verbose` is `TRUE`. #' #' @export -prod <- function(start = 1, end = 2, verbose = TRUE, parallel = TRUE) { +prod <- function(start = 1, end = 10000, verbose = TRUE, parallel = TRUE) { t0 <- Sys.time() @@ -98,7 +98,7 @@ prod <- function(start = 1, end = 2, verbose = TRUE, parallel = TRUE) { } } } - cat(end, "total packets processed in:", elapsed_time, "seconds\n") + cat(end - start + 1, "total packets processed in:", elapsed_time, "seconds\n") } # Print the results summary @@ -110,4 +110,6 @@ prod <- function(start = 1, end = 2, verbose = TRUE, parallel = TRUE) { cat("Parameter sets leading to errors:", paste(error_parameter_sets, collapse = ", "), "\n") + # Return the vector of error parameter sets + return(error_parameter_sets) } diff --git a/man/prod.Rd b/man/prod.Rd index 781a811..f12d6f5 100644 --- a/man/prod.Rd +++ b/man/prod.Rd @@ -4,7 +4,7 @@ \alias{prod} \title{Run Parameter Set Checks} \usage{ -prod(start = 1, end = 2, verbose = TRUE, parallel = TRUE) +prod(start = 1, end = 10000, verbose = TRUE, parallel = TRUE) } \arguments{ \item{start}{The starting index of the parameter sets to check (default is 1).}