From c6bc89785808d8b251c582820f331a7a8c411ba6 Mon Sep 17 00:00:00 2001 From: Weston Voglesonger Date: Wed, 7 Oct 2026 18:02:00 -0400 Subject: [PATCH] Avoid CRAN CPU notes from Stan smoke and example --- .github/workflows/test-coverage.yaml | 2 ++ R/hestia_functions.R | 2 +- tests/testthat/test-hestia-smoke.R | 11 ++++++----- 3 files changed, 9 insertions(+), 6 deletions(-) diff --git a/.github/workflows/test-coverage.yaml b/.github/workflows/test-coverage.yaml index 7f2c0bc..61785b5 100644 --- a/.github/workflows/test-coverage.yaml +++ b/.github/workflows/test-coverage.yaml @@ -12,6 +12,8 @@ jobs: env: GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }} R_KEEP_PKG_SOURCE: yes + # Keep the live Stan smoke fit active in CI; it skips on CRAN (#91). + NOT_CRAN: 'true' steps: - name: Checkout repository diff --git a/R/hestia_functions.R b/R/hestia_functions.R index 1899c7a..029fc20 100644 --- a/R/hestia_functions.R +++ b/R/hestia_functions.R @@ -926,7 +926,7 @@ make_stan_data <- function( #' [stan_options()] (for example `stan_options(iter = 1000)`). #' @returns `draws_array` object with chains for each model parameter #' -#' @examples +#' @examplesIf interactive() #' # Subset sir package data to 10 households (for speedy example) #' sir_sub <- sir[sir$hh_id <= 10, ] #' diff --git a/tests/testthat/test-hestia-smoke.R b/tests/testthat/test-hestia-smoke.R index 0b0574c..6fc7e6c 100644 --- a/tests/testthat/test-hestia-smoke.R +++ b/tests/testthat/test-hestia-smoke.R @@ -1,7 +1,7 @@ # End-to-end smoke test. This fits a real (if tiny) Stan model on the bundled # `sir` data and checks that the pipeline returns sensible, well-named draws. -# It deliberately uses a single short chain so it is cheap enough to run in CI -# on every push (no skip_on_cran()). +# The live fit runs in CI but is skipped on CRAN: even a single short chain +# uses several CPU seconds per elapsed second with Stan's reduce_sum (#91). test_that("the package and its bundled data are available", { expect_true(requireNamespace("hestia", quietly = TRUE)) @@ -13,13 +13,14 @@ test_that("the package and its bundled data are available", { }) test_that("run_model fits an SIR model end-to-end and returns named draws", { + skip_on_cran() + inf_mod <- sir_infection_model() obs_mod <- sir_observation_model() dat <- sir_subset(10) - # A single short chain keeps this cheap enough to run unconditionally (no - # skip_on_cran()) on CRAN's own check machines: run_model()'s init list is - # built dynamically from stan_opts$chains, so chains = 1 is fully supported. + # The init list is built dynamically from stan_opts$chains, so chains = 1 is + # supported while keeping this CI fit short. suppressWarnings(suppressMessages( draws <- run_model( inf_model = inf_mod,