From 498505bafb0d614762a40560ee29d798a24153f8 Mon Sep 17 00:00:00 2001 From: "Quan (Andy) Gan" Date: Tue, 12 Jan 2021 17:55:58 +0800 Subject: [PATCH] [Doc] fix docserver build for tutorials (#2518) * fix doc build * hide GPU code --- docs/Makefile | 10 +++++++++- new-tutorial/1_introduction.py | 10 ++++++---- python/dgl/nn/__init__.py | 10 +--------- 3 files changed, 16 insertions(+), 14 deletions(-) diff --git a/docs/Makefile b/docs/Makefile index 6d15dc1a990a..5c828d7c9827 100644 --- a/docs/Makefile +++ b/docs/Makefile @@ -29,12 +29,20 @@ pytorch: @echo "##################################################################" @DGLBACKEND=pytorch DGL_LOADALL=true $(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) +tensorflow: + @echo "##################################################################" + @echo "# #" + @echo "# Step 3: Building Tensorflow tutorials #" + @echo "# #" + @echo "##################################################################" + @DGLBACKEND=tensorflow DGL_LOADALL=true $(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O) + html-noexec: DGL_LOADALL=true $(SPHINXBUILD) -D plot_gallery=0 -b html "$(SOURCEDIR)" "$(BUILDDIR)/html" @echo @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." -html: Makefile mxnet pytorch +html: Makefile mxnet pytorch tensorflow # Catch-all target: route all unknown targets to Sphinx using the new # "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS). diff --git a/new-tutorial/1_introduction.py b/new-tutorial/1_introduction.py index 74a33aa2519f..e57080366b20 100644 --- a/new-tutorial/1_introduction.py +++ b/new-tutorial/1_introduction.py @@ -192,10 +192,12 @@ def train(g, model): # Training on GPU requires to put both the model and the graph onto GPU # with the ``to`` method, similar to what you will do in PyTorch. # - -g = g.to('cuda') -model = GCN(g.ndata['feat'].shape[1], 16, dataset.num_classes).to('cuda') -train(g, model) +# .. code:: python +# +# g = g.to('cuda') +# model = GCN(g.ndata['feat'].shape[1], 16, dataset.num_classes).to('cuda') +# train(g, model) +# ###################################################################### diff --git a/python/dgl/nn/__init__.py b/python/dgl/nn/__init__.py index f3262a3524b4..050d358cfe7c 100644 --- a/python/dgl/nn/__init__.py +++ b/python/dgl/nn/__init__.py @@ -25,12 +25,4 @@ def _load_backend(mod_name): for api, obj in mod.__dict__.items(): setattr(thismod, api, obj) - -LOAD_ALL = os.getenv("DGL_LOADALL", "False") - -if LOAD_ALL.lower() != "false": - from .mxnet import * - from .pytorch import * - from .tensorflow import * -else: - _load_backend(backend_name) +_load_backend(backend_name)