diff --git a/.gitignore b/.gitignore index 3405f660d2..066a7c877a 100644 --- a/.gitignore +++ b/.gitignore @@ -25,7 +25,7 @@ target/ .settings/* .idea/* h2o.iml -h2o.eml +*.eml h2o-samples/h2o-samples.iml experiments/experiments.iml /libpeerconnection.log @@ -40,3 +40,5 @@ R/.Rhistory R/tests/Rsandbox/ Rsandbox h2o-perf/perf-target/*jar +semantic.cache +.Rhistory diff --git a/build.sh b/build.sh index 5357c7a443..67d61ecca9 100755 --- a/build.sh +++ b/build.sh @@ -1,4 +1,4 @@ -#! /bin/bash +#! /bin/bash -x # determine the correct separator of multiple paths if [ `uname` = "Darwin" ] @@ -65,6 +65,8 @@ fi JAVAC_ARGS="-g -source 1.6 -target 1.6 + -J-Xms1024m + -J-Xmx1024m -XDignore.symbol.file -Xlint:all -Xlint:-deprecation @@ -188,7 +190,7 @@ function build_javadoc() { echo "creating javadoc files..." local CLASSPATH="${JAR_ROOT}${SEP}${DEPENDENCIES}${SEP}${JAR_ROOT}/hadoop/${DEFAULT_HADOOP_VERSION}/*" mkdir -p target/logs - "${JAVADOC}" -overview ${SRC}/overview.html -classpath "${CLASSPATH}" -d "${OUTDIR}"/javadoc -sourcepath "${SRC}" -subpackages hex:water >& target/logs/javadoc_build.log + "${JAVADOC}" -J-Xms256m -J-Xmx256m -overview ${SRC}/overview.html -classpath "${CLASSPATH}" -d "${OUTDIR}"/javadoc -sourcepath "${SRC}" -subpackages hex:water >& target/logs/javadoc_build.log } function junit() { diff --git a/src/main/java/hex/glm/GLMModel.java b/src/main/java/hex/glm/GLMModel.java index 2fbf5da1bc..269095ba1e 100644 --- a/src/main/java/hex/glm/GLMModel.java +++ b/src/main/java/hex/glm/GLMModel.java @@ -294,6 +294,14 @@ public static class GLMXValidationTask extends GLMValidationTask" + content + ""; + } + /////////////////////// + + + public static final Gson gson = new GsonBuilder().serializeSpecialFloatingPointValues().setPrettyPrinting().create(); + + private class ModelSummary { + public String model_type = "unknown"; + public String family = "unknown"; + public String state = "unknown"; + public List input_column_names = new ArrayList(); + public String response_column_name = null; + } + + /** + * Summarize fields which are generic to water.Model. + */ + private void summarizeModel(ModelSummary summary, Value value, water.Model model) { + String[] names = model._names; + + summary.model_type = model.getClass().toString(); + + summary.response_column_name = names[names.length - 1]; + + for (int i = 0; i < names.length - 1; i++) + summary.input_column_names.add(names[i]); + } + + /** + * Summarize fields which are specific to hex.glm.GLMModel. + */ + private void summarizeGLMModel(ModelSummary summary, Value value, hex.glm.GLMModel model) { + // add generic fields such as column names + summarizeModel(summary, value, model); + + summary.model_type = "GLM"; + summary.family = model.getParams().getFamily().toString(); + + // Job.JobHandle = (Job)DKV.get(model.getJobKey()); + // summary.state = job.state.toString()); + } + + /** + * Summarize fields which are specific to hex.drf.DRF.DRFModel. + */ + private void summarizeDRFModel(ModelSummary summary, Value value, hex.drf.DRF.DRFModel model) { + // add generic fields such as column names + summarizeModel(summary, value, model); + + summary.model_type = "DRF"; + // summary.family = model.getParams().getFamily().toString(); + + // Job.JobHandle = (Job)DKV.get(model.getJobKey()); + // summary.state = job.state.toString()); + } + + /** + * Summarize fields which are specific to hex.deeplearning.DeepLearningModel. + */ + private void summarizeDeepLearningModel(ModelSummary summary, Value value, hex.deeplearning.DeepLearningModel model) { + // add generic fields such as column names + summarizeModel(summary, value, model); + + summary.model_type = "DeepLearning"; + // summary.family = model.getParams().getFamily().toString(); + + // Job.JobHandle = (Job)DKV.get(model.getJobKey()); + // summary.state = job.state.toString()); + } + + /** + * Summarize fields which are specific to hex.gbm.GBM.GBMModel. + */ + private void summarizeGBMModel(ModelSummary summary, Value value, hex.gbm.GBM.GBMModel model) { + // add generic fields such as column names + summarizeModel(summary, value, model); + + summary.model_type = "GBM"; + // summary.family = model.getParams().getFamily().toString(); + + // Job.JobHandle = (Job)DKV.get(model.getJobKey()); + // summary.state = job.state.toString()); + } + + @Override + protected Response serve() { + + // Get all the model keys. Right now it's a hack to determine which values are models. + Set keySet = H2O.globalKeySet(null); + + Map map = new TreeMap(); // Sort for pretty display and reliable ordering. + for (Key key : keySet) { + String keyString = key.toString(); + ModelSummary summary = new ModelSummary(); + + Value value = DKV.get(key); + // TODO: we don't have a way right now of getting the type without deserializing to a POJO. + // This is going to deserialize the enture KV store. We need a less brute-force way. + Iced pojo = value.get(); + + if (pojo instanceof hex.glm.GLMModel) { + summarizeGLMModel(summary, value, (hex.glm.GLMModel) pojo); + } else if (pojo instanceof hex.drf.DRF.DRFModel) { + summarizeDRFModel(summary, value, (hex.drf.DRF.DRFModel) pojo); + } else if (pojo instanceof hex.deeplearning.DeepLearningModel) { + summarizeDeepLearningModel(summary, value, (hex.deeplearning.DeepLearningModel) pojo); + } else if (pojo instanceof hex.gbm.GBM.GBMModel) { + summarizeGBMModel(summary, value, (hex.gbm.GBM.GBMModel) pojo); + } else if (pojo instanceof water.Model) { + // catch-all + summarizeModel(summary, value, (water.Model) pojo); + } else { + // skip + continue; + } + + map.put(keyString, summary); + } + + // TODO: temporary hack to get things going + String json = gson.toJson(map); + Log.info("Json for kv store: " + json); + + JsonObject result = gson.fromJson(json, JsonElement.class).getAsJsonObject(); + return Response.done(result); + } // serve() + +} diff --git a/src/main/java/water/api/RequestServer.java b/src/main/java/water/api/RequestServer.java index 941812802f..a943da0ce2 100644 --- a/src/main/java/water/api/RequestServer.java +++ b/src/main/java/water/api/RequestServer.java @@ -212,6 +212,9 @@ public enum API_VERSION { // registerRequest(new GLMValidationView()); registerRequest(new LaunchJar()); Request.initializeNavBar(); + + // Pure APIs, no HTML, to support The New World + registerRequest(new Models()); } /**