Skip to content

Commit

Permalink
R-package (#208)
Browse files Browse the repository at this point in the history
* added the RGF R-package

* removed empty dir

* added submodule

* unsubmodule

* moved files in appropriate folder

* fixed DESCRIPTION FILE

* Revert "fixed DESCRIPTION FILE"

This reverts commit 561e9e7.

* I updated the DESCRIPTION file

* I updated the R package files as suggested

* I updated the R package files as suggested

* I updated the R package suggested

* I updated the R package as suggested

* I updated the R package as suggested

* I updated the R package as suggested

* I updated the R package as suggested

* I updated the R package as suggested

* I updated the R package as suggested

* I updated the R package as suggested

* I updated the R package as suggested

* added R-package test at Travis

* fixed R test at Travis

* fixed conflicts in library versions

* updated the DESCRIPTION and NEWS files

* updated the R-package files

* updated the R-package files

* fixed arxiv.org certificate error

* replaced problem link to r-pkg.org with link to package official page at cran

* fixed MinGW-w64 certificates problem

* update the R-package files
  • Loading branch information
mlampros authored and StrikerRUS committed Aug 17, 2018
1 parent 60e0b6b commit 303a787
Show file tree
Hide file tree
Showing 24 changed files with 3,235 additions and 7 deletions.
31 changes: 24 additions & 7 deletions .travis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,22 @@ os:
- osx

env:
- PYTHON_VERSION=2.7
- PYTHON_VERSION=3.4
- PYTHON_VERSION=3.5
- PYTHON_VERSION=3.6
global:
- R_LIB_PATH=~/Rlib
matrix:
- PYTHON_VERSION=2.7
- PYTHON_VERSION=3.4
- PYTHON_VERSION=3.5
- PYTHON_VERSION=3.6
- PYTHON_VERSION=3.6 TASK=R_PACKAGE

matrix:
exclude:
- os: osx
env: PYTHON_VERSION=3.6 TASK=R_PACKAGE

before_install:
- if [[ "$TRAVIS_OS_NAME" == "osx" ]]; then
- if [[ $TRAVIS_OS_NAME == "osx" ]]; then
sudo softwareupdate -i "Command Line Tools (macOS High Sierra version 10.13) for Xcode-9.3";
rm '/usr/local/include/c++';
brew install gcc;
Expand All @@ -39,21 +48,25 @@ before_install:
- RGF_VER=$(head -n 1 python-package/rgf/VERSION)

install:
- cd python-package
- cd $TRAVIS_BUILD_DIR/python-package
- python setup.py sdist --formats gztar
- pip install dist/rgf_python-$RGF_VER.tar.gz -v

script:
- pytest tests/ -v
- if [[ $TASK == "R_PACKAGE" ]]; then
bash $TRAVIS_BUILD_DIR/R-package/.R.travis.sh;
fi

before_deploy:
- cd $TRAVIS_BUILD_DIR/python-package
- if [[ $TRAVIS_OS_NAME == "osx" ]]; then
python setup.py bdist_wheel --plat-name=any --universal;
mv dist/rgf_python-${RGF_VER}-py2.py3-none-any.whl dist/rgf_python-${RGF_VER}-py2.py3-none-macosx_10_6_x86_64.macosx_10_7_x86_64.macosx_10_8_x86_64.macosx_10_9_x86_64.macosx_10_10_x86_64.macosx_10_11_x86_64.macosx_10_12_x86_64.macosx_10_13_x86_64.whl;
else
python setup.py bdist_wheel --plat-name=manylinux1_x86_64 --universal;
python setup.py bdist_wheel --plat-name=manylinux1_i686 --universal;
cd dist;
cd $TRAVIS_BUILD_DIR/python-package/dist;
zip -d rgf_python-${RGF_VER}-py2.py3-none-manylinux1_i686.whl rgf/rgf rgf/forest_train rgf/forest_predict;
mkdir rgf;
wget https://github.com/RGF-team/rgf/releases/download/3.2.0/rgf -O rgf/rgf;
Expand All @@ -66,6 +79,10 @@ before_deploy:
notifications:
email: false

cache:
directories:
- $R_LIB_PATH

deploy:
file_glob: true
file: python-package/dist/*.whl
Expand Down
60 changes: 60 additions & 0 deletions R-package/.R.travis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
mkdir -p $R_LIB_PATH
cd $TRAVIS_BUILD_DIR/R-package
echo "R_LIBS=$R_LIB_PATH" > .Renviron
echo 'options(repos = "https://cran.rstudio.com")' > .Rprofile

export PATH="$R_LIB_PATH/R/bin:$PATH"

sudo apt-get install gfortran-5
sudo update-alternatives --install /usr/bin/gfortran gfortran /usr/bin/gfortran-5 10
# use system-wide libraries (fix error "symbol _ZTINSt8ios_base7failureB5cxx11E, version GLIBCXX_3.4.21 not defined in file libstdc++.so.6 with link time reference")
conda remove --force libgfortran-ng libgcc-ng libstdcxx-ng

# install packages to build and check documentation
conda install --no-deps pandoc
sudo apt-get install texlive-latex-recommended texlive-fonts-recommended texlive-fonts-extra qpdf

# fix "libcurl error code 60: server certificate verification failed. CAfile: /etc/ssl/certs/ca-certificates.crt CRLfile: none"
echo -n | openssl s_client -connect arxiv.org:443 2>/dev/null | sed -ne '/-BEGIN CERTIFICATE-/,/-END CERTIFICATE-/p' | sudo tee -a /etc/ssl/certs/ca-certificates.crt

if ! command -v R &> /dev/null; then
R_VER=3.5.1
cd $TRAVIS_BUILD_DIR
wget https://cran.r-project.org/src/base/R-3/R-$R_VER.tar.gz
tar -xzf R-$R_VER.tar.gz
R-$R_VER/configure --enable-R-shlib --prefix=$R_LIB_PATH/R
make
make install
cd $TRAVIS_BUILD_DIR/R-package
fi

Rscript -e 'if(!"devtools" %in% rownames(installed.packages())) { install.packages("devtools", dependencies = TRUE) }'
Rscript -e 'if(!"roxygen2" %in% rownames(installed.packages())) { install.packages("roxygen2", dependencies = TRUE) }'
Rscript -e 'if(!"testthat" %in% rownames(installed.packages())) { install.packages("testthat", dependencies = TRUE) }'
Rscript -e 'if(!"knitr" %in% rownames(installed.packages())) { install.packages("knitr", dependencies = TRUE) }'
Rscript -e 'if(!"covr" %in% rownames(installed.packages())) { install.packages("covr", dependencies = TRUE) }'
Rscript -e 'if(!"rmarkdown" %in% rownames(installed.packages())) { install.packages("rmarkdown", dependencies = TRUE) }'
Rscript -e 'if(!"reticulate" %in% rownames(installed.packages())) { install.packages("reticulate", dependencies = TRUE) }'
Rscript -e 'if(!"R6" %in% rownames(installed.packages())) { install.packages("R6", dependencies = TRUE) }'
Rscript -e 'if(!"Matrix" %in% rownames(installed.packages())) { install.packages("Matrix", dependencies = TRUE) }'

Rscript -e 'update.packages(ask = FALSE, instlib = Sys.getenv("R_LIB_PATH"))'

Rscript -e 'devtools::install_deps(pkg = ".", dependencies = TRUE)'

R CMD build . || exit -1

PKG_FILE_NAME=$(ls -1t *.tar.gz | head -n 1)
PKG_NAME="${PKG_FILE_NAME%%_*}"
LOG_FILE_NAME="$PKG_NAME.Rcheck/00check.log"

R CMD check "${PKG_FILE_NAME}" --as-cran || exit -1
if grep -q -R "WARNING" "$LOG_FILE_NAME"; then
echo "WARNINGS have been found in the build log!"
exit -1
#elif grep -q -R "NOTE" "$LOG_FILE_NAME"; then
# echo "NOTES have been found in the build log!"
# exit -1
fi

Rscript -e 'covr::codecov(quiet = FALSE)'
1 change: 1 addition & 0 deletions R-package/.Rbuildignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
^\.R\.travis\.sh$
4 changes: 4 additions & 0 deletions R-package/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
.Rproj.user
.Rhistory
.RData
.Ruserdata
25 changes: 25 additions & 0 deletions R-package/DESCRIPTION
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
Package: RGF
Type: Package
Title: Regularized Greedy Forest
Version: 1.0.5
Date: 2018-08-15
Authors@R: c( person("Lampros", "Mouselimis", email = "mouselimislampros@gmail.com", role = c("aut", "cre")), person("Ryosuke", "Fukatani", role = "cph", comment = "Author of the python wrapper of the 'Regularized Greedy Forest' machine learning algorithm"), person("Nikita", "Titov", role = "cph", comment = "Author of the python wrapper of the 'Regularized Greedy Forest' machine learning algorithm"), person("Tong", "Zhang", role = "cph", comment = "Author of the 'Regularized Greedy Forest' and of the Multi-core implementation of Regularized Greedy Forest machine learning algorithm"), person("Rie", "Johnson", role = "cph", comment = "Author of the 'Regularized Greedy Forest' machine learning algorithm") )
Maintainer: Lampros Mouselimis <mouselimislampros@gmail.com>
BugReports: https://github.com/RGF-team/rgf/issues
URL: https://github.com/RGF-team/rgf/tree/master/R-package
Description: Regularized Greedy Forest wrapper of the 'Regularized Greedy Forest' <https://github.com/RGF-team/rgf/tree/master/python-package> 'python' package, which also includes a Multi-core implementation (FastRGF) <https://github.com/RGF-team/rgf/tree/master/FastRGF>.
License: MIT + file LICENSE
SystemRequirements: Python (2.7 or >= 3.4), rgf_python, scikit-learn (>= 0.18.0), scipy, numpy. Detailed installation instructions for each operating system can be found in the README file.
Depends:
R(>= 3.2.3)
Imports:
reticulate, R6, Matrix
Suggests:
testthat,
covr,
knitr,
rmarkdown
Encoding: UTF-8
LazyData: true
RoxygenNote: 6.0.1
VignetteBuilder: knitr
2 changes: 2 additions & 0 deletions R-package/LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
YEAR: 2018
COPYRIGHT HOLDER: Mouselimis Lampros <mouselimislampros@gmail.com>
24 changes: 24 additions & 0 deletions R-package/LICENSE.note
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Regularized Greedy Forest (RGF)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


See file COPYING: https://github.com/RGF-team/rgf/blob/master/RGF/COPYING



#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Fast Regularized Greedy Forest (FastRGF)
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


See file LICENSE: https://github.com/RGF-team/rgf/blob/master/FastRGF/LICENSE



#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
# Python wrapper of RGF and FastRGF
#~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


See file LICENSE: https://github.com/RGF-team/rgf/blob/master/python-package/LICENSE
10 changes: 10 additions & 0 deletions R-package/NAMESPACE
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
export(RGF_cleanup_temp_files)
export(mat_2scipy_sparse)
export(TO_scipy_sparse)
export(RGF_Regressor)
export(RGF_Classifier)
export(FastRGF_Regressor)
export(FastRGF_Classifier)
import(reticulate)
importFrom(R6,R6Class)
importFrom(Matrix,Matrix)
33 changes: 33 additions & 0 deletions R-package/NEWS.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
## RGF 1.0.5

The RGF R package was integrated in the home repository for the Regularized Greedy Forest (RGF) library (https://github.com/RGF-team).


## RGF 1.0.4

* We modified the license from GPL-3 to MIT to go in accordance with the new structure of the *rgf_python* package. The package includes two files : *LICENSE* (for the RGF R package) and *LICENSE.note* (for the *RGF*, *FastRGF* and *rgf_python* packages).
* We added the following new features of RGF estimators : *feature_importances_* and *dump_model()*
* We modified the README.md file and especially the installation instructions for all operating systems (Linux, Mac OS X, Windows)
* We created an R6 class (*Internal_class*) for all secondary functions which are used in RGF and FastRGF


## RGF 1.0.3

* The *dgCMatrix_2scipy_sparse* function was renamed to *TO_scipy_sparse* and now accepts either a *dgCMatrix* or a *dgRMatrix* as input. The appropriate format for the RGF package in case of sparse matrices is the *dgCMatrix* format (*scipy.sparse.csc_matrix*)
* We added an onload.R file to inform the users about the previous change
* Due to the previous changes we modified the Vignette and the tests too


## RGF 1.0.2

We commented the example(s) and test(s) related to the *dgCMatrix_2scipy_sparse* function [ *if (Sys.info()["sysname"] != 'Darwin')* ], because the *scipy-sparse* library on CRAN is not upgraded and the older version includes a bug (*TypeError : could not interpret data type*). This leads to an error on *Mac OS X* ( *reference* : https://github.com/scipy/scipy/issues/5353 ).


## RGF 1.0.1

We added links to the GitHub repository (master repository, issues).


## RGF 1.0.0

Initial version.
28 changes: 28 additions & 0 deletions R-package/R/package.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
#-------------------------
# Load the python-modules
#-------------------------


RGF_mod <- NULL; RGF_utils <- NULL; SCP <- NULL;


.onLoad <- function(libname, pkgname) {

if (reticulate::py_available(initialize = TRUE)) {

if (reticulate::py_module_available("rgf.sklearn")) {

RGF_mod <<- reticulate::import("rgf.sklearn", delay_load = TRUE)
}

if (reticulate::py_module_available("rgf.utils")) {

RGF_utils <<- reticulate::import("rgf.utils", delay_load = TRUE)
}

if (reticulate::py_module_available("scipy")) {

SCP <<- reticulate::import("scipy", delay_load = TRUE, convert = FALSE)
}
}
}
Loading

0 comments on commit 303a787

Please sign in to comment.