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

Re-organize Scala maven build #13626

Merged
merged 3 commits into from
Jan 9, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
85 changes: 9 additions & 76 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,6 @@
ROOTDIR = $(CURDIR)
TPARTYDIR = $(ROOTDIR)/3rdparty

SCALA_VERSION_PROFILE := scala-2.11

ifeq ($(OS),Windows_NT)
UNAME_S := Windows
else
Expand Down Expand Up @@ -408,18 +406,13 @@ PLUGIN_OBJ =
PLUGIN_CUOBJ =
include $(MXNET_PLUGINS)

ifeq ($(UNAME_S), Windows)
# TODO(yizhi) currently scala package does not support windows
SCALA_PKG_PROFILE := windows
else
ifneq ($(UNAME_S), Windows)
ifeq ($(UNAME_S), Darwin)
WHOLE_ARCH= -all_load
NO_WHOLE_ARCH= -noall_load
SCALA_PKG_PROFILE := osx-x86_64
else
WHOLE_ARCH= --whole-archive
NO_WHOLE_ARCH= --no-whole-archive
SCALA_PKG_PROFILE := linux-x86_64
endif
endif

Expand All @@ -438,7 +431,6 @@ ifeq ($(USE_CUDA), 1)
# Make sure to add stubs as fallback in order to be able to build
# without full CUDA install (especially if run without nvidia-docker)
LDFLAGS += -L/usr/local/cuda/lib64/stubs
SCALA_PKG_PROFILE := $(SCALA_PKG_PROFILE)-gpu
ifeq ($(USE_NCCL), 1)
ifneq ($(USE_NCCL_PATH), NONE)
CFLAGS += -I$(USE_NCCL_PATH)/include
Expand All @@ -450,7 +442,6 @@ ifeq ($(USE_CUDA), 1)
CFLAGS += -DMXNET_USE_NCCL=0
endif
else
SCALA_PKG_PROFILE := $(SCALA_PKG_PROFILE)-cpu
CFLAGS += -DMXNET_USE_NCCL=0
endif

Expand Down Expand Up @@ -620,80 +611,22 @@ rpkgtest:
Rscript -e 'res<-covr:::package_coverage("R-package");fileConn<-file(paste("r-package_coverage_",toString(runif(1)),".json"));writeLines(covr:::to_codecov(res), fileConn);close(fileConn)'

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")
(cd $(ROOTDIR)/scala-package && mvn clean)

scalapkg:
(cd $(ROOTDIR)/scala-package && \
mvn package $(MAVEN_ARGS) -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")
(cd $(ROOTDIR)/scala-package && mvn install -DskipTests)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could we change this into mvn package and skiptests?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be install, package doesn't do verify.


scalainstall:
(cd $(ROOTDIR)/scala-package && mvn install)

scalaunittest:
(cd $(ROOTDIR)/scala-package && \
mvn integration-test $(MAVEN_ARGS) -P$(SCALA_PKG_PROFILE),$(SCALA_VERSION_PROFILE),unittest -Dcxx="$(CXX)" \
-Dcflags="$(CFLAGS)" -Dldflags="$(LDFLAGS)" \
-Dlddeps="$(LIB_DEP) $(ROOTDIR)/lib/libmxnet.a" $(SCALA_TEST_ARGS))
(cd $(ROOTDIR)/scala-package && mvn install)

scalaintegrationtest:
(cd $(ROOTDIR)/scala-package && \
mvn integration-test $(MAVEN_ARGS) -P$(SCALA_PKG_PROFILE),$(SCALA_VERSION_PROFILE),integrationtest -Dcxx="$(CXX)" \
-Dcflags="$(CFLAGS)" -Dldflags="$(LDFLAGS)" \
-Dlddeps="$(LIB_DEP) $(ROOTDIR)/lib/libmxnet.a" $(SCALA_TEST_ARGS))

scalainstall:
(cd $(ROOTDIR)/scala-package && \
mvn install $(MAVEN_ARGS) -P$(SCALA_PKG_PROFILE),$(SCALA_VERSION_PROFILE) -DskipTests=true -Dcxx="$(CXX)" \
-Dbuild.platform="$(SCALA_PKG_PROFILE)" \
-Dcflags="$(CFLAGS)" -Dldflags="$(LDFLAGS)" \
-Dlddeps="$(LIB_DEP) $(ROOTDIR)/lib/libmxnet.a")

scalarelease-dryrun:
(cd $(ROOTDIR)/scala-package && \
mvn release:clean release:prepare -DdryRun=true -DautoVersionSubmodules=true \
-Papache-release,$(SCALA_PKG_PROFILE),$(SCALA_VERSION_PROFILE) \
-Darguments=""-Dbuild\.platform=\""$(SCALA_PKG_PROFILE)\""\ -DskipTests=true\ -Dcflags=\""$(CFLAGS)\""\ -Dcxx=\""$(CXX)\""\ -Dldflags=\""$(LDFLAGS)\""\ -Dlddeps=\""$(LIB_DEP) $(ROOTDIR)/lib/libmxnet.a\"""")

scalarelease-prepare:
(cd $(ROOTDIR)/scala-package && \
mvn release:clean release:prepare -DautoVersionSubmodules=true \
-Papache-release,$(SCALA_PKG_PROFILE),$(SCALA_VERSION_PROFILE) \
-Darguments=""-Dbuild\.platform=\""$(SCALA_PKG_PROFILE)\""\ -DskipTests=true\ -Dcflags=\""$(CFLAGS)\""\ -Dcxx=\""$(CXX)\""\ -Dldflags=\""$(LDFLAGS)\""\ -Dlddeps=\""$(LIB_DEP) $(ROOTDIR)/lib/libmxnet.a\"""")

scalarelease-perform:
(cd $(ROOTDIR)/scala-package && \
mvn release:perform -DautoVersionSubmodules=true \
-Papache-release,$(SCALA_PKG_PROFILE),$(SCALA_VERSION_PROFILE) \
-Darguments=""-Dbuild\.platform=\""$(SCALA_PKG_PROFILE)\""\ -DskipTests=true\ -Dcflags=\""$(CFLAGS)\""\ -Dcxx=\""$(CXX)\""\ -Dldflags=\""$(LDFLAGS)\""\ -Dlddeps=\""$(LIB_DEP) $(ROOTDIR)/lib/libmxnet.a\"""")

scaladeploy:
(cd $(ROOTDIR)/scala-package && \
mvn deploy $(MAVEN_ARGS) -Papache-release,$(SCALA_PKG_PROFILE),$(SCALA_VERSION_PROFILE) \-DskipTests=true -Dcxx="$(CXX)" \
-Dbuild.platform="$(SCALA_PKG_PROFILE)" \
-Dcflags="$(CFLAGS)" -Dldflags="$(LDFLAGS)" \
-Dlddeps="$(LIB_DEP) $(ROOTDIR)/lib/libmxnet.a")

scaladeploylocal:
(cd $(ROOTDIR)/scala-package && \
mvn deploy $(MAVEN_ARGS) -Papache-release,deployLocal,$(SCALA_PKG_PROFILE),$(SCALA_VERSION_PROFILE) \-DskipTests=true -Dcxx="$(CXX)" \
-DaltDeploymentRepository=snapshot-repo::default::file:local-snapshot \
-Dgpg.skip \
-Dbuild.platform="$(SCALA_PKG_PROFILE)" \
-Dcflags="$(CFLAGS)" -Dldflags="$(LDFLAGS)" \
-Dlddeps="$(LIB_DEP) $(ROOTDIR)/lib/libmxnet.a")
(cd $(ROOTDIR)/scala-package && mvn integration-test -DskipTests=false)

jnilint:
3rdparty/dmlc-core/scripts/lint.py mxnet-jnicpp cpp scala-package/native/src
3rdparty/dmlc-core/scripts/lint.py mxnet-jnicpp cpp scala-package/native/src --exclude_path scala-package/native/src/main/native/org_apache_mxnet_native_c_api.h

rclean:
$(RM) -r R-package/src/image_recordio.h R-package/NAMESPACE R-package/man R-package/R/mxnet_generated.R \
Expand Down
2 changes: 1 addition & 1 deletion contrib/clojure-package/project.clj
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@
;[org.apache.mxnet/mxnet-full_2.11-linux-x86_64-gpu "1.2.1"]

;;; CI
[org.apache.mxnet/mxnet-full_2.11-linux-x86_64-cpu "1.5.0-SNAPSHOT"]
[org.apache.mxnet/mxnet-full_2.11 "INTERNAL"]

[org.clojure/tools.logging "0.4.0"]
[org.apache.logging.log4j/log4j-core "2.8.1"]
Expand Down
12 changes: 6 additions & 6 deletions docs/mxdoc.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,9 +113,9 @@ def build_scala_docs(app):
scala_doc_sources = 'find . -type f -name "*.scala" | egrep \"\.\/core|\.\/infer\" | egrep -v \"\/javaapi\" | egrep -v \"Suite\"'
scala_doc_classpath = ':'.join([
'`find native -name "*.jar" | grep "target/lib/" | tr "\\n" ":" `',
'`find macros -name "*-SNAPSHOT.jar" | tr "\\n" ":" `',
'`find core -name "*-SNAPSHOT.jar" | tr "\\n" ":" `',
'`find infer -name "*-SNAPSHOT.jar" | tr "\\n" ":" `'
'`find macros -name "*-INTERNAL.jar" | tr "\\n" ":" `',
'`find core -name "*-INTERNAL.jar" | tr "\\n" ":" `',
'`find infer -name "*-INTERNAL.jar" | tr "\\n" ":" `'
])
# There are unresolvable errors on mxnet 1.2.x. We are ignoring those errors while aborting the ci on newer versions
scala_ignore_errors = '; exit 0' if '1.2.' in _BUILD_VER else ''
Expand All @@ -135,9 +135,9 @@ def build_java_docs(app):
java_doc_sources = 'find . -type f -name "*.scala" | egrep \"\.\/core|\.\/infer\" | egrep \"\/javaapi\" | egrep -v \"Suite\"'
java_doc_classpath = ':'.join([
'`find native -name "*.jar" | grep "target/lib/" | tr "\\n" ":" `',
'`find macros -name "*-SNAPSHOT.jar" | tr "\\n" ":" `',
'`find core -name "*-SNAPSHOT.jar" | tr "\\n" ":" `',
'`find infer -name "*-SNAPSHOT.jar" | tr "\\n" ":" `'
'`find macros -name "*-INTERNAL.jar" | tr "\\n" ":" `',
'`find core -name "*-INTERNAL.jar" | tr "\\n" ":" `',
'`find infer -name "*-INTERNAL.jar" | tr "\\n" ":" `'
])
_run_cmd('cd {}; scaladoc `{}` -classpath {} -feature -deprecation'
.format(java_path, java_doc_sources, java_doc_classpath))
Expand Down
2 changes: 1 addition & 1 deletion scala-package/.gitignore
Original file line number Diff line number Diff line change
@@ -1,10 +1,10 @@
.flattened-pom.xml
core/src/main/scala/org/apache/mxnet/NDArrayAPIBase.scala
core/src/main/scala/org/apache/mxnet/NDArrayBase.scala
core/src/main/scala/org/apache/mxnet/NDArrayRandomAPIBase.scala
core/src/main/scala/org/apache/mxnet/javaapi/NDArrayBase.scala
core/src/main/scala/org/apache/mxnet/SymbolAPIBase.scala
core/src/main/scala/org/apache/mxnet/SymbolBase.scala
core/src/main/scala/org/apache/mxnet/NDArrayRandomAPIBase.scala
core/src/main/scala/org/apache/mxnet/SymbolRandomAPIBase.scala
examples/scripts/infer/images/
examples/scripts/infer/models/
Expand Down
43 changes: 34 additions & 9 deletions scala-package/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ The MXNet Scala/Java Package brings flexible and efficient GPU/CPU computing and
- The Scala/Java Inferece APIs provides an easy out of the box solution for loading pre-trained MXNet models and running inference on them.

Pre-Built Maven Packages
------------
------------------------

### Stable ###

Expand Down Expand Up @@ -114,30 +114,51 @@ Also, add the dependency which corresponds to your platform to the ```dependenci
**Note:** ```<version>[1.5.0,)<\version>``` indicates that we will fetch packages with version 1.5.0 or higher. This will always ensure that the pom.xml is able to fetch the latest and greatest jar files from Maven Snapshot repository.

Build From Source
------------
-----------------

Checkout the [Installation Guide](http://mxnet.incubator.apache.org/install/index.html) contains instructions to install mxnet package and build it from source.
If you have built MXNet from source and are looking to setup Scala from that point, you may simply run the following from the MXNet source root:
Checkout the [Installation Guide](http://mxnet.incubator.apache.org/install/index.html) contains instructions to install mxnet package and build it from source. Scala maven build assume you already have a ``lib/libmxnet.so`` file.
If you have built MXNet from source and are looking to setup Scala from that point, you may simply run the following from the MXNet source root, Scala build will detect your platform (OSX/Linux) and libmxnet.so flavor (CPU/GPU):

```bash
make scalapkg
cd scala-package
mvn install
```

You can also run the unit tests and integration tests on the Scala Package by :

```bash
make scalaunittest
make scalaintegrationtest
cd scala-package
mvn integration-test -DskipTests=false
```

Or run a subset of unit tests, for e.g.,

```bash
make SCALA_TEST_ARGS=-Dsuites=org.apache.mxnet.NDArraySuite scalaunittest
cd scala-package
mvn -Dsuites=org.apache.mxnet.NDArraySuite integration-test
```

If everything goes well, you will find jars for `assembly`, `core` and `example` modules.
Also it produces the native library in `native/{your-architecture}/target`, which you can use to cooperate with the `core` module.
Also it produces the native library in `native/target`, which you can use to cooperate with the `core` module.

Deploy to repository
--------------------

By default, `maven deploy` will deploy artifacts to local file system, you can file then in: ``scala-package/deploy/target/repo`` folder.

For nightly build in CI, a snapshot build will be uploaded to apache repository with follow command:

```bash
cd scala-package
mvn deploy -Pnightly
```

Use following command to deploy release build (push artifacts to apache staging repository):

```bash
cd scala-package
mvn deploy -Pstaging
```

Examples & Usage
-------
Expand Down Expand Up @@ -175,3 +196,7 @@ More details about JVM Memory Management are available [here](https://github.com
License
-------
MXNet Scala Package is licensed under [Apache-2](https://github.com/apache/incubator-mxnet/blob/master/scala-package/LICENSE) license.

MXNet uses some 3rd party softwares. Following 3rd party license files are bundled inside Scala jar file:
* cub/LICENSE.TXT
* mkldnn/external/mklml_mac_2019.0.1.20180928/license.txt
131 changes: 0 additions & 131 deletions scala-package/assembly/linux-x86_64-cpu/pom.xml

This file was deleted.

Loading