Commit cd907cdd authored by VoVAllen's avatar VoVAllen Committed by Minjie Wang
Browse files

[Tutorial] Add sse tutorial & MXNet Tutorial CI (#252)

* add sse tutorial

* add mxnet tutorial ci

* fix ci

* fix ci

* fix ci

* fix ci

* fix ci

* fix ci

* Fix ci

* Fix ci

* Fix ci

* fix ci

* fix ci

* fix ci

* fix ci

* fix ci

* fix ci

* Fix CI

Fix CI image

* permission fix

* fix a bug in the code.

* small fix

* fix doc

* fix ci

* shorten the iters

* fix

* remove extra file

* add load_backend api to dynamically switch to another backend

* try fix

* fix tutorial

* fix tutorial

* fix bug in tutorial
parent f4a9a455
......@@ -40,7 +40,7 @@ def mxnet_unit_test(dev) {
def example_test(dev) {
withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build", "PYTHONPATH=${env.WORKSPACE}/python"]) {
dir ("tests/scripts") {
sh "./task_example_test.sh ${dev}"
sh "bash task_example_test.sh ${dev}"
}
}
}
......@@ -48,11 +48,18 @@ def example_test(dev) {
def pytorch_tutorials() {
withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build", "PYTHONPATH=${env.WORKSPACE}/python"]) {
dir ("tests/scripts") {
sh "./task_tutorial_test.sh"
sh "bash task_pytorch_tutorial_test.sh"
}
}
}
def mxnet_tutorials() {
withEnv(["DGL_LIBRARY_PATH=${env.WORKSPACE}/build", "PYTHONPATH=${env.WORKSPACE}/python"]) {
dir("tests/scripts") {
sh "bash task_mxnet_tutorial_test.sh"
}
}
}
pipeline {
agent none
stages {
......@@ -60,7 +67,7 @@ pipeline {
agent { docker { image "dgllib/dgl-ci-lint" } }
steps {
init_git_submodule()
sh "tests/scripts/task_lint.sh"
sh "bash tests/scripts/task_lint.sh"
}
}
stage("Build") {
......@@ -144,9 +151,19 @@ pipeline {
}
}
stage("Doc") {
agent { docker { image "dgllib/dgl-ci-cpu" } }
steps {
pytorch_tutorials()
parallel {
stage("TH Tutorial") {
agent { docker { image "dgllib/dgl-ci-cpu" } }
steps {
pytorch_tutorials()
}
}
stage("MX Tutorial") {
agent { docker { image "dgllib/dgl-ci-mxnet-cpu" } }
steps {
mxnet_tutorials()
}
}
}
}
}
......
.. apisampler
Sampling subgraphs from a large graph
=====================================
Graph samplers
==============
.. currentmodule:: dgl.contrib.sampling
NeighborSampler
---------------
A function that generates a subgraph loader for sampling subgraphs.
.. autofunction:: dgl.contrib.sampling.sampler.NeighborSampler
from . import backend
# One has to manually import dgl.data; fixes #125
#from . import data
from . import function
......@@ -10,6 +9,7 @@ from ._ffi.function import register_func, get_global_func, list_global_func_name
from ._ffi.base import DGLError, __version__
from .base import ALL
from .backend import load_backend
from .batched_graph import *
from .graph import DGLGraph
from .subgraph import DGLSubGraph
......
......@@ -14,11 +14,13 @@ def _gen_missing_api(api, mod_name):
' the DGLBACKEND environment.' % (api, mod_name))
return _missing_api
def _load_backend():
mod_name = os.environ.get('DGLBACKEND', 'pytorch').lower()
def load_backend(mod_name):
mod = importlib.import_module('.%s' % mod_name, __name__)
thismod = sys.modules[__name__]
for api in backend.__dict__.keys():
if api.startswith('__'):
# ignore python builtin attributes
continue
if api == 'data_type_dict':
# load data type
if api not in mod.__dict__:
......@@ -41,7 +43,7 @@ def _load_backend():
else:
setattr(thismod, api, _gen_missing_api(api, mod_name))
_load_backend()
load_backend(os.environ.get('DGLBACKEND', 'pytorch').lower())
def is_enabled(api):
"""Return true if the api is enabled by the current backend.
......
......@@ -81,7 +81,11 @@ def NeighborSampler(g, batch_size, expand_factor, num_hops=1,
neighbor_type='in', node_prob=None, seed_nodes=None,
shuffle=False, num_workers=1, max_subgraph_size=None,
return_seed_id=False):
'''
'''Create a sampler that samples neighborhood.
.. note:: This method currently only supports MXNet backend. Set
"DGLBACKEND" environment variable to "mxnet".
This creates a subgraph data loader that samples subgraphs from the input graph
with neighbor sampling. This simpling method is implemented in C and can perform
sampling very efficiently.
......@@ -127,7 +131,7 @@ def NeighborSampler(g, batch_size, expand_factor, num_hops=1,
Returns
-------
A subgraph loader that returns a list of batched subgraphs and a dictionary of
additional infomration about the subgraphs.
additional information about the subgraphs.
'''
return NSSubgraphLoader(g, batch_size, expand_factor, num_hops, neighbor_type, node_prob,
seed_nodes, shuffle, num_workers, max_subgraph_size, return_seed_id)
File mode changed from 100755 to 100644
#!/bin/sh
#!/bin/bash
# cpplint
echo 'Checking code style of C++ codes...'
......
......@@ -14,7 +14,7 @@ pip3 install -r requirements.txt || fail "installing requirements"
# Test
export MPLBACKEND=Agg
for f in $(find . -name "*.py")
for f in $(find . -name "*_mx.py")
do
echo "Running tutorial ${f} ..."
python3 $f || fail "run ${f}"
......
#!/bin/bash
# The working directory for this script will be "tests/scripts"
TUTORIAL_ROOT="../../tutorials"
function fail {
echo FAIL: $@
exit -1
}
pushd ${TUTORIAL_ROOT} > /dev/null
# Install requirements
pip3 install -r requirements.txt || fail "installing requirements"
# Test
export MPLBACKEND=Agg
for f in $(find . -name "*.py" ! -name "*_mx.py")
do
echo "Running tutorial ${f} ..."
python3 $f || fail "run ${f}"
done
popd > /dev/null
This diff is collapsed.
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment