Skip to content

Commit

Permalink
update: rel path names solved, simpler autoGen RUnits
Browse files Browse the repository at this point in the history
  • Loading branch information
spennihana committed Nov 27, 2013
1 parent 25eb0cf commit 2da1443
Show file tree
Hide file tree
Showing 254 changed files with 4,570 additions and 3,044 deletions.
20 changes: 11 additions & 9 deletions R/h2oRClient-package/R/Internal.R
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@ h2o.__changeCommandLog <- function(path) {
cmd <- paste(path, 'commands.log', sep='/')
assign("h2o.__LOG_COMMAND", cmd, envir = pkg.env)
}
h2o.__changeErrorLog <- function(path) {
cmd <- paste(path, 'errors.log', sep='/')
h2o.__changeErrorLog <- function(path) {
cmd <- paste(path, 'errors.log', sep='/')
assign("h2o.__LOG_ERROR", cmd, envir = pkg.env)
}
h2o.__startLogging <- function() { assign("IS_LOGGING", TRUE, envir = pkg.env) }
Expand All @@ -39,15 +39,17 @@ h2o.__openErrLog <- function() {
}

h2o.__logIt<-
function(url, tmp, commandOrErr) {
if(is.null(tmp)) s <- url
function(m, tmp, commandOrErr) {
#m is a url if commandOrErr == "Command"
if(is.null(tmp)) s <- m
else {
tmp <- get("tmp"); nams = names(tmp)
s <- rep(" ", length(tmp))
for(i in seq_along(tmp))
s[i] <- paste(nams[i], ": ", tmp[[i]], sep="")
s <- paste(url, '\t', paste(s, collapse=", "))
tmp <- get("tmp"); nams = names(tmp)
s <- rep(" ", length(tmp))
for(i in seq_along(tmp))
s[i] <- paste(nams[i], ": ", tmp[[i]], sep="")
s <- paste(m, ' \t', paste(s, collapse=", "))
}
if (commandOrErr != "Command") s <- paste(s, '\n')
write(s, file = ifelse(commandOrErr == "Command", pkg.env$h2o.__LOG_COMMAND, pkg.env$h2o.__LOG_ERROR), append = TRUE)
}

Expand Down
113 changes: 64 additions & 49 deletions R/tests/Utils/h2oR.R
Original file line number Diff line number Diff line change
@@ -1,74 +1,89 @@
options(echo=FALSE)

read.zip <- function(zipfile, exdir,header=T) {
zipdir <- exdir
unzip(zipfile, exdir=zipdir)
files <- list.files(zipdir)
file <- paste(zipdir, files[1], sep="/")
read.csv(file,header=header)
read.zip<-
function(zipfile, exdir,header=T) {
zipdir <- exdir
unzip(zipfile, exdir=zipdir)
files <- list.files(zipdir)
file <- paste(zipdir, files[1], sep="/")
read.csv(file,header=header)
}

remove_exdir <- function(exdir) {
exec <- paste("rm -r ", exdir, sep="")
system(exec)
remove_exdir<-
function(exdir) {
exec <- paste("rm -r ", exdir, sep="")
system(exec)
}

sandbox<-
function() {
unlink("./sandbox", TRUE)
dir.create("./sandbox")
h2o.__LOG_COMMAND <- "./sandbox/"
h2o.__LOG_ERROR <- "./sandbox/"
h2o.__changeCommandLog(normalizePath(h2o.__LOG_COMMAND))
h2o.__changeErrorLog(normalizePath(h2o.__LOG_ERROR))
h2o.__startLogging()
unlink("./Rsandbox", TRUE)
dir.create("./Rsandbox")
h2o.__LOG_COMMAND <- "./Rsandbox/"
h2o.__LOG_ERROR <- "./Rsandbox/"
h2o.__changeCommandLog(normalizePath(h2o.__LOG_COMMAND))
h2o.__changeErrorLog(normalizePath(h2o.__LOG_ERROR))
h2o.__startLogging()
}

Log.info<-
function(m) {
message <- paste("[INFO]: ",m, sep="")
logging(message)
message <- paste("[INFO]: ",m, sep="")
logging(message)
}

Log.warn<-
function(m) {
logging(paste("[WARN] : ",m,sep=""))
logging(paste("[WARN] : ",m,sep=""))
#temp <- strsplit(as.character(Sys.time()), " ")[[1]]
#m <- paste('[',temp[1], ' ',temp[2],']', '\t', m)
h2o.__logIt("[WARN] :", m, "Error")
traceback()
}

Log.err<-
function(m) {
logging(paste("[ERROR] : ",m,sep=""))
q("no",1,FALSE) #exit with nonzero exit code
logging(paste("[ERROR] : ",m,sep=""))
#temp <- strsplit(as.character(Sys.time()), " ")[[1]]
#m <- paste('[',temp[1], ' ',temp[2],']', '\t', m)
h2o.__logIt("[ERROR] :", m, "Error")
traceback()
q("no",1,FALSE) #exit with nonzero exit code
}

logging<-
function(m) {
cat(sprintf("[%s] %s\n", Sys.time(),m))
}

PASS <-
PASS<-
function() {
cat("###### # ##### ##### \n")
cat("# # # # # # # # \n")
cat("# # # # # # \n")
cat("###### # # ##### ##### \n")
cat("# ####### # # \n")
cat("# # # # # # # \n")
cat("# # # ##### ##### \n")
cat("###### # ##### ##### \n")
cat("# # # # # # # # \n")
cat("# # # # # # \n")
cat("###### # # ##### ##### \n")
cat("# ####### # # \n")
cat("# # # # # # # \n")
cat("# # # ##### ##### \n")
}

FAIL <-
FAIL<-
function(e) {
cat("")
cat("######## ### #### ## \n")
cat("## ## ## ## ## \n")
cat("## ## ## ## ## \n")
cat("###### ## ## ## ## \n")
cat("## ######### ## ## \n")
cat("## ## ## ## ## \n")
cat("## ## ## #### ########\n")

Log.err(e)
cat("")
cat("######## ### #### ## \n")
cat("## ## ## ## ## \n")
cat("## ## ## ## ## \n")
cat("###### ## ## ## ## \n")
cat("## ######### ## ## \n")
cat("## ## ## ## ## \n")
cat("## ## ## #### ######## \n")

Log.err(e)
}

WARN<-
function(w) {
Log.warn(w)
}

get_args<-
Expand All @@ -92,7 +107,7 @@ function(args) {

checkNLoadWrapper<-
function(ipPort) {
logging("\nCheck if H2O R wrapper package is installed\n")
Log.info("Check if H2O R wrapper package is installed\n")
if (!"h2o" %in% rownames(installed.packages())) {
envPath = Sys.getenv("H2OWrapperDir")
wrapDir = ifelse(envPath == "", defaultPath, envPath)
Expand All @@ -105,23 +120,23 @@ function(ipPort) {
install.packages(wrapPath, repos = NULL, type = "source")
}

logging("\nCheck that H2O R package matches version on server\n")
Log.info("Check that H2O R package matches version on server\n")
library(h2o)
h2o.installDepPkgs() # Install R package dependencies
h2o.init(ip = ipPort[[1]],
port = ipPort[[2]],
startH2O = FALSE,
silentUpgrade = TRUE)
source("../../h2oRClient-package/R/Algorithms.R")
source("../../h2oRClient-package/R/Classes.R")
source("../../h2oRClient-package/R/ParseImport.R")
source("../../h2oRClient-package/R/Internal.R")
sandbox()
#source("../../h2oRClient-package/R/Algorithms.R")
#source("../../h2oRClient-package/R/Classes.R")
#source("../../h2oRClient-package/R/ParseImport.R")
#source("../../h2oRClient-package/R/Internal.R")
#sandbox()
}

checkNLoadPackages<-
function() {
logging("\nChecking Package dependencies for this test.\n")
Log.info("Checking Package dependencies for this test.\n")
if (!"RUnit" %in% rownames(installed.packages())) install.packages("RUnit")
if (!"testthat" %in% rownames(installed.packages())) install.packages("testthat")

Expand All @@ -145,7 +160,7 @@ function(object) {
h2o.__remoteSend(object, h2o.__PAGE_REMOVEALL)
}

logging("\nLoading other required test packages")
Log.info("Loading other required test packages")
if(!"glmnet" %in% rownames(installed.packages())) install.packages("glmnet")
if(!"gbm" %in% rownames(installed.packages())) install.packages("gbm")
require(glmnet)
Expand Down
Empty file removed R/tests/Utils/out
Empty file.
5 changes: 4 additions & 1 deletion R/tests/autoGen/GenUtils.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
from math import floor, ceil
import sys

count = 0
def setup_random_seed(random_seed=None):
if random_seed is not None:
SEED = random_seed
Expand Down Expand Up @@ -150,7 +151,9 @@ def convertSeq(seq):
yield str(x)

def genTestName(FU, dataname):
res = dataname + '_' + str(uuid4()).replace('-','_')
global count
count += 1
res = dataname + '_' + str(count) #str(uuid4()).replace('-','_')
if FU == '[':
return 'sliceTest_' + res
if len(FU.split(';')) > 1:
Expand Down
141 changes: 139 additions & 2 deletions R/tests/autoGen/README
Original file line number Diff line number Diff line change
Expand Up @@ -9,5 +9,142 @@ What it does:
-A simple filter
-A compound filter

2. A simple filter is subsetting rows/cols by a single '<', '>', '=>','<=','!=','=='
3. A compound filter is an aribtrarily complicated sequence of '!','&','|','<', '>', '=>','<=','!=','=='
-A simple filter is subsetting rows/cols by a single '<', '>', '=>','<=','!=','=='
-A compound filter is an aribtrarily complicated sequence of '!','&','|','<', '>', '=>','<=','!=','=='

Future:
Generate these types of tasks:

Algorithms.R h2o.gbm
Algorithms.R h2o.glm.FV
Algorithms.R h2o.__getGLM2Results
Algorithms.R h2o.kmeans
Algorithms.R h2o.nn
Algorithms.R h2o.prcomp.internal
Algorithms.R h2o.prcomp
Algorithms.R h2o.pcr
Algorithms.R h2o.randomForest
Algorithms.R h2o.predict
Algorithms.R h2o.glm.internal
Algorithms.R h2o.glmgrid.internal
Algorithms.R h2o.__getGLMResults
Algorithms.R h2o.glm
Internal.R h2o.__logIt<- No direct test
Internal.R h2o.__remoteSend No direct test
Internal.R h2o.__writeToFile No direct test
Internal.R h2o.__formatError No direct test
Internal.R h2o.__dumpLogs No direct test
Internal.R h2o.__poll No direct test
Internal.R h2o.__allDone No direct test
Internal.R h2o.__pollAll No direct test
Internal.R h2o.__uniqID No direct test
Internal.R h2o.__version No direct test
Internal.R h2o.__getFamily No direct test
Internal.R h2o.__exec2 No direct test
Internal.R h2o.__exec2_dest_key No direct test
Internal.R h2o.__unop2 No direct test
Internal.R h2o.__binop2 No direct test
ParseImport.R h2o.startLauncher unimpl
ParseImport.R h2o.importURL
ParseImport.R h2o.importHDFS
Classes.R initialize H2ORawData
Classes.R initialize H2OParsedData
Classes.R initialize H2OModel
Classes.R show H2OClient
Classes.R show H2ORawData
Classes.R show H2OParsedData
Classes.R show H2OGLMModel
Classes.R show H2OGLMGrid
Classes.R show H2OKMeansModel
Classes.R show H2ONNModel
Classes.R show H2ODRFModel
Classes.R show H2OPCAModel
Classes.R show H2OGBMModel
Classes.R show H2OGBMGrid
Classes.R summary H2OPCAModel
Classes.R plot H2OPCAModel
Classes.R [ H2OParsedData
Classes.R $ H2OParsedData
Classes.R [<- H2OParsedData
Classes.R $<- H2OParsedData
Classes.R + H2OParsedData
Classes.R - H2OParsedData
Classes.R * H2OParsedData
Classes.R / H2OParsedData
Classes.R %% H2OParsedData
Classes.R "==" H2OParsedData
Classes.R > H2OParsedData
Classes.R < H2OParsedData
Classes.R != H2OParsedData
Classes.R >= H2OParsedData
Classes.R <= H2OParsedData
Classes.R & H2OParsedData
Classes.R | H2OParsedData
Classes.R + numeric
Classes.R - numeric
Classes.R * numeric
Classes.R / numeric
Classes.R %% numeric
Classes.R "==" numeric
Classes.R > numeric
Classes.R < numeric
Classes.R != numeric
Classes.R >= numeric
Classes.R <= numeric
Classes.R & numeric
Classes.R | numeric
Classes.R + H2OParsedData
Classes.R - H2OParsedData
Classes.R * H2OParsedData
Classes.R / H2OParsedData
Classes.R %% H2OParsedData
Classes.R "==" H2OParsedData
Classes.R > H2OParsedData
Classes.R < H2OParsedData
Classes.R != H2OParsedData
Classes.R >= H2OParsedData
Classes.R <= H2OParsedData
Classes.R & H2OParsedData
Classes.R | H2OParsedData
Classes.R ! H2OParsedData
Classes.R abs H2OParsedData ??
Classes.R sign H2OParsedData ??
Classes.R sqrt H2OParsedData ??
Classes.R ceiling H2OParsedData ??
Classes.R floor H2OParsedData ??
Classes.R log H2OParsedData ??
Classes.R exp H2OParsedData ??
Classes.R sum H2OParsedData ??
Classes.R is.na H2OParsedData ??
Classes.R h2o.cut H2OParsedData vecTask??
Classes.R h2o.table H2OParsedData multiVecTask??
Classes.R h2o.factor H2OParsedData vecTask (assuming)
Classes.R colnames H2OParsedData frameTask
Classes.R names H2OParsedData frameTask
Classes.R nrow H2OParsedData frameTask
Classes.R ncol H2OParsedData frameTask
Classes.R min H2OParsedData vecTask
Classes.R max H2OParsedData vecTask
Classes.R range H2OParsedData vecTask,frameTask
Classes.R colMeans H2OParsedData frameTask
Classes.R dim H2OParsedData frameTask
Classes.R as.data.frame H2OParsedData vecTask,frameTask
Classes.R head H2OParsedData vecTask,frameTask
Classes.R tail H2OParsedData vecTask,frameTask
Classes.R is.factor H2OParsedData ??
Classes.R quantile H2OParsedData vecTask
Classes.R histograms H2OParsedData ??
Classes.R summary H2OParsedData vecTask,frameTask
Classes.R apply H2OParsedData
Classes.R show H2ORawDataVA
Classes.R show H2OParsedDataVA
Classes.R show H2OGLMModelVA
Classes.R show H2OGLMGridVA
Classes.R colnames H2OParsedDataVA frameTask
Classes.R names H2OParsedDataVA frameTask
Classes.R nrow H2OParsedDataVA frameTask
Classes.R ncol H2OParsedDataVA frameTask
Classes.R dim H2OParsedDataVA frameTask
Classes.R head H2OParsedDataVA vecTask,frameTask
Classes.R tail H2OParsedDataVA vecTask,frameTask
Classes.R summary H2OParsedDataVA vecTask,frameTask
Loading

0 comments on commit 2da1443

Please sign in to comment.