Skip to content

Commit

Permalink
Get master up to date with the version on cran (#334)
Browse files Browse the repository at this point in the history
  • Loading branch information
martinju authored Jun 1, 2023
1 parent c2d0a11 commit b96f5c1
Show file tree
Hide file tree
Showing 17 changed files with 101 additions and 84 deletions.
3 changes: 3 additions & 0 deletions .Rbuildignore
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,7 @@ inst/compare_lundberg\.xgb\.obj
^Meta$
^_pkgdown\.yml$
^pkgdown$
[.]Rout$
[.]out$
^CRAN-SUBMISSION$
^.Rprofile
49 changes: 20 additions & 29 deletions .github/workflows/R-CMD-check.yaml
Original file line number Diff line number Diff line change
@@ -1,19 +1,21 @@
# Nov 11th, 2021: THIS IS A MODIFIED VERSION OF THE check-full VERSION AS DESCRIBED BELOW
# IT ADDS cranversion TO THE LIST OF BRANCHES TO RUN ON AND REDUCED THE NUMBER OF CONFIGS, OTHERWISE IDENTICAL
# July 5th, 2022: This is a modifided version of the 'check-standard' version from
# https://github.com/r-lib/actions/tree/v2/examples#standard-ci-workflow

# Workflow derived from https://github.com/r-lib/actions/tree/master/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
# check-standard.yaml is likely a better choice.
# usethis::use_github_action("check-standard") will install it.
# The following is modified:

# 1. Runs on branches cranversion and devel as well
# 2. Runs on oldrel-2 as well
# 3. R CMD check is performed WITHOUT the default as-cran flag. This allows snapshots to run without setting
# as-cran=TRUE in every single call to expect_snapshot

# 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:
branches: [main, master, cranversion]
branches: [main, master, cranversion, devel]
pull_request:
branches: [main, master, cranversion]
branches: [main, master, cranversion, devel]

name: R-CMD-check

Expand All @@ -28,14 +30,11 @@ jobs:
matrix:
config:
- {os: macOS-latest, r: 'release'}

- {os: windows-latest, r: 'release'}

- {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'}
# - {os: ubuntu-latest, r: 'oldrel-3'}

env:
GITHUB_PAT: ${{ secrets.GITHUB_TOKEN }}
Expand All @@ -44,28 +43,20 @@ jobs:
steps:
- uses: actions/checkout@v2

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

- uses: r-lib/actions/setup-r@v1
- 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@v1
- uses: r-lib/actions/setup-r-dependencies@v2
with:
extra-packages: rcmdcheck

- uses: r-lib/actions/check-r-package@v1

- name: Show testthat output
if: always()
run: find check -name 'testthat.Rout*' -exec cat '{}' \; || true
shell: bash
extra-packages: any::rcmdcheck
needs: check

- name: Upload check results
if: failure()
uses: actions/upload-artifact@main
- uses: r-lib/actions/check-r-package@v2
with:
name: ${{ runner.os }}-r${{ matrix.config.r }}-results
path: check
args: 'c("--no-manual")' # I.e. exclude the as-cran comment here
upload-snapshots: true
2 changes: 2 additions & 0 deletions CRAN-RELEASE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
This package was submitted to CRAN on 2021-01-27.
Once it is accepted, delete this file and tag the release (commit 703b477).
3 changes: 3 additions & 0 deletions CRAN-SUBMISSION
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Version: 0.2.2
Date: 2023-05-04 12:59:55 UTC
SHA: c046e1c3cc967c6cefcfdc1e4b2510f29c17d254
4 changes: 2 additions & 2 deletions DESCRIPTION
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
Package: shapr
Version: 0.2.0.9002
Version: 0.2.2
Title: Prediction Explanation with Dependence-Aware Shapley Values
Description: Complex machine learning models are often hard to interpret. However, in
many situations it is crucial to understand and explain why a model made a specific
Expand All @@ -24,7 +24,7 @@ Encoding: UTF-8
LazyData: true
ByteCompile: true
Language: en-US
RoxygenNote: 7.1.2
RoxygenNote: 7.2.3
Depends: R (>= 3.5.0)
Imports:
stats,
Expand Down
1 change: 1 addition & 0 deletions NAMESPACE
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ S3method(explain,ctree_comb_mincrit)
S3method(explain,empirical)
S3method(explain,gaussian)
S3method(explain,independence)
S3method(get_model_specs,default)
S3method(get_model_specs,gam)
S3method(get_model_specs,glm)
S3method(get_model_specs,lm)
Expand Down
10 changes: 10 additions & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,16 @@
computed both feature-wise and group-wise
* Fixed bug when passing non-named data to shapr() or explain() (e.g. ```shapr(data[,1:5],model...)```

# shapr 0.2.2

* Patch to fix failing CRAN-tests on R-devel due to changed behavior of `attach()`: Fixed by changing how we simluate adding a function to .GlobalEnv in the failing test. Actual package not affected.

# shapr 0.2.1

* Patch to fix warning from development version of data.table due to the use of nomatch argument in merge(),
as requested from [data.table developers](https://github.com/NorskRegnesentral/shapr/issues/322).


# shapr 0.2.0

* Minor CRAN release
Expand Down
3 changes: 2 additions & 1 deletion R/models.R
Original file line number Diff line number Diff line change
Expand Up @@ -347,6 +347,7 @@ get_model_specs <- function(x) {
}

#' @rdname get_model_specs
#' @export
get_model_specs.default <- function(x) {

# For custom models where there is no
Expand Down Expand Up @@ -464,7 +465,7 @@ get_supported_models <- function() {
DT_predict_model[, predict_model := 1]
DT_predict_model[, c("visible", "from", "generic", "isS4") := NULL]

DT <- merge(DT_get_model_specs, DT_predict_model, by = "rn", all = T, allow.cartesian = T, nomatch = 0)
DT <- merge(DT_get_model_specs, DT_predict_model, by = "rn", all = T, allow.cartesian = T)
DT[, (colnames(DT)[-1]) := lapply(.SD, data.table::nafill, fill = 0), .SDcols = colnames(DT)[-1]]
DT[, (colnames(DT)[2:3]) := lapply(.SD, as.logical), .SDcols = colnames(DT)[2:3]]
data.table::setnames(DT, "rn", "model_class")
Expand Down
2 changes: 1 addition & 1 deletion README.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ knitr::opts_chunk$set(
[![CRAN_Downloads_Badge](https://cranlogs.r-pkg.org/badges/grand-total/shapr)](https://cran.r-project.org/package=shapr)
[![R build status](https://github.com/NorskRegnesentral/shapr/workflows/R-CMD-check/badge.svg)](https://github.com/NorskRegnesentral/shapr/actions?query=workflow%3AR-CMD-check)
[![Lifecycle: experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
[![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/license/mit/)
[![DOI](https://joss.theoj.org/papers/10.21105/joss.02027/status.svg)](https://doi.org/10.21105/joss.02027)
<!-- badges: end -->

Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ status](https://github.com/NorskRegnesentral/shapr/workflows/R-CMD-check/badge.s
[![Lifecycle:
experimental](https://img.shields.io/badge/lifecycle-experimental-orange.svg)](https://lifecycle.r-lib.org/articles/stages.html)
[![License:
MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/licenses/MIT)
MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](https://opensource.org/license/mit/)
[![DOI](https://joss.theoj.org/papers/10.21105/joss.02027/status.svg)](https://doi.org/10.21105/joss.02027)
<!-- badges: end -->

Expand Down Expand Up @@ -182,12 +182,14 @@ explanation <- explain(
# For more information about the interpretation of the values in the table, see ?shapr::explain.
print(explanation$dt)
#> none lstat rm dis indus
#> <num> <num> <num> <num> <num>
#> 1: 22.446 5.2632030 -1.2526613 0.2920444 4.5528644
#> 2: 22.446 0.1671901 -0.7088401 0.9689005 0.3786871
#> 3: 22.446 5.9888022 5.5450858 0.5660134 -1.4304351
#> 4: 22.446 8.2142204 0.7507572 0.1893366 1.8298304
#> 5: 22.446 0.5059898 5.6875103 0.8432238 2.2471150
#> 6: 22.446 1.9929673 -3.6001958 0.8601984 3.1510531

# Finally we plot the resulting explanations
plot(explanation)
```
Expand Down
88 changes: 47 additions & 41 deletions cran-comments.md
Original file line number Diff line number Diff line change
@@ -1,59 +1,65 @@

# Minor release, shapr 0.2.0
# Patch release, shapr 0.2.2

* Adds the ctree approach from new paper
* Simplified supported for custom models
* Adds comprehensive check suite for feature consistency
* Patch to fix failing CRAN-tests on R-devel due to changed behavior of `attach()`: Fixed by changing how we simluate adding a function to .GlobalEnv in the failing test. Actual package not affected.
* Exports also get_model_specs.default as per the following NOTE from initial CRAN submission 'Apparent methods for exported generics not registered: get_model_specs.default'

## Test environments

* GitHub Actions (windows-latest): R 4.0
* GitHub Actions (ubuntu-16.04): R 4.0, 3.6, 3.5
* GitHub Actions (macOS-latest): R-release, 4.0
* win-builder (x86_64-w64-mingw32): R 4.0, 3.6, R-devel
* local Ubuntu 18.04: R 3.6
* local Windows 10: R 4.0
* R-hub (windows-x86_64-devel): R-devel
* R-hub (macos-highsierra-release-cran): R-release
### With data.table from github master installed, data.table::update_dev_pkg()

* local Ubuntu 18.04: R 3.6 (without packages in Suggests):
```devtools::check(vignettes = FALSE, env_vars=c(`_R_CHECK_DEPENDS_ONLY_` = "true"))```
* local Windows 10: R-devel (4.4.0)

### With cran version of data.table:

* GitHub Actions (ubuntu-latest), R-version: devel, release, oldrel-1, oldrel-2
* GitHub Actions (windows-latest), R-version: release
* GitHub Actions (macOS-latest), R-version: release
* win-builder, R-version: devel, release
* R-hub (Fedora Linux): R-version: devel
* R-hub (Windows server 2022): R-version: devel

## R CMD check results

There were no ERRORs or WARNINGs.
There were no ERRORs or WARNINGs

There were 5 NOTES

### NOTE 1 (on GitHub action, ubuntu-latest):

* checking installed package size ... NOTE
installed size is 5.0Mb
sub-directories of 1Mb or more:
libs 4.0Mb

> Nothing has changed since the last submission.
### NOTE 2 (on R-hub (Fedora Linux)):

* checking HTML version of manual ... NOTE
Skipping checking HTML validation: no command 'tidy' found
Skipping checking math rendering: package 'V8' unavailable

There was 2 NOTES
> Missing packages on R-hubs Windows Server 2022 platform.
*NOTE 1 (on local Windows 10: R 4.0):
### NOTE 4 (on R-hub (Fedora Linux, Windows Server 2022)):

Note: information on .o files for i386 is not available
Note: information on .o files for x64 is not available
File 'C:/Users/jullum/Dropbox/Local_work/Git/shapr.Rcheck/shapr/libs/i386/shapr.dll':
Found '_exit', possibly from '_exit' (C)
Found 'abort', possibly from 'abort' (C), 'runtime' (Fortran)
Found 'exit', possibly from 'exit' (C), 'stop' (Fortran)
Found 'printf', possibly from 'printf' (C)
File 'C:/Users/jullum/Dropbox/Local_work/Git/shapr.Rcheck/shapr/libs/x64/shapr.dll':
Found '_exit', possibly from '_exit' (C)
Found 'abort', possibly from 'abort' (C), 'runtime' (Fortran)
Found 'exit', possibly from 'exit' (C), 'stop' (Fortran)
Found 'printf', possibly from 'printf' (C)

Compiled code should not call entry points which might terminate R nor
write to stdout/stderr instead of to the console, nor use Fortran I/O
nor system RNGs. The detected symbols are linked into the code but
might come from libraries and not actually be called.

See 'Writing portable packages' in the 'Writing R Extensions' manual.
*Found the following (possibly) invalid URLs:
URL: https://opensource.org/license/mit/
From: README.md
Status: 403
Message: Forbidden

> I believe this is a false-positive ref https://stackoverflow.com/questions/64402688/information-on-o-files-for-x64-is-not-available-note-on-r-package-checks-using
> I believe this is a false positive. Running 'urlchecker::url_check()' locally shows all URLs are correct.
*NOTE 2 (on all winbuilder + R-hub servers)
### NOTE 5 (on R-hub (Windows Server 2022)):

Days since last update: 6
* checking for detritus in the temp directory ... NOTE
Found the following files/directories:
'lastMiKTeXException'

> The previous release was a basic patch after the package was taken off CRAN. This is a proper release with new features.
> As noted in [R-hub issue #503](https://github.com/r-hub/rhub/issues/503), this could be due to a bug/crash in MiKTeX and can likely be ignored.
## Downstream dependencies
There are currently no downstream dependencies for this package.
There is 1 downstream dependency (PPtreeregViz) of shapr
I have also run R CMD check on that and it passed without errors, warnings or notes.
Binary file modified man/figures/README-basic_example-1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
1 change: 0 additions & 1 deletion src/Makevars
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
CXX_STD = CXX11
PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
1 change: 0 additions & 1 deletion src/Makevars.win
Original file line number Diff line number Diff line change
@@ -1,3 +1,2 @@
CXX_STD = CXX11
PKG_CXXFLAGS = $(SHLIB_OPENMP_CXXFLAGS)
PKG_LIBS = $(SHLIB_OPENMP_CXXFLAGS) $(LAPACK_LIBS) $(BLAS_LIBS) $(FLIBS)
2 changes: 1 addition & 1 deletion tests/testthat/test-a-shapley.R
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
context("test-shapley.R")

RNGversion(vstr = "3.5.0")
suppressWarnings(RNGversion(vstr = "3.5.0"))

test_that("Basic test functions in shapley.R", {

Expand Down
2 changes: 1 addition & 1 deletion tests/testthat/test-explanation.R
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
context("test-explanation.R")

# For using same Random numer generator as CircelCI (R version 3.5.x)
RNGversion(vstr = "3.5.0")
suppressWarnings(RNGversion(vstr = "3.5.0"))

test_that("Test get_list_approaches", {
m <- 4
Expand Down
10 changes: 5 additions & 5 deletions tests/testthat/test-models.R
Original file line number Diff line number Diff line change
Expand Up @@ -457,16 +457,16 @@ test_that("Test missing colnames", {
test_that("Test get_supported_models", {
org_models <- get_supported_models()

# Simulate adding to .GlobalEnv
globalfun_1 <- list(get_model_specs.test = function() 1)
attach(globalfun_1)
# Adding to .GlobalEnv
get_model_specs.test <<- function() 1

new_models <- get_supported_models()

# Removin form .GlobalEnv
rm("get_model_specs.test",pos = ".GlobalEnv")

expect_false("test" %in% org_models$model_class)
expect_true("test" %in% new_models$model_class)

detach(globalfun_1) # Sets search path back
})

test_that("Test get_model_specs", {
Expand Down

0 comments on commit b96f5c1

Please sign in to comment.