Skip to content

Commit

Permalink
[SW-1502] Relocation of com.google.protobuf for MOJO2 (#1434)
Browse files Browse the repository at this point in the history
* [SW-1502] Upgrade to mojo2 library v2.1.3

* Relocation of com.google.protobuf for MOJO2

* extra line
  • Loading branch information
mn-mikke authored and jakubhava committed Aug 14, 2019
1 parent eeebcb6 commit bf15285
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 5 deletions.
1 change: 1 addition & 0 deletions assembly/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ shadowJar {

relocate 'javassist', 'ai.h2o.javassist'
relocate 'com.google.common', 'ai.h2o.com.google.common'
relocate 'com.google.protobuf', 'ai.h2o.com.google.protobuf'
relocate 'org.eclipse.jetty', 'ai.h2o.org.eclipse.jetty'
relocate 'org.eclipse.jetty.orbit', 'ai.h2o.org.eclipse.jetty.orbit'

Expand Down
1 change: 0 additions & 1 deletion gradle/shadowRuntime.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ configurations {
exclude group: 'commons-io', module: 'commons-io' // a dependency of org.apache.spark:spark-core_2.11
exclude group: 'commons-logging', module: 'commons-logging' // a dependency of org.apache.hadoop:hadoop-auth
exclude group: 'log4j', module: 'log4j' // a dependency of org.apache.hadoop:hadoop-auth
exclude group: 'com.google.protobuf' // a dependency of org.apache.hadoop:hadoop-common
exclude group: 'com.fasterxml.jackson.core', module: 'jackson-core'
// a dependency of org.apache.spark:spark-sql_2.11
exclude group: 'org.apache.httpcomponents' // a dependency of org.apache.hadoop:hadoop-auth
Expand Down
4 changes: 2 additions & 2 deletions ml/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,10 @@ dependencies {


compile "ai.h2o:mojo2-runtime-api:${mojoPipelineVersion}"
runtime "ai.h2o:mojo2-runtime-impl:${mojoPipelineVersion}"
compile "ai.h2o:mojo2-runtime-impl:${mojoPipelineVersion}"

testCompile "ai.h2o:mojo2-runtime-api:${mojoPipelineVersion}"
testRuntime "ai.h2o:mojo2-runtime-impl:${mojoPipelineVersion}"
testCompile "ai.h2o:mojo2-runtime-impl:${mojoPipelineVersion}"

// And use scalatest for Scala testing
testCompile "org.scalatest:scalatest_${scalaBaseVersion}:2.2.1"
Expand Down
2 changes: 1 addition & 1 deletion scoring/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ dependencies {
compileOnly project(":sparkling-water-macros")

compile "ai.h2o:mojo2-runtime-api:${mojoPipelineVersion}"
runtime "ai.h2o:mojo2-runtime-impl:${mojoPipelineVersion}"
compile "ai.h2o:mojo2-runtime-impl:${mojoPipelineVersion}"
compile "ai.h2o:h2o-genmodel:${h2oVersion}"
compile project(":sparkling-water-utils")
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,12 @@ class H2OMOJOPipelineModel(override val uid: String) extends H2OMOJOModelBase[H2
builder.addRow(rowBuilder)
val output = mojoPipeline.transform(builder.toMojoFrame)
val predictions = output.getColumnNames.zipWithIndex.map { case (_, i) =>
val predictedVal = output.getColumnData(i).asInstanceOf[Array[Double]]
val columnOutput = output.getColumnData(i)
val predictedVal = if(columnOutput.isInstanceOf[Array[Float]]) {
columnOutput.asInstanceOf[Array[Float]].map(_.asInstanceOf[Double])
} else {
columnOutput.asInstanceOf[Array[Double]]
}
if (predictedVal.length != 1) {
throw new RuntimeException("Invalid state, we predict on each row by row, independently at this moment.")
}
Expand Down

0 comments on commit bf15285

Please sign in to comment.