Skip to content

Commit

Permalink
Update docs setting for rtd site
Browse files Browse the repository at this point in the history
  • Loading branch information
bichengying committed May 10, 2020
1 parent 012810d commit 50b1ab4
Show file tree
Hide file tree
Showing 6 changed files with 115 additions and 10 deletions.
2 changes: 1 addition & 1 deletion bluefog/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +1 @@
__version__ = '0.1.0'
__version__ = '0.2.0'
20 changes: 17 additions & 3 deletions docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,19 +12,25 @@
#
import os
import sys
sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath('..'))


# -- Project information -----------------------------------------------------

project = 'Bluefog'
copyright = '2019, Bicheng Ying'
copyright = '2020, Bicheng Ying'
author = 'Bicheng Ying'
master_doc = 'index'

# The full version, including alpha/beta/rc tags
release = '0.1'
from bluefog import __version__
version = __version__

# -- Mocking configuration ---------------------------------------------------

import mocks
mocks.instrument()

# -- General configuration ---------------------------------------------------

Expand All @@ -34,7 +40,8 @@
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.napoleon',
'matplotlib.sphinxext.plot_directive',
'nbsphinx',
# 'matplotlib.sphinxext.plot_directive',
]

# Include the example source for plots in API docs
Expand Down Expand Up @@ -70,6 +77,13 @@
#
html_theme = 'sphinx_rtd_theme'

html_theme_options = {
'logo_only': False,
'display_version': True,
'prev_next_buttons_location': 'bottom',
'github_url': 'https://github.com/Bluefog-Lib/bluefog',
}

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
# so a file named "default.css" will overwrite the builtin "default.css".
Expand Down
93 changes: 93 additions & 0 deletions docs/mocks.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,93 @@
# Modifications copyright (C) 2020 Bluefog Team. All Rights Reserved.
# Copyright 2019 Uber Technologies, Inc.
#
# Licensed 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.
# ==============================================================================

import sys
from unittest.mock import MagicMock


MOCK_MODULES = [
'cloudpickle',
'ctypes',
'psutil',

'numpy',
'numpy.core.multiarray',

'tensorflow',
'tensorflow.python',
'tensorflow.python.framework',
'tensorflow.python.platform',
'tensorflow.python.eager',

'torch',
'torch.autograd.function',
'torch.nn.functional',
'torch.nn.modules.batchnorm',
'torch.utils',
'torch.utils.data',
'torch.utils.tensorboard',

'bluefog.common.util',
'bluefog.torch.mpi_lib',
'bluefog.tensorflow.mpi_lib',
]


MOCK_TREE = {
'tensorflow': {
'__version__': '2.0.0',
'train': {
'Optimizer': MagicMock,
},
},
'torch': {
'__version__': '1.4.0',
},
'bluefog': {
'common': {
'util': {
'get_ext_suffix': lambda: 'xyz',
},
},
},
}


def gen_mock_package(path):
if type(path) == str:
path = path.split('.')

class TreeMock(MagicMock):
@classmethod
def __getattr__(cls, name):
full_path = path + [name]
tree_ptr = MOCK_TREE
for path_part in full_path:
if path_part in tree_ptr:
if type(tree_ptr[path_part]) != dict:
return tree_ptr[path_part]
else:
tree_ptr = tree_ptr[path_part]
else:
return MagicMock()
return gen_mock_package(full_path)

return TreeMock()


def instrument():
sys.modules.update((mod_name, gen_mock_package(mod_name))
for mod_name in MOCK_MODULES)
4 changes: 1 addition & 3 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,4 +1,2 @@
bluefog
matplotlib
torch
tensorflow
networkx
2 changes: 1 addition & 1 deletion docs/timeline.rst
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ improve the training efficiency in real practice.
Example III: Resnet training with one-sided communication
---------------------------------------------------------
In this example, we show the timeline for a real experiment when decentralized SGD is used to
train Resnet with CIFAR10 dataset. We exploit the one-sided communicaton primitive ``win_put''
train Resnet with CIFAR10 dataset. We exploit the one-sided communicaton primitive ``win_put``
to exchange information between ranks. It is observed that each phase during the training
is clearly illustrated in the timeline.

Expand Down
4 changes: 2 additions & 2 deletions setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,15 +29,15 @@

from setuptools import find_packages, setup, Extension
from setuptools.command.build_ext import build_ext as _build_ext

from bluefog import __version__

# Package meta-data.
NAME = "bluefog"
DESCRIPTION = "A distributed training framework for diffusion or consensus-type algorithm."
EMAIL = "bichengying@gmail.com"
AUTHOR = "Bicheng Ying"
REQUIRES_PYTHON = ">=3.7.0"
VERSION = "0.2.0"
VERSION = __version__

EXTRAS = {}

Expand Down

0 comments on commit 50b1ab4

Please sign in to comment.