Skip to content

Commit

Permalink
[R] AppVeyor CI for R package (dmlc#2954)
Browse files Browse the repository at this point in the history
* [R] fix finding R.exe with cmake on WIN when it is in PATH

* [R] appveyor config for R package

* [R] wrap the lines to make R check happier

* [R] install only binary dep-packages in appveyor

* [R] for MSVC appveyor, also build a binary for R package and keep as an artifact
  • Loading branch information
khotilov authored Dec 17, 2017
1 parent 4fa917b commit 76f8f51
Show file tree
Hide file tree
Showing 5 changed files with 85 additions and 9 deletions.
9 changes: 6 additions & 3 deletions R-package/R/xgb.plot.shap.R
Original file line number Diff line number Diff line change
Expand Up @@ -93,9 +93,12 @@
#' objective = "multi:softprob", num_class = nclass, verbose = 0)
#' trees0 <- seq(from=0, by=nclass, length.out=nrounds)
#' col <- rgb(0, 0, 1, 0.5)
#' xgb.plot.shap(x, model = mbst, trees = trees0, target_class = 0, top_n = 4, n_col = 2, col = col, pch = 16, pch_NA = 17)
#' xgb.plot.shap(x, model = mbst, trees = trees0 + 1, target_class = 1, top_n = 4, n_col = 2, col = col, pch = 16, pch_NA = 17)
#' xgb.plot.shap(x, model = mbst, trees = trees0 + 2, target_class = 2, top_n = 4, n_col = 2, col = col, pch = 16, pch_NA = 17)
#' xgb.plot.shap(x, model = mbst, trees = trees0, target_class = 0, top_n = 4,
#' n_col = 2, col = col, pch = 16, pch_NA = 17)
#' xgb.plot.shap(x, model = mbst, trees = trees0 + 1, target_class = 1, top_n = 4,
#' n_col = 2, col = col, pch = 16, pch_NA = 17)
#' xgb.plot.shap(x, model = mbst, trees = trees0 + 2, target_class = 2, top_n = 4,
#' n_col = 2, col = col, pch = 16, pch_NA = 17)
#'
#' @rdname xgb.plot.shap
#' @export
Expand Down
9 changes: 6 additions & 3 deletions R-package/man/xgb.plot.shap.Rd

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

64 changes: 64 additions & 0 deletions appveyor.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
environment:
R_ARCH: x64
USE_RTOOLS: true
matrix:
- target: msvc
ver: 2013
Expand All @@ -15,6 +17,15 @@ environment:
- target: mingw
generator: "Unix Makefiles"
- target: jvm
- target: rmsvc
ver: 2015
generator: "Visual Studio 14 2015 Win64"
configuration: Release
- target: rmingw
generator: "Unix Makefiles"

#matrix:
# fast_finish: true

platform:
- x64
Expand All @@ -34,6 +45,16 @@ install:
- if /i "%target%" == "mingw" set DO_PYTHON=on
- if /i "%target%_%ver%_%configuration%" == "msvc_2015_Release" set DO_PYTHON=on
- if /i "%DO_PYTHON%" == "on" conda install -y numpy scipy pandas matplotlib nose scikit-learn graphviz python-graphviz
# R: based on https://github.com/krlmlr/r-appveyor
- ps: |
if($env:target -eq 'rmingw' -or $env:target -eq 'rmsvc') {
#$ErrorActionPreference = "Stop"
Invoke-WebRequest http://raw.github.com/krlmlr/r-appveyor/master/scripts/appveyor-tool.ps1 -OutFile "$Env:TEMP\appveyor-tool.ps1"
Import-Module "$Env:TEMP\appveyor-tool.ps1"
Bootstrap
$DEPS = "c('data.table','magrittr','stringi','ggplot2','DiagrammeR','Ckmeans.1d.dp','vcd','testthat','igraph','knitr','rmarkdown')"
cmd /c "R.exe -q -e ""install.packages($DEPS, repos='$CRAN', type='win.binary')"" 2>&1"
}
build_script:
- cd %APPVEYOR_BUILD_FOLDER%
Expand All @@ -49,12 +70,55 @@ build_script:
cmake .. -G"%generator%" &&
make -j2
)
# Python package
- if /i "%DO_PYTHON%" == "on" (
cd %APPVEYOR_BUILD_FOLDER%\python-package &&
python setup.py install
)
# R package: make + mingw standard CRAN packaging (only x64 for now)
- if /i "%target%" == "rmingw" (
make Rbuild &&
ls -l &&
R.exe CMD INSTALL --no-multiarch xgboost*.tar.gz
)
# R package: cmake + VC2015
- if /i "%target%" == "rmsvc" (
mkdir build_rmsvc%ver% &&
cd build_rmsvc%ver% &&
cmake .. -G"%generator%" -DCMAKE_CONFIGURATION_TYPES="Release" -DR_LIB=ON &&
cmake --build . --target install --config Release
)
- if /i "%target%" == "jvm" cd jvm-packages && mvn test -pl :xgboost4j

test_script:
- cd %APPVEYOR_BUILD_FOLDER%
- if /i "%DO_PYTHON%" == "on" python -m nose tests/python
# mingw R package: run the R check (which includes unit tests), and also keep the built binary package
- if /i "%target%" == "rmingw" (
set _R_CHECK_CRAN_INCOMING_=FALSE&&
R.exe CMD check xgboost*.tar.gz --no-manual --no-build-vignettes --as-cran --install-args=--build --no-multiarch
)
# MSVC R package: run only the unit tests
# TODO: create a binary msvc-built package to keep as an artifact
- if /i "%target%" == "rmsvc" (
cd build_rmsvc%ver%\R-package &&
R.exe -q -e "library(testthat); setwd('tests'); source('testthat.R')"
)

on_failure:
# keep the whole output of R check
- if /i "%target%" == "rmingw" (
7z a failure.zip *.Rcheck\* &&
appveyor PushArtifact failure.zip
)

artifacts:
# log from R check
- path: '*.Rcheck\**\*.log'
name: Logs
# source R-package
- path: '\xgboost_*.tar.gz'
name: Bits
# binary R-package
- path: '**\xgboost_*.zip'
name: Bits
2 changes: 1 addition & 1 deletion cmake/Utils.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -82,5 +82,5 @@ function(setup_rpackage_install_target rlib_target build_dir)
if(length(deps)>0) install.packages(deps, repo = 'https://cloud.r-project.org/')")
install(CODE "execute_process(COMMAND \"${LIBR_EXECUTABLE}\" \"-q\" \"-e\" \"${XGB_DEPS_SCRIPT}\")")
install(CODE "execute_process(COMMAND \"${LIBR_EXECUTABLE}\" CMD INSTALL\
\"--no-multiarch\" \"${build_dir}/R-package\")")
\"--no-multiarch\" \"--build\" \"${build_dir}/R-package\")")
endfunction(setup_rpackage_install_target)
10 changes: 8 additions & 2 deletions cmake/modules/FindLibR.cmake
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ else()

# attempt to find R executable
if(NOT LIBR_EXECUTABLE)
find_program(LIBR_EXECUTABLE R)
find_program(LIBR_EXECUTABLE NAMES R R.exe)
endif()

if(UNIX)
Expand Down Expand Up @@ -117,7 +117,7 @@ else()
# ask R for R_HOME
if(LIBR_EXECUTABLE)
execute_process(
COMMAND ${LIBR_EXECUTABLE} "--slave" "--no-save" "-e" "cat(normalizePath(R.home(), winslash='/')"
COMMAND ${LIBR_EXECUTABLE} "--slave" "--no-save" "-e" "cat(normalizePath(R.home(), winslash='/'))"
OUTPUT_VARIABLE LIBR_HOME)
endif()
# if R executable not available, query R_HOME path from registry
Expand All @@ -138,6 +138,12 @@ else()
set(LIBR_INCLUDE_DIRS "${LIBR_HOME}/include")
set(LIBR_LIB_DIR "${LIBR_HOME}/bin/${R_ARCH}")

message(STATUS "LIBR_HOME [${LIBR_HOME}]")
message(STATUS "LIBR_EXECUTABLE [${LIBR_EXECUTABLE}]")
message(STATUS "LIBR_INCLUDE_DIRS [${LIBR_INCLUDE_DIRS}]")
message(STATUS "LIBR_LIB_DIR [${LIBR_LIB_DIR}]")
message(STATUS "LIBR_CORE_LIBRARY [${LIBR_CORE_LIBRARY}]")

endif()

endif()
Expand Down

0 comments on commit 76f8f51

Please sign in to comment.