Skip to content

Commit

Permalink
Merge pull request #116 from tidymodels/2023-spring-cleaning
Browse files Browse the repository at this point in the history
2023 spring cleaning
  • Loading branch information
topepo authored Oct 31, 2023
2 parents 4e33df6 + a842994 commit 103e3f5
Show file tree
Hide file tree
Showing 34 changed files with 273 additions and 237 deletions.
21 changes: 10 additions & 11 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# 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 is overkill for most R packages and
Expand All @@ -22,24 +22,25 @@ jobs:
fail-fast: false
matrix:
config:
- {os: macOS-latest, r: 'release'}
- {os: macos-latest, r: 'release'}

- {os: windows-latest, r: 'release'}
# Use 3.6 to trigger usage of RTools35
- {os: windows-latest, r: '3.6'}
# use 4.1 to check with rtools40's older compiler
- {os: windows-latest, r: '4.1'}

# Use older ubuntu to maximise backward compatibility
- {os: ubuntu-18.04, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-18.04, r: 'release'}
- {os: ubuntu-18.04, r: 'oldrel-1'}
- {os: ubuntu-18.04, r: 'oldrel-2'}
- {os: ubuntu-latest, r: 'devel', http-user-agent: 'release'}
- {os: ubuntu-latest, r: 'release'}
- {os: ubuntu-latest, r: 'oldrel-1'}
- {os: ubuntu-latest, r: 'oldrel-2'}

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

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

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

Expand All @@ -51,9 +52,7 @@ jobs:

- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages:
any::rcmdcheck,
randomForest=?ignore-before-r=4.1.0
extra-packages: any::rcmdcheck
needs: check

- uses: r-lib/actions/check-r-package@v2
Expand Down
26 changes: 18 additions & 8 deletions .github/workflows/pkgdown.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# 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
# Add Config/Needs/website: tidyverse/tidytemplate to DESCRIPTION
on:
push:
branches: [main, master]
Expand All @@ -15,10 +14,15 @@ name: pkgdown
jobs:
pkgdown:
runs-on: ubuntu-latest
# Only restrict concurrency for non-PR jobs
concurrency:
group: pkgdown-${{ github.event_name != 'pull_request' || github.run_id }}
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
permissions:
contents: write
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

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

Expand All @@ -31,8 +35,14 @@ jobs:
extra-packages: any::pkgdown, local::.
needs: website

- name: Deploy package
run: |
git config --local user.name "$GITHUB_ACTOR"
git config --local user.email "[email protected]"
Rscript -e 'pkgdown::deploy_to_branch(new_process = FALSE)'
- name: Build site
run: pkgdown::build_site_github_pages(new_process = FALSE, install = FALSE)
shell: Rscript {0}

- name: Deploy to GitHub pages 🚀
if: github.event_name != 'pull_request'
uses: JamesIves/[email protected]
with:
clean: false
branch: gh-pages
folder: docs
36 changes: 20 additions & 16 deletions .github/workflows/pr-commands.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# 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
on:
issue_comment:
Expand All @@ -8,28 +8,30 @@ name: Commands

jobs:
document:
if: startsWith(github.event.comment.body, '/document')
if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/document') }}
name: document
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: r-lib/actions/pr-fetch@v1
- uses: r-lib/actions/pr-fetch@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

- uses: r-lib/actions/setup-r@v1
- uses: r-lib/actions/setup-r@v2
with:
use-public-rspm: true

- uses: r-lib/actions/setup-r-dependencies@v1
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: roxygen2
extra-packages: any::roxygen2
needs: pr-document

- name: Document
run: Rscript -e 'roxygen2::roxygenise()'
run: roxygen2::roxygenise()
shell: Rscript {0}

- name: commit
run: |
Expand All @@ -38,30 +40,32 @@ jobs:
git add man/\* NAMESPACE
git commit -m 'Document'
- uses: r-lib/actions/pr-push@v1
- uses: r-lib/actions/pr-push@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

style:
if: startsWith(github.event.comment.body, '/style')
if: ${{ github.event.issue.pull_request && (github.event.comment.author_association == 'MEMBER' || github.event.comment.author_association == 'OWNER') && startsWith(github.event.comment.body, '/style') }}
name: style
runs-on: ubuntu-latest
env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: r-lib/actions/pr-fetch@v1
- uses: r-lib/actions/pr-fetch@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}

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

- name: Install dependencies
run: Rscript -e 'install.packages("styler")'
run: install.packages("styler")
shell: Rscript {0}

- name: Style
run: Rscript -e 'styler::style_pkg()'
run: styler::style_pkg()
shell: Rscript {0}

- name: commit
run: |
Expand All @@ -70,6 +74,6 @@ jobs:
git add \*.R
git commit -m 'Style'
- uses: r-lib/actions/pr-push@v1
- uses: r-lib/actions/pr-push@v2
with:
repo-token: ${{ secrets.GITHUB_TOKEN }}
25 changes: 22 additions & 3 deletions .github/workflows/test-coverage.yaml
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
# Workflow derived from https://github.com/r-lib/actions/tree/master/examples
# 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
on:
push:
Expand All @@ -15,7 +15,7 @@ jobs:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}

steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3

- uses: r-lib/actions/setup-r@v2
with:
Expand All @@ -27,5 +27,24 @@ jobs:
needs: coverage

- name: Test coverage
run: covr::codecov(quiet = FALSE)
run: |
covr::codecov(
quiet = FALSE,
clean = FALSE,
install_path = file.path(normalizePath(Sys.getenv("RUNNER_TEMP"), winslash = "/"), "package")
)
shell: Rscript {0}

- name: Show testthat output
if: always()
run: |
## --------------------------------------------------------------------
find ${{ runner.temp }}/package -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash

- name: Upload test results
if: failure()
uses: actions/upload-artifact@v3
with:
name: coverage-test-failures
path: ${{ runner.temp }}/package
21 changes: 10 additions & 11 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
Package: tidypredict
Title: Run Predictions Inside the Database
Version: 0.5
Authors@R:
c(
person("Edgar", "Ruiz", email = "[email protected]", role = c("aut", "cre")),
person("Max", "Kuhn", email = "[email protected]", role = c("aut"))
)
Authors@R: c(
person("Edgar", "Ruiz", , "[email protected]", role = c("aut", "cre")),
person("Max", "Kuhn", , "[email protected]", role = "aut")
)
Description: It parses a fitted 'R' model object, and returns a formula in
'Tidy Eval' code that calculates the predictions. It works with
several databases back-ends because it leverages 'dplyr' and 'dbplyr'
Expand All @@ -17,13 +16,14 @@ URL: https://tidypredict.tidymodels.org,
https://github.com/tidymodels/tidypredict
BugReports: https://github.com/tidymodels/tidypredict/issues
Depends:
R (>= 3.1)
R (>= 3.6)
Imports:
cli,
dplyr (>= 0.7),
generics,
knitr,
purrr,
rlang,
rlang (>= 1.1.1),
tibble,
tidyr
Suggests:
Expand All @@ -42,13 +42,12 @@ Suggests:
ranger,
rmarkdown,
RSQLite,
testthat (>= 3.0.0),
testthat (>= 3.2.0),
xgboost,
yaml
VignetteBuilder:
knitr
Config/Needs/website:
tidyverse/tidytemplate
Config/Needs/website: tidyverse/tidytemplate
Config/testthat/edition: 3
Encoding: UTF-8
RoxygenNote: 7.2.3
Config/testthat/edition: 3
9 changes: 4 additions & 5 deletions R/acceptable.R
Original file line number Diff line number Diff line change
Expand Up @@ -28,12 +28,11 @@ acceptable_formula.glm <- function(model) {
}

## As suggested by @topepo, brought in from the `pryr` package
## via the `recepies` package
## via the `recipes` package
fun_calls <- function(f) {
if (is.function(f)) {
fun_calls(body(f))
}
else if (is.call(f)) {
} else if (is.call(f)) {
fname <- as.character(f[[1]])
# Calls inside .Internal are special and shouldn't be included
if (identical(fname, ".Internal")) {
Expand All @@ -49,7 +48,7 @@ acceptable_lm <- function(model) {
contr <- model$contrasts
contr <- contr[!("contr.treatment" %in% contr)]
if (length(contr) > 0) {
stop(
cli::cli_abort(
"The treatment contrast is the only one supported at this time. Field(s) with an invalid contrast are: ",
paste0("`", names(contr), "`", collapse = ","),
call. = FALSE
Expand All @@ -63,7 +62,7 @@ acceptable_lm <- function(model) {
if (length(funs) > 0) {
contains_offset <- any(funs == "offset")
contains_other <- funs[funs != "offset"]
stop(
cli::cli_abort(
paste0(
"Functions inside the formula are not supported.",
if (contains_offset) "\n- Offset detected. Try using offset as an argument instead.",
Expand Down
4 changes: 2 additions & 2 deletions R/as-parsed-model.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
#' Prepares parsed model object
#'
#'
#' @param x A parsed model object
#'
#'
#' @export
as_parsed_model <- function(x) {
UseMethod("as_parsed_model")
Expand Down
4 changes: 2 additions & 2 deletions R/model-cubist.R
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ parse_model.cubist <- function(model) {
coefs <- model$coefficients
splits <- model$splits
splits$variable <- as.character(splits$variable)
splits$dir <- as.character(splits$dir)
splits$dir <- as.character(splits$dir)

committees2 <- map(
unique(coefs$committee),
Expand All @@ -13,7 +13,7 @@ parse_model.cubist <- function(model) {
coefs$rule[coefs$committee == comm],
~ {
cc <- coefs[coefs$rule == .x & coefs$committee == comm, ]
if(!is.null(model$splits)) {
if (!is.null(model$splits)) {
cs <- splits[splits$rule == .x & splits$committee == comm, ]
tcs <- transpose(cs)
mcs <- map(
Expand Down
Loading

0 comments on commit 103e3f5

Please sign in to comment.