Skip to content

Commit

Permalink
updates for no-suggests checks (#949)
Browse files Browse the repository at this point in the history
* no suggests changes

* more no-suggest changes

* various no suggests updates

* move to examplesIf

* kernlab

* skip skip skip

* regen snapshots

* skip skip

* one more example adjustment

* a few more minor changes
  • Loading branch information
topepo authored Oct 18, 2024
1 parent 51db99e commit bc5422a
Show file tree
Hide file tree
Showing 45 changed files with 442 additions and 140 deletions.
59 changes: 59 additions & 0 deletions .github/workflows/R-CMD-check-hard.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
# Workflow derived from https://github.com/r-lib/actions/tree/v2/examples
# Need help debugging build failures? Start at https://github.com/r-lib/actions#where-to-find-help
#
# NOTE: This workflow only directly installs "hard" dependencies, i.e. Depends,
# Imports, and LinkingTo dependencies. Notably, Suggests dependencies are never
# installed, with the exception of testthat, knitr, and rmarkdown. The cache is
# never used to avoid accidentally restoring a cache containing a suggested
# dependency.
on:
push:
branches: [main, master]
pull_request:

name: R-CMD-check-hard.yaml

permissions: read-all

jobs:
check-no-suggests:
runs-on: ${{ matrix.config.os }}

name: ${{ matrix.config.os }} (${{ matrix.config.r }})

strategy:
fail-fast: false
matrix:
config:
- {os: ubuntu-latest, r: 'release'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
R_KEEP_PKG_SOURCE: yes

steps:
- uses: actions/checkout@v4

- uses: r-lib/actions/setup-pandoc@v2

- uses: r-lib/actions/setup-r@v2
with:
r-version: ${{ matrix.config.r }}
http-user-agent: ${{ matrix.config.http-user-agent }}
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v2
with:
dependencies: '"hard"'
cache: false
extra-packages: |
any::rcmdcheck
any::testthat
any::knitr
any::rmarkdown
needs: check

- uses: r-lib/actions/check-r-package@v2
with:
upload-snapshots: true
build_args: 'c("--no-manual","--compact-vignettes=gs+qpdf")'
2 changes: 1 addition & 1 deletion DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ Imports:
recipes (>= 1.0.4),
rlang (>= 1.1.0),
rsample (>= 1.2.1.9000),
tailor,
tibble (>= 3.1.0),
tidyr (>= 1.2.0),
tidyselect (>= 1.1.2),
Expand All @@ -52,7 +53,6 @@ Suggests:
scales,
spelling,
splines2,
tailor,
testthat (>= 3.0.0),
xgboost,
xml2
Expand Down
4 changes: 3 additions & 1 deletion R/conf_mat_resampled.R
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
#' @param tidy Should the results come back in a tibble (`TRUE`) or a `conf_mat`
#' object like `yardstick::conf_mat()` (`FALSE`)?
#' @return A tibble or `conf_mat` with the average cell count across resamples.
#' @examples
#' @examplesIf rlang::is_installed("modeldata")
#' # example code
#'
#' library(parsnip)
#' library(rsample)
#' library(dplyr)
Expand Down
3 changes: 2 additions & 1 deletion R/coord_obs_pred.R
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,8 @@ CoordObsPred <-
#' may show up in places such as the axes, the legend, the plot title, or the
#' plot margins.
#' @return A `ggproto` object.
#' @examples
#' @examplesIf rlang::is_installed("modeldata")
#' # example code
#' data(solubility_test, package = "modeldata")
#'
#' library(ggplot2)
Expand Down
4 changes: 3 additions & 1 deletion R/extract.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,9 @@
#' description section.
#'
#' @name extract-tune
#' @examples
#' @examplesIf rlang::is_installed("splines2")
#' # example code
#'
#' library(recipes)
#' library(rsample)
#' library(parsnip)
Expand Down
6 changes: 3 additions & 3 deletions R/fit_best.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#' a column for each tuning parameter. This tibble should have columns for each
#' tuning parameter identifier (e.g. `"my_param"` if `tune("my_param")` was used).
#' If `NULL`, this argument will be set to
#' [`select_best(metric, eval_time)`][tune::select_best.tune_results].
#' If not `NULL`, `parameters` overwrites the specification via `metric`, and
#' [`select_best(metric, eval_time)`][tune::select_best.tune_results].
#' If not `NULL`, `parameters` overwrites the specification via `metric`, and
#' `eval_time`.
#' @param verbose A logical for printing logging.
#' @param add_validation_set When the resamples embedded in `x` are a split into
Expand All @@ -37,7 +37,7 @@
#'
#' @inheritSection last_fit See also
#'
#' @examplesIf tune:::should_run_examples()
#' @examplesIf tune:::should_run_examples() & rlang::is_installed("modeldata")
#' library(recipes)
#' library(rsample)
#' library(parsnip)
Expand Down
32 changes: 17 additions & 15 deletions R/int_pctl.R
Original file line number Diff line number Diff line change
Expand Up @@ -46,24 +46,26 @@
#' @references Davison, A., & Hinkley, D. (1997). _Bootstrap Methods and their
#' Application_. Cambridge: Cambridge University Press.
#' doi:10.1017/CBO9780511802843
#' @examplesIf !tune:::is_cran_check() & tune:::should_run_examples("modeldata")
#' data(Sacramento, package = "modeldata")
#' library(rsample)
#' library(parsnip)
#' @examplesIf !tune:::is_cran_check()
#' if (rlang::is_installed("modeldata")) {
#' data(Sacramento, package = "modeldata")
#' library(rsample)
#' library(parsnip)
#'
#' set.seed(13)
#' sac_rs <- vfold_cv(Sacramento)
#' set.seed(13)
#' sac_rs <- vfold_cv(Sacramento)
#'
#' lm_res <-
#' linear_reg() %>%
#' fit_resamples(
#' log10(price) ~ beds + baths + sqft + type + latitude + longitude,
#' resamples = sac_rs,
#' control = control_resamples(save_pred = TRUE)
#' )
#' lm_res <-
#' linear_reg() %>%
#' fit_resamples(
#' log10(price) ~ beds + baths + sqft + type + latitude + longitude,
#' resamples = sac_rs,
#' control = control_resamples(save_pred = TRUE)
#' )
#'
#' set.seed(31)
#' int_pctl(lm_res)
#' set.seed(31)
#' int_pctl(lm_res)
#' }
#' @export
int_pctl.tune_results <- function(.data, metrics = NULL, eval_time = NULL,
times = 1001, parameters = NULL,
Expand Down
2 changes: 1 addition & 1 deletion R/last_fit.R
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,7 @@
#' model (and recipe, if any) that used the training set. Helper functions
#' for formatting tuning results like [collect_metrics()] and
#' [collect_predictions()] can be used with `last_fit()` output.
#' @examplesIf tune:::should_run_examples()
#' @examplesIf tune:::should_run_examples() & rlang::is_installed("splines2")
#' library(recipes)
#' library(rsample)
#' library(parsnip)
Expand Down
2 changes: 1 addition & 1 deletion R/merge.R
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
#'
#' @return A tibble with a column `x` that has as many rows as were in `y`.
#' @keywords internal
#' @examplesIf tune:::should_run_examples(suggests = c("xgboost", "modeldata"))
#' @examplesIf tune:::should_run_examples(suggests = c("xgboost", "modeldata", "splines2"))
#' library(tibble)
#' library(recipes)
#' library(parsnip)
Expand Down
2 changes: 1 addition & 1 deletion R/resample.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
#' @template case-weights
#' @template censored-regression
#' @seealso [control_resamples()], [collect_predictions()], [collect_metrics()]
#' @examplesIf tune:::should_run_examples()
#' @examplesIf tune:::should_run_examples() & rlang::is_installed("splines2")
#' library(recipes)
#' library(rsample)
#' library(parsnip)
Expand Down
2 changes: 1 addition & 1 deletion R/tune_grid.R
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@
#' @template case-weights
#' @template censored-regression
#'
#' @examplesIf tune:::should_run_examples(suggests = "kernlab")
#' @examplesIf tune:::should_run_examples(suggests = "kernlab") & rlang::is_installed("splines2")
#' library(recipes)
#' library(rsample)
#' library(parsnip)
Expand Down
4 changes: 4 additions & 0 deletions man/conf_mat_resampled.Rd

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

3 changes: 3 additions & 0 deletions man/coord_obs_pred.Rd

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

4 changes: 4 additions & 0 deletions man/extract-tune.Rd

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

2 changes: 1 addition & 1 deletion man/fit_best.Rd

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

2 changes: 1 addition & 1 deletion man/fit_resamples.Rd

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

32 changes: 17 additions & 15 deletions man/int_pctl.tune_results.Rd

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

2 changes: 1 addition & 1 deletion man/last_fit.Rd

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

2 changes: 1 addition & 1 deletion man/merge.recipe.Rd

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

2 changes: 1 addition & 1 deletion man/tune_grid.Rd

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

12 changes: 6 additions & 6 deletions tests/testthat/_snaps/bayes.md
Original file line number Diff line number Diff line change
Expand Up @@ -392,13 +392,13 @@
cars_res <- tune_bayes(svm_mod, preprocessor = rec, resamples = data_folds)
Message
x Fold1: preprocessor 1/1:
Error in `step_bs()`:
Caused by error in `if (...) NULL`:
! missing value where TRUE/FALSE needed
Error in `step_spline_b()`:
Caused by error in `glue()`:
! Expecting '}'
x Fold2: preprocessor 1/1:
Error in `step_bs()`:
Caused by error in `if (...) NULL`:
! missing value where TRUE/FALSE needed
Error in `step_spline_b()`:
Caused by error in `glue()`:
! Expecting '}'
Condition
Warning:
All models failed. Run `show_notes(.Last.tune.result)` for more information.
Expand Down
16 changes: 16 additions & 0 deletions tests/testthat/_snaps/checks.md
Original file line number Diff line number Diff line change
Expand Up @@ -92,6 +92,22 @@
Error in `tune:::check_workflow()`:
! A parsnip model is required.

# errors informatively when needed package isn't installed

Code
check_workflow(stan_wflow)
Condition
Error:
! Package install is required for rstanarm.

---

Code
fit_resamples(stan_wflow, rsample::bootstraps(mtcars))
Condition
Error in `fit_resamples()`:
! Package install is required for rstanarm.

# workflow objects (will not tune, tidymodels/tune#548)

Code
Expand Down
Loading

0 comments on commit bc5422a

Please sign in to comment.