Skip to content

Commit

Permalink
add more logging
Browse files Browse the repository at this point in the history
  • Loading branch information
spennihana committed Aug 5, 2014
1 parent a82aee7 commit b5ba44e
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 8 deletions.
19 changes: 14 additions & 5 deletions R/h2o-package/R/Wrapper.R
Original file line number Diff line number Diff line change
Expand Up @@ -2,24 +2,33 @@
# 1) If can't connect and user doesn't want to start H2O, stop immediately
# 2) If user does want to start H2O and running locally, attempt to bring up H2O launcher
# 3) If user does want to start H2O, but running non-locally, print an error
h2o.init <- function(ip = "127.0.0.1", port = 54321, startH2O = TRUE, forceDL = FALSE, Xmx = "1g", beta = FALSE, assertion = TRUE, license = NULL) {
h2o.init <- function(ip = "127.0.0.1", port = 54321, startH2O = TRUE, forceDL = FALSE, Xmx,
beta = FALSE, assertion = TRUE, license = NULL, max_mem_size = "1g", min_mem_size = "1g") {
if(!is.character(ip)) stop("ip must be of class character")
if(!is.numeric(port)) stop("port must be of class numeric")
if(!is.logical(startH2O)) stop("startH2O must be of class logical")
if(!is.logical(forceDL)) stop("forceDL must be of class logical")
if(!is.character(Xmx)) stop("Xmx must be of class character")
if(!is.character(max_mem_size)) stop("max_mem_size must be of class character")
if(!is.character(min_mem_size)) stop("min_mem_size must be of class character")
if(!regexpr("^[1-9][0-9]*[gGmM]$", Xmx)) stop("Xmx option must be like 1g or 1024m")
if(!is.logical(beta)) stop("beta must be of class logical")
if(!is.logical(assertion)) stop("assertion must be of class logical")
if(!is.null(license) && !is.character(license)) stop("license must be of class character")

if(!missing(Xmx)) {
warning("Xmx is a deprecated parameter. Use `max_mem_size` and `min_mem_size` to set the memory boundaries. Using `Xmx` to set these.")
max_mem_size <- Xmx
min_mem_size <- Xmx
}

myURL = paste("http://", ip, ":", port, sep="")
if(!url.exists(myURL)) {
if(!startH2O)
stop(paste("Cannot connect to H2O server. Please check that H2O is running at", myURL))
else if(ip == "localhost" || ip == "127.0.0.1") {
cat("\nH2O is not running yet, starting it now...\n")
.h2o.startJar(memory = Xmx, beta = beta, assertion = assertion, forceDL = forceDL, license = license)
.h2o.startJar(max_memory = max_mem_size, min_memory = min_mem_size, beta = beta, assertion = assertion, forceDL = forceDL, license = license)
count = 0; while(!url.exists(myURL) && count < 60) { Sys.sleep(1); count = count + 1 }
if(!url.exists(myURL)) stop("H2O failed to start, stopping execution.")
} else stop("Can only start H2O launcher if IP address is localhost.")
Expand Down Expand Up @@ -189,7 +198,7 @@ h2o.clusterStatus <- function(client) {
# h2o.shutdown(new("H2OClient", ip=ip, port=port), prompt = FALSE)
# }

.h2o.startJar <- function(memory = "1g", beta = FALSE, assertion = TRUE, forceDL = FALSE, license = NULL) {
.h2o.startJar <- function(max_memory = "1g", min_memory = "1g", beta = FALSE, assertion = TRUE, forceDL = FALSE, license = NULL) {
command <- .h2o.checkJava()

if (! is.null(license)) {
Expand All @@ -208,8 +217,8 @@ h2o.clusterStatus <- function(client) {
jar_file <- paste('"', jar_file, '"', sep = "")

# Compose args
args <- c(paste("-Xms", memory, sep=""),
paste("-Xmx", memory, sep=""))
args <- c(paste("-Xms", min_memory, sep=""),
paste("-Xmx", max_memory, sep=""))
if(assertion) args <- c(args, "-ea")
args <- c(args, "-jar", jar_file)
args <- c(args, "-name", "H2O_started_from_R")
Expand Down
8 changes: 5 additions & 3 deletions R/h2o-package/man/h2o.init.Rd
Original file line number Diff line number Diff line change
Expand Up @@ -4,18 +4,20 @@
\description{
Connects to a running H2O instance and checks the local H2O R package is the correct version (i.e. that the version of the R package and the version of H2O are the same).}
\usage{
h2o.init(ip = "127.0.0.1", port = 54321, startH2O = TRUE, forceDL = FALSE, Xmx = "1g",
beta = FALSE, assertion = TRUE, license = NULL)}
h2o.init(ip = "127.0.0.1", port = 54321, startH2O = TRUE, forceDL = FALSE, Xmx = "1g", max_mem_size = "1g",
min_mem_size = "1g", beta = FALSE, assertion = TRUE, license = NULL)}

\arguments{
\item{ip}{Object of class \code{"character"} representing the IP address of the server where H2O is running.}
\item{port}{Object of class \code{"numeric"} representing the port number of the H2O server.}
\item{startH2O}{(Optional) A logical value indicating whether to start the H2O launcher GUI if no connection with H2O is detected. This is only possible if \code{ip = "localhost"} or \code{ip = "127.0.0.1"}.}
\item{forceDL}{(Optional) A logical value indicating whether to force download of the H2O executable. Defaults to FALSE, so the executable will only be downloaded if it does not already exist in the h2o R library resources directory \code{h2o/java/h2o.jar}.}
\item{Xmx}{(Optional) A string specifying the maximum size, in bytes, of the memory allocation pool to H2O. This value must a multiple of 1024 greater than 2MB. Append the letter m or M to indicate megabytes, or g or G to indicate gigabytes.}
\item{Xmx}{ DEPRECATED A string specifying the maximum size, in bytes, of the memory allocation pool to H2O. This value must a multiple of 1024 greater than 2MB. Append the letter m or M to indicate megabytes, or g or G to indicate gigabytes.}
\item{beta}{(Optional) A logical value indicating whether H2O should be launch in beta mode.}
\item{assertion}{(Optional) A logical value indicating whether H2O should be launched with assertions enabled. Used mainly for error checking and debugging purposes.}
\item{license}{(Optional) A string value specifying the full path of the license file.}
\item{max_mem_size}{(Optional) A string specifying the maximum size, in bytes, of the memory allocation pool to H2O. This value must a multiple of 1024 greater than 2MB. Append the letter m or M to indicate megabytes, or g or G to indicate gigabytes.}
\item{min_mem_size}{(Optional) A string specifying the minimum size, in bytes, of the memory allocation pool to H2O. This value must a multiple of 1024 greater than 2MB. Append the letter m or M to indicate megabytes, or g or G to indicate gigabytes.}
}
\details{
This method first checks if H2O is connectible. If it cannot connect and \code{startH2O = TRUE} with IP of localhost, it will attempt to start an instance of H2O with IP = localhost, port = 54321. Otherwise, it stops immediately with an error.
Expand Down
3 changes: 3 additions & 0 deletions h2o-perf/bench/R/h2oPerf/prologue.R
Original file line number Diff line number Diff line change
Expand Up @@ -415,6 +415,9 @@ function(expected_results=NULL, type=NULL) {
.predict(model)
if (!is.null(expected_results)) {
if (type == "cm") {
print("CONFUSION MATRIX DATA")
print(confusion_matrix)
print(dim(confusion_matrix))
rr <- confusion_matrix[,dim(confusion_matrix)[2]]
rr <- data.frame(rr)[,1]
rr <- rr[1:(length(rr) - 2)] # -2 becuase the last row is totals, and the penultimate row is bogus fill by R
Expand Down

0 comments on commit b5ba44e

Please sign in to comment.