You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@mxnet.apache.org by GitBox <gi...@apache.org> on 2018/06/29 11:52:34 UTC

[GitHub] nswamy closed pull request #11294: [MXNET-543][WIP]Scala Spark test

nswamy closed pull request #11294: [MXNET-543][WIP]Scala Spark test
URL: https://github.com/apache/incubator-mxnet/pull/11294
 
 
   

This is a PR merged from a forked repository.
As GitHub hides the original diff on merge, it is displayed below for
the sake of provenance:

As this is a foreign pull request (from a fork), the diff is supplied
below (as it won't show otherwise due to GitHub magic):

diff --git a/scala-package/spark/pom.xml b/scala-package/spark/pom.xml
index f2b806094af..43ff1f78fe1 100644
--- a/scala-package/spark/pom.xml
+++ b/scala-package/spark/pom.xml
@@ -36,6 +36,24 @@
       </properties>
     </profile>
   </profiles>
+  <build>
+    <plugins>
+      <plugin>
+        <groupId>org.scalatest</groupId>
+        <artifactId>scalatest-maven-plugin</artifactId>
+        <configuration>
+          <argLine>
+            -Djava.library.path=${project.parent.basedir}/native/${platform}/target \
+            -Dlog4j.configuration=file://${project.basedir}/src/test/resources/log4j.properties
+          </argLine>
+        </configuration>
+      </plugin>
+      <plugin>
+        <groupId>org.scalastyle</groupId>
+        <artifactId>scalastyle-maven-plugin</artifactId>
+      </plugin>
+    </plugins>
+  </build>
   <dependencies>
     <dependency>
       <groupId>org.apache.mxnet</groupId>
diff --git a/scala-package/spark/src/test/resources/log4j.properties b/scala-package/spark/src/test/resources/log4j.properties
new file mode 100644
index 00000000000..ef523cb7bc4
--- /dev/null
+++ b/scala-package/spark/src/test/resources/log4j.properties
@@ -0,0 +1,24 @@
+# Licensed to the Apache Software Foundation (ASF) under one
+# or more contributor license agreements.  See the NOTICE file
+# distributed with this work for additional information
+# regarding copyright ownership.  The ASF licenses this file
+# to you under the Apache License, Version 2.0 (the
+# "License"); you may not use this file except in compliance
+# with the License.  You may obtain a copy of the License at
+# 
+#   http://www.apache.org/licenses/LICENSE-2.0
+# 
+# Unless required by applicable law or agreed to in writing,
+# software distributed under the License is distributed on an
+# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+# KIND, either express or implied.  See the License for the
+# specific language governing permissions and limitations
+# under the License.
+
+# for development debugging
+log4j.rootLogger = info, stdout
+
+log4j.appender.stdout = org.apache.log4j.ConsoleAppender
+log4j.appender.stdout.Target = System.out
+log4j.appender.stdout.layout = org.apache.log4j.PatternLayout
+log4j.appender.stdout.layout.ConversionPattern=%d{yyyy-MM-dd HH:mm:ss,SSS} [%t] [%c] [%p] - %m%n
diff --git a/scala-package/spark/src/test/scala/org/apache/mxnet/spark/MXNetGeneralSuite.scala b/scala-package/spark/src/test/scala/org/apache/mxnet/spark/MXNetGeneralSuite.scala
index 72bbbe0fed0..7eec901fcb4 100644
--- a/scala-package/spark/src/test/scala/org/apache/mxnet/spark/MXNetGeneralSuite.scala
+++ b/scala-package/spark/src/test/scala/org/apache/mxnet/spark/MXNetGeneralSuite.scala
@@ -21,14 +21,16 @@ import java.io.{BufferedReader, File, InputStreamReader}
 import java.nio.file.Files
 
 import scala.sys.process.Process
-
 import org.apache.spark.SparkContext
 import org.apache.spark.mllib.linalg.Vectors
 import org.apache.spark.mllib.regression.LabeledPoint
 import org.apache.spark.rdd.RDD
+import org.slf4j.LoggerFactory
 
 class MXNetGeneralSuite extends SharedSparkContext {
 
+  private val logger = LoggerFactory.getLogger(classOf[MXNetGeneralSuite])
+
   private var testDataDir: String = _
 
   private def parseRawData(sc: SparkContext, path: String): RDD[LabeledPoint] = {
@@ -42,30 +44,38 @@ class MXNetGeneralSuite extends SharedSparkContext {
   }
 
   private def downloadTestData(): Unit = {
+    logger.info("Downloading the training data...")
     Process("wget http://apache-mxnet.s3-accelerate.dualstack.amazonaws.com/gluon" +
       "/dataset/mxnet-spark-test/train.txt" + " -P " + testDataDir + " -q") !
   }
 
-//  override def beforeAll(): Unit = {
-//  val tempDirFile = Files.createTempDirectory(s"mxnet-spark-test-${System.currentTimeMillis()}").
-//      toFile
-//    testDataDir = tempDirFile.getPath
-//    tempDirFile.deleteOnExit()
-//    downloadTestData()
-//  }
+  override def beforeAll(): Unit = {
+  val tempDirFile = Files.createTempDirectory(s"mxnet-spark-test-${System.currentTimeMillis()}").
+      toFile
+    testDataDir = tempDirFile.getPath
+    tempDirFile.deleteOnExit()
+    downloadTestData()
+  }
 
-  test("Dummy test on Spark") {
+  test("run spark with MLP") {
+    if (System.getenv().containsKey("SCALA_TEST_ON_GPU") &&
+      System.getenv("SCALA_TEST_ON_GPU").toInt == 1) {
+      val trainData = parseRawData(sc, s"$testDataDir/train.txt")
+      val model = buildMlp().fit(trainData)
+      assert(model != null)
+    } else {
+      logger.info("Currently not supporting CPU, skipped for now")
+    }
+  }
 
+  test("run spark with LeNet") {
+    if (System.getenv().containsKey("SCALA_TEST_ON_GPU") &&
+      System.getenv("SCALA_TEST_ON_GPU").toInt == 1) {
+      val trainData = parseRawData(sc, s"$testDataDir/train.txt")
+      val model = buildLeNet().fit(trainData)
+      assert(model != null)
+    } else {
+      logger.info("Currently not supporting CPU, skipped for now")
+    }
   }
-//  test("run spark with MLP") {
-//    val trainData = parseRawData(sc, s"$testDataDir/train.txt")
-//    val model = buildMlp().fit(trainData)
-//    assert(model != null)
-//  }
-//
-//  test("run spark with LeNet") {
-//    val trainData = parseRawData(sc, s"$testDataDir/train.txt")
-//    val model = buildLeNet().fit(trainData)
-//    assert(model != null)
-//  }
 }


 

----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
 
For queries about this service, please contact Infrastructure at:
users@infra.apache.org


With regards,
Apache Git Services