From 367ff84d1db0c207c1e19098940c4b8a2707fb48 Mon Sep 17 00:00:00 2001 From: Eva Hamrud <50098063+evaham1@users.noreply.github.com> Date: Thu, 26 Sep 2024 11:15:00 +1000 Subject: [PATCH] fixed biocparallel asking for too many cpus in vignette.md -> now cmd check works locally on macOS --- vignettes/vignette.Rmd | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/vignettes/vignette.Rmd b/vignettes/vignette.Rmd index 833c677d..c1fd9f6b 100644 --- a/vignettes/vignette.Rmd +++ b/vignettes/vignette.Rmd @@ -915,6 +915,16 @@ The optimal parameters can be output, along with a plot showing the tuning resul list.keepX <- c(seq(5, 50, 5)) list.keepY <- c(3:10) +# added this to avoid errors where num_workers exceeded limits set by devtools::check() + chk <- Sys.getenv("_R_CHECK_LIMIT_CORES_", "") + if (nzchar(chk) && chk == "TRUE") { + # use 2 cores in CRAN/Travis/AppVeyor + num_workers <- 2L + } else { + # use all cores in devtools::test() + num_workers <- parallel::detectCores() + } + set.seed(33) # For reproducibility with this handbook, remove otherwise tune.spls.liver <- tune.spls(X, Y, test.keepX = list.keepX, test.keepY = list.keepY, ncomp = 2, @@ -922,7 +932,7 @@ tune.spls.liver <- tune.spls(X, Y, test.keepX = list.keepX, measure = 'cor', # the following uses two CPUs for faster computation # it can be commented out - BPPARAM = BiocParallel::SnowParam(workers = 14) + BPPARAM = BiocParallel::SnowParam(workers = num_workers) ) plot(tune.spls.liver)