Skip to content
This repository has been archived by the owner on Nov 17, 2023. It is now read-only.

Commit

Permalink
[MXNET-1155] Add scala packageTest utility
Browse files Browse the repository at this point in the history
  • Loading branch information
zachgk committed Nov 29, 2018
1 parent 1e4afd5 commit d6ad0e4
Show file tree
Hide file tree
Showing 13 changed files with 445 additions and 0 deletions.
8 changes: 8 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -603,6 +603,14 @@ scalaclean:
(cd $(ROOTDIR)/scala-package; \
mvn clean -P$(SCALA_PKG_PROFILE),$(SCALA_VERSION_PROFILE))

scalatestcompile:
(cd $(ROOTDIR)/scala-package; \
mvn test-compile -P$(SCALA_PKG_PROFILE),$(SCALA_VERSION_PROFILE) -Dcxx="$(CXX)" \
-Dbuild.platform="$(SCALA_PKG_PROFILE)" \
-Dcflags="$(CFLAGS)" -Dldflags="$(LDFLAGS)" \
-Dcurrent_libdir="$(ROOTDIR)/lib" \
-Dlddeps="$(LIB_DEP) $(ROOTDIR)/lib/libmxnet.a")

scalapkg:
(cd $(ROOTDIR)/scala-package; \
mvn package -P$(SCALA_PKG_PROFILE),$(SCALA_VERSION_PROFILE) -Dcxx="$(CXX)" \
Expand Down
8 changes: 8 additions & 0 deletions scala-package/core/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@
<exclude>META-INF/*.RSA</exclude>
</excludes>
</configuration>
<executions>
<execution>
<goals>
<goal>test-jar
</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
8 changes: 8 additions & 0 deletions scala-package/examples/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -119,6 +119,14 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-jar-plugin</artifactId>
<executions>
<execution>
<goals>
<goal>test-jar
</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
8 changes: 8 additions & 0 deletions scala-package/infer/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,14 @@
<exclude>META-INF/*.RSA</exclude>
</excludes>
</configuration>
<executions>
<execution>
<goals>
<goal>test-jar
</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
8 changes: 8 additions & 0 deletions scala-package/macros/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,14 @@
<exclude>META-INF/*.RSA</exclude>
</excludes>
</configuration>
<executions>
<execution>
<goals>
<goal>test-jar
</goal>
</goals>
</execution>
</executions>
</plugin>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
Expand Down
77 changes: 77 additions & 0 deletions scala-package/packageTest/Makefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
# 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.

SCALA_VERSION_PROFILE := 2.11
SCALA_VERSION := 2.11.8
MXNET_VERSION := 1.3.1-SNAPSHOT

MXNET_REPO = https://repository.apache.org/content/repositories/snapshots

ifeq ($(OS),Windows_NT)
UNAME_S := Windows
else
UNAME_S := $(shell uname -s)
endif

ifeq ($(UNAME_S), Windows)
# TODO: currently scala package does not support windows
SCALA_PKG_PROFILE := windows
else
ifeq ($(UNAME_S), Darwin)
SCALA_PKG_PROFILE := osx-x86_64-cpu
else
SCALA_PKG_PROFILE := linux-x86_64
ifeq ($(USE_CUDA), 1)
SCALA_PKG_PROFILE := $(SCALA_PKG_PROFILE)-gpu
else
SCALA_PKG_PROFILE := $(SCALA_PKG_PROFILE)-cpu
endif
endif
endif

scalapkg:
(mvn package -Dmxnet.profile=$(SCALA_PKG_PROFILE) \
-Dmxnet.scalaprofile=$(SCALA_VERSION_PROFILE) \
-Dmxnet.version=$(MXNET_VERSION) \
-Dscala.version=$(SCALA_VERSION))

scalaclean:
(mvn clean -Dmxnet.profile=$(SCALA_PKG_PROFILE) \
-Dmxnet.scalaprofile=$(SCALA_VERSION_PROFILE) \
-Dmxnet.version=$(MXNET_VERSION) \
-Dscala.version=$(SCALA_VERSION))

scalaintegrationtest:
(mvn integration-test -Dmxnet.profile=$(SCALA_PKG_PROFILE) \
-PwithExamples \
-Dmxnet.scalaprofile=$(SCALA_VERSION_PROFILE) \
-Dmxnet.version=$(MXNET_VERSION) \
-Dscala.version=$(SCALA_VERSION))

scalaintegrationtestsnapshot:
(mvn integration-test -Dmxnet.profile=$(SCALA_PKG_PROFILE) \
-PfromSnapshots \
-Dmxnet.scalaprofile=$(SCALA_VERSION_PROFILE) \
-Dmxnet.repo=$(MXNET_REPO) \
-Dmxnet.version=$(MXNET_VERSION) \
-Dscala.version=$(SCALA_VERSION))

scalaintegrationtestwithoutexamples:
(mvn integration-test -Dmxnet.profile=$(SCALA_PKG_PROFILE) \
-Dmxnet.scalaprofile=$(SCALA_VERSION_PROFILE) \
-Dmxnet.version=$(MXNET_VERSION) \
-Dscala.version=$(SCALA_VERSION))
50 changes: 50 additions & 0 deletions scala-package/packageTest/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
# MXNet Scala Package Test

This is an project created to run the test suite on a fully packaged mxnet jar.

## Setup

### Install Package

To run the test suite, first install the package. This can be done either by installing directly from a jar with `mvn install:install-file -Dfile=<path-to-file>` or by running `make scalainstall` in the main mxnet folder. Note that if you use `mvn install:install-file`, you will be unable to run the example tests unless you also install the mxnetexamples jar. You can run all tests except for those examples with `make scalaintegrationtestwithoutexamples`.

### Build

Build the mxnet tests by running `make scalapkg` and then `make scalatestcompile` from the main mxnet directory. This is needed for test discovery.

## Run

To run, ensure the versions are correct in the `Makefile`. Then, just run `make scalaintegrationtest` to execute the test suite

## Clean

You can clean temporary files and target artifacts by running `make scalaclean`.

## Troubleshooting

### Missing Examples

If you fail with the following error
```
[ERROR] Failed to execute goal org.scalatest:scalatest-maven-plugin:1.0:test (test) on project mxnet-scala-packagetest-examples_2.11: There are test failures -> [Help 1]
[ERROR]
[ERROR] To see the full stack trace of the errors, re-run Maven with the -e switch.
[ERROR] Re-run Maven using the -X switch to enable full debug logging.
[ERROR]
[ERROR] For more information about the errors and possible solutions, please read the following articles:
[ERROR] [Help 1] http://cwiki.apache.org/confluence/display/MAVEN/MojoFailureException
[ERROR]
[ERROR] After correcting the problems, you can resume the build with the command
[ERROR] mvn <goals> -rf :mxnet-scala-packagetest-examples_2.11
Makefile:57: recipe for target 'scalaintegrationtest' failed
make: *** [scalaintegrationtest] Error 1
```

and stacktrace begins with the following,

```
*** RUN ABORTED ***
java.lang.NoClassDefFoundError: org/apache/mxnetexamples/Util$
```

you are missing the mxnetexamples package. See the "Install Package" section for details.
30 changes: 30 additions & 0 deletions scala-package/packageTest/core/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>PackageTest</groupId>
<artifactId>mxnet-scala-packagetest_2.11</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>mxnet-scala-packagetest-core_2.11</artifactId>
<name>MXNet Scala Package Test</name>
<packaging>pom</packaging>

<build>
<plugins>
<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<runpath>${project.build.outputDirectory},${project.build.testOutputDirectory},../../core/target/test-classes</runpath>
</configuration>
</plugin>
</plugins>
</build>

</project>
1 change: 1 addition & 0 deletions scala-package/packageTest/core/scripts
39 changes: 39 additions & 0 deletions scala-package/packageTest/examples/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,39 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>PackageTest</groupId>
<artifactId>mxnet-scala-packagetest_2.11</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>mxnet-scala-packagetest-examples_2.11</artifactId>
<name>MXNet Scala Package Test</name>
<packaging>pom</packaging>

<build>
<plugins>
<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<runpath>${project.build.outputDirectory},${project.build.testOutputDirectory},../../examples/target/test-classes</runpath>
</configuration>
</plugin>
</plugins>
</build>

<dependencies>
<dependency>
<groupId>org.apache.mxnet</groupId>
<artifactId>mxnet-examples_${mxnet.scalaprofile}</artifactId>
<version>${mxnet.version}</version>
<scope>test</scope>
</dependency>
</dependencies>

</project>
1 change: 1 addition & 0 deletions scala-package/packageTest/examples/scripts
29 changes: 29 additions & 0 deletions scala-package/packageTest/infer/pom.xml
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
<?xml version="1.0" encoding="UTF-8"?>
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>PackageTest</groupId>
<artifactId>mxnet-scala-packagetest_2.11</artifactId>
<version>1.0-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath>
</parent>

<artifactId>mxnet-scala-packagetest-infer_2.11</artifactId>
<name>MXNet Scala Package Test</name>
<packaging>pom</packaging>

<build>
<plugins>
<plugin>
<groupId>org.scalatest</groupId>
<artifactId>scalatest-maven-plugin</artifactId>
<version>1.0</version>
<configuration>
<runpath>${project.build.outputDirectory},${project.build.testOutputDirectory},../../infer/target/test-classes</runpath>
</configuration>
</plugin>
</plugins>
</build>
</project>
Loading

0 comments on commit d6ad0e4

Please sign in to comment.