diff --git a/h2o-scala/src/main/scala/water/api/dsl/DslLegos.scala b/h2o-scala/src/main/scala/water/api/dsl/DslLegos.scala index 993c9687fd..6dc40b87ff 100644 --- a/h2o-scala/src/main/scala/water/api/dsl/DslLegos.scala +++ b/h2o-scala/src/main/scala/water/api/dsl/DslLegos.scala @@ -271,9 +271,8 @@ trait T_H2O_Env[K<:HexKey, VT <: DFrame] { // Operating with only given represen def jobs() = { val aj = Job.all() aj foreach { j:Job => - val cancelled = if (j.end_time == 0) Job.isRunning(j.self()) else j.end_time == Job.CANCELLED_END_TIME - val progress = if (j.end_time == 0) (if (cancelled) "DONE" else j.progress()) else "DONE" - println(j.description + " | " + (if (cancelled) "CANCELLED" else progress)) + val progress = if (!j.isRunning()) j.getState().toString else j.progress()*100+" %" + println(j.description + " | " + progress) } } // We need shutdown for sure ! :-) diff --git a/h2o-scala/src/main/scala/water/api/dsl/examples/Examples.scala b/h2o-scala/src/main/scala/water/api/dsl/examples/Examples.scala index 224c323cc0..f1a1595e05 100644 --- a/h2o-scala/src/main/scala/water/api/dsl/examples/Examples.scala +++ b/h2o-scala/src/main/scala/water/api/dsl/examples/Examples.scala @@ -21,13 +21,20 @@ object Examples { // Call in the context of H2O classloader def userMain(args: Array[String]):Unit = { H2O.main(args) - //example1() - //example2() + example1() + example2() example3() + water.api.dsl.H2ODsl.shutdown() + } + + def banner(id:Int, desc: String) = { + println("\n==== Example #"+id+" ====\n== \""+desc+"\"" ) + println( "====\n") } /** Compute average for given column. */ def example1() = { + banner(1, "Compute average of 2nd column in cars dataset") import water.api.dsl.H2ODsl._ /** Mutable class */ @@ -45,12 +52,11 @@ object Examples { } ) println("Average of 2. column is: " + r.sum / r.cnt); - shutdown() } /** Call DRF, make a model, predict on a train data, compute MSE. */ def example2() = { - + banner(2, "Call DRF API and make a forest for cars dataset") import water.api.dsl.H2ODsl._ val f = parse("../private/cars.csv") val source = f(1) ++ f(3 to 7) @@ -74,13 +80,11 @@ object Examples { }) println("RSS: " + rss) - - shutdown() } /** Compute quantiles for all vectors in a given frame. */ def example3() = { - + banner(3, "Call quantiles API and compute quantiles for all columns in cars dataset.") import water.api.dsl.H2ODsl._ val f = parse("../private/cars.csv") @@ -93,9 +97,7 @@ object Examples { val q = quantiles(f, columnId) println("Column '" + colname + "' quantile is " + q) } - } - - shutdown() + } } } diff --git a/src/main/java/water/Job.java b/src/main/java/water/Job.java index 610645cc12..5e07402275 100644 --- a/src/main/java/water/Job.java +++ b/src/main/java/water/Job.java @@ -224,6 +224,8 @@ public boolean isCancelledOrCrashed() { */ public boolean isRunning() { return state == JobState.RUNNING; } + public JobState getState() { return state; } + /** Returns a list of all jobs in a system. * @return list of all jobs including running, done, cancelled, crashed jobs.