Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
Merge pull request #457 from terrytangyuan/test
Browse files Browse the repository at this point in the history
[R TST] Set up R Travis Environment
  • Loading branch information
tqchen committed Nov 2, 2015
2 parents 68a25b2 + 075ca59 commit 9832672
Show file tree
Hide file tree
Showing 6 changed files with 106 additions and 3 deletions.
9 changes: 7 additions & 2 deletions .travis.yml
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
# disable sudo to use container based build
sudo: false

language: cpp
Expand All @@ -18,6 +17,7 @@ env:
- TASK=cpp_test
# run tests/python
- TASK=python_test
#- TASK=r_test

# TODO, R test, distributed test, clang, more g++ versions

Expand All @@ -27,6 +27,8 @@ matrix:
env: TASK=lint
- os: osx
env: TASK=doc
- os: linux
env: TASK=r_test

# dependent apt packages
addons:
Expand Down Expand Up @@ -67,10 +69,13 @@ cache:

before_cache:
- dmlc-core/scripts/travis/travis_before_cache.sh

after_failure:
- tests/travis/travis_after_failure.sh

notifications:
# Emails are sent to the committer's git-configured email address by default,
email:
on_success: change
on_failure: always
slack: dmlc:NmroCzntCiWOuxUZpii40USd
#slack: dmlc:NmroCzntCiWOuxUZpii40USd
2 changes: 2 additions & 0 deletions CONTRIBUTORS.md
Original file line number Diff line number Diff line change
Expand Up @@ -60,5 +60,7 @@ List of Contributors
* [Nan Xiao](https://github.com/road2stat)
* [Junyuan Xie](https://github.com/piiswrong)
* [Wei Wu](https://github.com/tornadomeet)
* [Yuan Tang](https://github.com/terrytangyuan)
- Yuan set up the R Travis environment to make development safer.
* [Michaël Benesty](https://github.com/pommedeterresautee)
-Michaël contributes the R visualization module of mxnet
7 changes: 6 additions & 1 deletion R-package/DESCRIPTION
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,12 @@ URL: https://github.com/dmlc/mxnet/R-package
BugReports: https://github.com/dmlc/mxnet/issues
Imports:
methods,
Rcpp (>= 0.11.1)
Rcpp (>= 0.11.1),
DiagrammeR,
data.table,
jsonlite,
magrittr,
stringr
Suggests:
testthat
LinkingTo: Rcpp
Expand Down
62 changes: 62 additions & 0 deletions R-package/tests/testthat/test_model.R
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
require(mxnet)

context("models")

# test_that("basic symbol operation", {
# # Network configuration
# batch.size <- 100
# data <- mx.symbol.Variable("data")
# fc1 <- mx.symbol.FullyConnected(data, name="fc1", num_hidden=128)
# act1 <- mx.symbol.Activation(fc1, name="relu1", act_type="relu")
# fc2 <- mx.symbol.FullyConnected(act1, name = "fc2", num_hidden = 64)
# act2 <- mx.symbol.Activation(fc2, name="relu2", act_type="relu")
# fc3 <- mx.symbol.FullyConnected(act2, name="fc3", num_hidden=10)
# softmax <- mx.symbol.Softmax(fc3, name = "sm")
#
# dtrain = mx.io.MNISTIter(
# image="data/train-images-idx3-ubyte",
# label="data/train-labels-idx1-ubyte",
# data.shape=c(784),
# batch.size=batch.size,
# shuffle=TRUE,
# flat=TRUE,
# silent=0,
# seed=10)
#
# dtest = mx.io.MNISTIter(
# image="data/t10k-images-idx3-ubyte",
# label="data/t10k-labels-idx1-ubyte",
# data.shape=c(784),
# batch.size=batch.size,
# shuffle=FALSE,
# flat=TRUE,
# silent=0)
#
# mx.set.seed(0)
# devices = lapply(1:2, function(i) {
# mx.cpu(i)
# })
#
# # create the model
# model <- mx.model.FeedForward.create(softmax, X=dtrain, eval.data=dtest,
# ctx=devices, num.round=1,
# learning.rate=0.1, momentum=0.9,
# initializer=mx.init.uniform(0.07),
# epoch.end.callback=mx.callback.save.checkpoint("chkpt"),
# batch.end.callback=mx.callback.log.train.metric(100))
#
# # do prediction
# pred <- predict(model, dtest)
# label <- mx.io.extract(dtest, "label")
# dataX <- mx.io.extract(dtest, "data")
# # Predict with R's array
# pred2 <- predict(model, X=dataX)
#
# accuracy <- function(label, pred) {
# ypred = max.col(t(as.array(pred)))
# return(sum((as.array(label) + 1) == ypred) / length(label))
# }
#
# print(paste0("Finish prediction... accuracy=", accuracy(label, pred)))
# print(paste0("Finish prediction... accuracy2=", accuracy(label, pred2)))
# })
24 changes: 24 additions & 0 deletions tests/travis/run_test.sh
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,30 @@ if [ ${TASK} == "cpp_test" ]; then
exit 0
fi

if [ ${TASK} == "r_test" ]; then
make all || exit -1
# use cached dir for storing data
rm -rf ${PWD}/data
mkdir -p ${CACHE_PREFIX}/data
ln -s ${CACHE_PREFIX}/data ${PWD}/data

set -e
export _R_CHECK_TIMINGS_=0
export R_BUILD_ARGS="--no-build-vignettes --no-manual"
export R_CHECK_ARGS="--no-vignettes --no-manual"

curl -OL http://raw.github.com/craigcitro/r-travis/master/scripts/travis-tool.sh
chmod 755 ./travis-tool.sh
./travis-tool.sh bootstrap
./travis-tool.sh install_aptget r-cran-testthat r-cran-Rcpp r-cran-DiagrammeR r-cran-data.table r-cran-jsonlite r-cran-magrittr r-cran-stringr

R CMD INSTALL R-package
cd ./R-package
../travis-tool.sh install_deps
../travis-tool.sh run_tests
exit 0
fi

if [ ${TASK} == "python_test" ]; then
make all || exit -1
# use cached dir for storing data
Expand Down
5 changes: 5 additions & 0 deletions tests/travis/travis_after_failure.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
#!/bin/bash

if [ ${TASK} == "r_test" ]; then
cat mxnet/mxnet.Rcheck/*.log
fi

0 comments on commit 9832672

Please sign in to comment.