Skip to content

Commit a4096d0

Browse files
authored
Merge pull request #536 from stan-dev/use-github-actions
Add R command check GitHub Action
2 parents dd2a5ac + bbd2b3a commit a4096d0

File tree

4 files changed

+72
-6
lines changed

4 files changed

+72
-6
lines changed

.github/workflows/R-CMD-check.yaml

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
1+
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
2+
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
3+
on:
4+
push:
5+
branches: [main, master]
6+
pull_request:
7+
8+
name: R-CMD-check.yaml
9+
10+
permissions: read-all
11+
12+
jobs:
13+
R-CMD-check:
14+
runs-on: ${{ matrix.config.os }}
15+
16+
name: ${{ matrix.config.os }} (${{ matrix.config.r }})
17+
18+
strategy:
19+
fail-fast: false
20+
matrix:
21+
config:
22+
- {os: macos-latest, r: 'release'}
23+
- {os: windows-latest, r: 'release'}
24+
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
25+
- {os: ubuntu-latest, r: 'release'}
26+
- {os: ubuntu-latest, r: 'oldrel-1'}
27+
28+
env:
29+
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
30+
R_KEEP_PKG_SOURCE: yes
31+
32+
steps:
33+
- uses: actions/checkout@v4
34+
35+
- uses: r-lib/actions/setup-pandoc@v2
36+
37+
- uses: r-lib/actions/setup-r@v2
38+
with:
39+
r-version: ${{ matrix.config.r }}
40+
http-user-agent: ${{ matrix.config.http-user-agent }}
41+
use-public-rspm: true
42+
extra-repositories: https://stan-dev.r-universe.dev
43+
44+
- uses: r-lib/actions/setup-r-dependencies@v2
45+
with:
46+
extra-packages: |
47+
any::rcmdcheck
48+
any::BH
49+
any::Rcpp
50+
any::RcppEigen
51+
any::RcppParallel
52+
any::StanHeaders
53+
needs: check
54+
55+
- uses: r-lib/actions/check-r-package@v2
56+
with:
57+
upload-snapshots: true
58+
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'

README.Rmd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ knitr::opts_chunk$set(
1616
<!-- badges: start -->
1717
<!-- [![codecov](https://codecov.io/gh/stan-dev/projpred/branch/master/graph/badge.svg)](https://app.codecov.io/gh/stan-dev/projpred) -->
1818
[![CRAN_Status_Badge](https://www.r-pkg.org/badges/version/projpred?color=blue)](https://CRAN.R-project.org/package=projpred)
19+
[![R-CMD-check](https://github.com/stan-dev/projpred/actions/workflows/R-CMD-check.yaml/badge.svg)](https://github.com/stan-dev/projpred/actions/workflows/R-CMD-check.yaml)
1920
<!-- badges: end -->
2021

2122
# projpred [<img src="man/figures/logo.svg" align="right" height="139" alt="Stan Logo"/>](https://mc-stan.org)

tests/testthat/test_augdat.R

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -211,7 +211,7 @@ test_that(paste(
211211

212212
eta_aug <- refmod_crr$family$linkfun(pref_aug$mu)
213213
eta_trad <- refmod_crr_trad$family$linkfun(pref_trad$mu)
214-
expect_identical(structure(unclass(eta_aug), ndiscrete = NULL), eta_trad,
214+
expect_equal(structure(unclass(eta_aug), ndiscrete = NULL), eta_trad,
215215
info = tstsetup)
216216
}
217217
if (exists("rng_old")) assign(".Random.seed", rng_old, envir = .GlobalEnv)

vignettes/projpred.Rmd

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -189,7 +189,8 @@ For this final `cv_varsel()` run (with `validate_search = TRUE`, as recommended)
189189
In practice, we recommend using either the default of `cv_method = "LOO"` (possibly subsampled, see argument `nloo` of `cv_varsel()`) or a larger value for `K` if this is possible in terms of computation time.
190190
Here, we also perform the $K$ reference model refits outside of `cv_varsel()`.
191191
Although not strictly necessary here, this is helpful in practice because often, `cv_varsel()` needs to be re-run multiple times in order to try out different argument settings.
192-
We also illustrate how **projpred**'s CV (i.e., the CV comprising search and performance evaluation, after refitting the reference model $K$ times) can be parallelized, even though this is of little use here (we have only `K = 2` folds and the fold-wise searches and performance evaluations are quite fast, so the parallelization overhead eats up any runtime improvements).
192+
We also show how **projpred**'s CV (i.e., the CV comprising search and performance evaluation, after refitting the reference model $K$ times) can be parallelized (though we disable it here for vignette building).
193+
In practice, parallelization is of little use with only `K = 2` folds and fast fold-wise operations, as the parallelization overhead eats up any runtime improvements.
193194
Note that for this final `cv_varsel()` run, we cannot make use of `cv_varsel.vsel()` (by applying `cv_varsel()` to `cvvs_fast` or `cvvs_fast_refit` instead of `refm_obj`) because of the change in `nterms_max` (here: 9, for `cvvs_fast` and `cvvs_fast_refit`: 20).
194195
```{r cv_varsel, message=FALSE}
195196
# Refit the reference model K times:
@@ -200,7 +201,11 @@ cv_fits <- run_cvfun(
200201
###
201202
)
202203
# For running projpred's CV in parallel (see cv_varsel()'s argument `parallel`):
203-
doParallel::registerDoParallel(ncores)
204+
# Note: Parallel processing is disabled during package building to avoid issues
205+
use_parallel <- FALSE # Set to TRUE for actual parallel processing
206+
if (use_parallel) {
207+
doParallel::registerDoParallel(ncores)
208+
}
204209
# Final cv_varsel() run:
205210
cvvs <- cv_varsel(
206211
refm_obj,
@@ -211,14 +216,16 @@ cvvs <- cv_varsel(
211216
nclusters_pred = 20,
212217
###
213218
nterms_max = 9,
214-
parallel = TRUE,
219+
parallel = use_parallel,
215220
### In interactive use, we recommend not to deactivate the verbose mode:
216221
verbose = 0
217222
###
218223
)
219224
# Tear down the CV parallelization setup:
220-
doParallel::stopImplicitCluster()
221-
foreach::registerDoSEQ()
225+
if (use_parallel) {
226+
doParallel::stopImplicitCluster()
227+
foreach::registerDoSEQ()
228+
}
222229
```
223230

224231
#### Predictive performance plot from final `cv_varsel()` run {#plotfinal}

0 commit comments

Comments
 (0)