Skip to content

Commit

Permalink
Minor helper function for scala.
Browse files Browse the repository at this point in the history
  • Loading branch information
mmalohlava committed Apr 3, 2014
1 parent 58e27d4 commit 9a87973
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 26 deletions.
15 changes: 15 additions & 0 deletions h2o-scala/src/main/scala/water/api/dsl/DslLegos.scala
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,21 @@ trait T_H2O_Env[K<:HexKey, VT <: DFrame] { // Operating with only given represen
// Wrap the frame
new DFrame(f)
}
// Find a given filename
def ffind(fname: String):File = {
var file = new File(fname)
if (!file.exists())
file = new File("../" + fname)
if (!file.exists())
file = new File("../../" + fname)
if (!file.exists())
file = new File("../smalldata/" + fname)
if (!file.exists())
file = new File("../../smalldata/" + fname)
if (!file.exists())
file = null
file
}
def keys:Unit = keys(false)
// Simply print a list of keys in KV store
def keys(verbose:Boolean = false) = {
Expand Down
10 changes: 1 addition & 9 deletions h2o-scala/src/main/scala/water/api/dsl/H2ODsl.scala
Original file line number Diff line number Diff line change
@@ -1,16 +1,8 @@
package water.api.dsl

import water.fvec.Frame
import scala.collection.immutable.Range
import water.fvec.Frame
import water.UKV
import water.Key
import water.H2O
import water.TestUtil
import java.io.File
import water.fvec.NFSFileVec
import water.fvec.ParseDataset2
import java.util.UUID

/** The object carry global environment and provides basic global methods such as head, tail, nrows, ... */
object H2ODsl extends H2ODslImplicitConv with T_R_Env[DFrame] with T_H2O_Env[HexKey, DFrame] with DefaultEnv[HexKey, DFrame] {
Expand All @@ -34,7 +26,7 @@ object H2ODsl extends H2ODslImplicitConv with T_R_Env[DFrame] with T_H2O_Env[Hex
def save(k:HexKey, d:DFrame) = put(k,d)

def example():DFrame = example(System.getProperty("user.dir") + "/../../")

def example(topdir:String):DFrame = {
println("topdir is: " + topdir)
val tdir = if (topdir==null) "" else if (!topdir.endsWith("/")) topdir+"/" else topdir
Expand Down
20 changes: 3 additions & 17 deletions h2o-scala/src/main/scala/water/api/dsl/examples/Examples.scala
Original file line number Diff line number Diff line change
Expand Up @@ -129,10 +129,10 @@ makes a prediction over train data and compute MSE of prediction."""")
def userMain(args: Array[String]):Unit = {
H2O.main(args)
try {
//example1()
example1()
example2()
//example3()
//example4()
example3()
example4()
} catch {
case t:Throwable => t.printStackTrace() // Simple debug
} finally {
Expand All @@ -145,20 +145,6 @@ makes a prediction over train data and compute MSE of prediction."""")
println("\n==== Example #"+id+" ====\n "+desc )
println( "====================\n")
}

// Find a given filename
private def ffind(fname: String):File = {
var file = new File(fname)
if (!file.exists())
file = new File("../" + fname)
if (!file.exists())
file = new File("../../" + fname)
if (!file.exists())
file = null
file
}


}

// Companion class
Expand Down

0 comments on commit 9a87973

Please sign in to comment.