diff --git a/Jenkinsfile b/Jenkinsfile index ab0e24f8d421..3474fda7a869 100644 --- a/Jenkinsfile +++ b/Jenkinsfile @@ -5,47 +5,49 @@ def init_git_submodule() { sh "git submodule update" } -def setup() { - init_git_submodule() +def init_git_submodule_win64() { + bat "git submodule init" + bat "git submodule update" } def build_dgl() { - sh "if [ -d build ]; then rm -rf build; fi; mkdir build" - sh "rm -rf _download" - dir ("build") { - sh "cmake .." - sh "make -j4" - } - dir("python") { - sh "rm -rf build *.egg-info dist" - sh "pip3 uninstall -y dgl" - sh "python3 setup.py install" - } + sh "bash tests/scripts/build_dgl.sh" } -def pytorch_unit_test(dev) { - withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build", "PYTHONPATH=${env.WORKSPACE}/python"]) { - sh "python3 -m nose -v --with-xunit tests" - sh "python3 -m nose -v --with-xunit tests/pytorch" - sh "python3 -m nose -v --with-xunit tests/graph_index" +def build_dgl_win64() { + /* Assuming that Windows slaves are already configured with MSBuild VS2017, + * CMake and Python/pip/setuptools etc. */ + bat "CALL tests\\scripts\\build_dgl.bat" +} + +def unit_test(backend, dev) { + withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build", "PYTHONPATH=${env.WORKSPACE}/python", "DGLBACKEND=${backend}"]) { + sh "bash tests/scripts/task_unit_test.sh ${backend}" } } -def mxnet_unit_test(dev) { - withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build", "PYTHONPATH=${env.WORKSPACE}/python"]) { - sh "python3 -m nose -v --with-xunit tests/mxnet" - sh "python3 -m nose -v --with-xunit tests/graph_index" +def unit_test_win64(backend, dev) { + withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}\\build", "PYTHONPATH=${env.WORKSPACE}\\python", "DGLBACKEND=${backend}"]) { + bat "CALL tests\\scripts\\task_unit_test.bat ${backend}" } } -def example_test(dev) { - withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build", "PYTHONPATH=${env.WORKSPACE}/python"]) { +def example_test(backend, dev) { + withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build", "PYTHONPATH=${env.WORKSPACE}/python", "DGLBACKEND=${backend}"]) { dir ("tests/scripts") { sh "bash task_example_test.sh ${dev}" } } } +def example_test_win64(backend, dev) { + withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}\\build", "PYTHONPATH=${env.WORKSPACE}\\python", "DGLBACKEND=${backend}"]) { + dir ("tests\\scripts") { + bat "CALL task_example_test ${dev}" + } + } +} + def pytorch_tutorials() { withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build", "PYTHONPATH=${env.WORKSPACE}/python"]) { dir ("tests/scripts") { @@ -65,7 +67,9 @@ pipeline { agent none stages { stage("Lint Check") { - agent { docker { image "dgllib/dgl-ci-lint" } } + agent { + docker { image "dgllib/dgl-ci-lint" } + } steps { init_git_submodule() sh "bash tests/scripts/task_lint.sh" @@ -74,9 +78,11 @@ pipeline { stage("Build") { parallel { stage("CPU Build") { - agent { docker { image "dgllib/dgl-ci-cpu" } } + agent { + docker { image "dgllib/dgl-ci-cpu" } + } steps { - setup() + init_git_submodule() build_dgl() } } @@ -88,29 +94,56 @@ pipeline { } } steps { - setup() + init_git_submodule() build_dgl() } } stage("MXNet CPU Build (temp)") { - agent { docker { image "dgllib/dgl-ci-mxnet-cpu" } } + agent { + docker { image "dgllib/dgl-ci-mxnet-cpu" } + } steps { - setup() + init_git_submodule() build_dgl() } } + stage("CPU Build (Win64/PyTorch)") { + agent { + label "windows" + } + steps { + init_git_submodule_win64() + build_dgl_win64() + } + } } } stage("Test") { parallel { stage("Pytorch CPU") { - agent { docker { image "dgllib/dgl-ci-cpu" } } + agent { + docker { image "dgllib/dgl-ci-cpu" } + } stages { stage("TH CPU unittest") { - steps { pytorch_unit_test("CPU") } + steps { unit_test("pytorch", "CPU") } } stage("TH CPU example test") { - steps { example_test("CPU") } + steps { example_test("pytorch", "CPU") } + } + } + post { + always { junit "*.xml" } + } + } + stage("Pytorch CPU (Windows)") { + agent { label "windows" } + stages { + stage("TH CPU Win64 unittest") { + steps { unit_test_win64("pytorch", "CPU") } + } + stage("TH CPU Win64 example test") { + steps { example_test_win64("pytorch", "CPU") } } } post { @@ -130,7 +163,7 @@ pipeline { // steps { pytorch_unit_test("GPU") } //} stage("TH GPU example test") { - steps { example_test("GPU") } + steps { example_test("pytorch", "GPU") } } } // TODO: have GPU unittest @@ -139,10 +172,12 @@ pipeline { //} } stage("MXNet CPU") { - agent { docker { image "dgllib/dgl-ci-mxnet-cpu" } } + agent { + docker { image "dgllib/dgl-ci-mxnet-cpu" } + } stages { stage("MX Unittest") { - steps { mxnet_unit_test("CPU") } + steps { unit_test("mxnet", "CPU") } } } post { @@ -154,13 +189,17 @@ pipeline { stage("Doc") { parallel { stage("TH Tutorial") { - agent { docker { image "dgllib/dgl-ci-cpu" } } + agent { + docker { image "dgllib/dgl-ci-cpu" } + } steps { pytorch_tutorials() } } stage("MX Tutorial") { - agent { docker { image "dgllib/dgl-ci-mxnet-cpu" } } + agent { + docker { image "dgllib/dgl-ci-mxnet-cpu" } + } steps { mxnet_tutorials() } diff --git a/tests/pytorch/test_graph.py b/tests/pytorch/test_graph.py index d334c258436d..302e6bec5b69 100644 --- a/tests/pytorch/test_graph.py +++ b/tests/pytorch/test_graph.py @@ -94,7 +94,7 @@ def test_incmat(): def test_incmat_cache(): n = 1000 - p = 2 * math.log(n) / n + p = 10 * math.log(n) / n a = sp.random(n, n, p, data_rvs=lambda n: np.ones(n)) g = dgl.DGLGraph(a) # the first call should contruct the inc diff --git a/tests/scripts/build_dgl.bat b/tests/scripts/build_dgl.bat new file mode 100644 index 000000000000..42c1d2b11688 --- /dev/null +++ b/tests/scripts/build_dgl.bat @@ -0,0 +1,21 @@ +@ECHO OFF +SETLOCAL EnableDelayedExpansion + +DEL /S /Q build +DEL /S /Q _download +MD build + +PUSHD build +CALL "C:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\VC\Auxiliary\Build\vcvars64.bat" +cmake -DCMAKE_CXX_FLAGS="/DDGL_EXPORTS" -DCMAKE_CONFIGURATION_TYPES="Release" .. -G "Visual Studio 15 2017 Win64" || EXIT /B 1 +msbuild dgl.sln || EXIT /B 1 +COPY Release\dgl.dll . +POPD + +PUSHD python +DEL /S /Q build *.egg-info dist +pip install -e . --force-reinstall --user || EXIT /B 1 +POPD + +ENDLOCAL +EXIT /B diff --git a/tests/scripts/build_dgl.sh b/tests/scripts/build_dgl.sh new file mode 100644 index 000000000000..44282ad42ba9 --- /dev/null +++ b/tests/scripts/build_dgl.sh @@ -0,0 +1,19 @@ +#!/bin/bash + +if [ -d build ]; then + rm -rf build +fi +mkdir build + +rm -rf _download + +pushd build +cmake .. +make -j4 +popd + +pushd python +rm -rf build *.egg-info dist +pip3 uninstall -y dgl +python3 setup.py install +popd diff --git a/tests/scripts/task_example_test.bat b/tests/scripts/task_example_test.bat new file mode 100644 index 000000000000..9a33e49a4ca1 --- /dev/null +++ b/tests/scripts/task_example_test.bat @@ -0,0 +1,28 @@ +@ECHO OFF +SETLOCAL EnableDelayedExpansion + +IF x%1x==xx ( + ECHO Must supply CPU or GPU + GOTO :FAIL +) ELSE IF x%1x==xCPUx ( + SET DEV=-1 +) ELSE IF x%1x==xGPUx ( + SET DEV=0 + SET CUDA_VISIBLE_DEVICES=0 +) ELSE ( + ECHO Must supply CPU or GPU + GOTO :FAIL +) + +PUSHD ..\..\examples\pytorch +python pagerank.py || GOTO :FAIL +python gcn\gcn.py --dataset cora --gpu !dev! || GOTO :FAIL +python gcn\gcn_spmv.py --dataset cora --gpu !dev! || GOTO :FAIL +POPD +ENDLOCAL +EXIT /B + +:FAIL +ECHO Example test failed +ENDLOCAL +EXIT /B 1 diff --git a/tests/scripts/task_unit_test.bat b/tests/scripts/task_unit_test.bat new file mode 100644 index 000000000000..0a10b7f6abd2 --- /dev/null +++ b/tests/scripts/task_unit_test.bat @@ -0,0 +1,14 @@ +@ECHO OFF +SETLOCAL EnableDelayedExpansion + +IF x%1x==xx ( + ECHO Specify backend + EXIT /B 1 +) ELSE ( + SET BACKEND=%1 +) + +python -m nose -v --with-xunit tests || EXIT /B 1 +python -m nose -v --with-xunit tests\!BACKEND! || EXIT /B 1 +python -m nose -v --with-xunit tests\graph_index || EXIT /B 1 +EXIT /B diff --git a/tests/scripts/task_unit_test.sh b/tests/scripts/task_unit_test.sh new file mode 100644 index 000000000000..54aab1645986 --- /dev/null +++ b/tests/scripts/task_unit_test.sh @@ -0,0 +1,21 @@ +#!/bin/bash + +function fail { + echo FAIL: $@ + exit -1 +} + +function usage { + echo "Usage: $0 backend" +} + +if [ $# -ne 1 ]; then + usage + fail "Error: must specify backend" +fi + +BACKEND=$1 + +python3 -m nose -v --with-xunit tests || fail "tests" +python3 -m nose -v --with-xunit tests/$BACKEND || fail "backend" +python3 -m nose -v --with-xunit tests/graph_index || fail "graph_index"