Skip to content
Permalink
Browse files

Add ReadTheDocs (#1010)

* Add ReadTheDocs

Signed-off-by: Alex Sergeev <alsrgv@users.noreply.github.com>

* Add docs building to Buildkite

Signed-off-by: Alex Sergeev <alsrgv@users.noreply.github.com>
  • Loading branch information...
alsrgv committed Apr 13, 2019
1 parent 6cc9ca7 commit abc3d885448ea5fef1e8a6c088ba1586720286b3
@@ -135,6 +135,19 @@ run_all() {
fi
}

build_docs() {
echo "- label: ':book: Build Docs'"
echo " command: 'cd /workdir/docs && pip install -r requirements.txt && make html'"
echo " plugins:"
echo " - docker#v3.1.0:"
echo " image: 'python:3.7'"
echo " timeout_in_minutes: 5"
echo " retry:"
echo " automatic: true"
echo " agents:"
echo " queue: cpu"
}

# begin the pipeline.yml file
echo "steps:"

@@ -143,6 +156,9 @@ for test in ${tests[@]}; do
build_test "${test}"
done

# build documentation
build_docs

# wait for all builds to finish
echo "- wait"

@@ -4,6 +4,7 @@
horovod.egg-info
dist
build
docs/_build
.vscode/
env
examples/checkpoint*
@@ -0,0 +1,32 @@
# Copyright (c) 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.
# ==============================================================================
#
# ReadTheDocs.io build configuration: supply addition pip install options
#
version: 2

# Sphinx configuration
sphinx:
configuration: docs/conf.py
fail_on_warning: true

# Don't build any extra formats
formats: []

# Requirements for building docs
python:
version: 3.7
install:
- requirements: docs/requirements.txt
@@ -0,0 +1,19 @@
# Minimal makefile for Sphinx documentation
#

# You can set these variables from the command line.
SPHINXOPTS = -W
SPHINXBUILD = sphinx-build
SOURCEDIR = .
BUILDDIR = _build

# Put it first so that "make" without argument is like "make help".
help:
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)

.PHONY: help Makefile

# Catch-all target: route all unknown targets to Sphinx using the new
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
%: Makefile
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
No changes.
BIN +162 KB docs/_static/logo.png
Binary file not shown.
No changes.
@@ -0,0 +1,26 @@
API
===

horovod.tensorflow
------------------
.. automodule:: horovod.tensorflow

horovod.tensorflow.keras
------------------------
.. automodule:: horovod.tensorflow.keras

horovod.keras
-------------
.. automodule:: horovod.keras

horovod.torch
-------------
.. automodule:: horovod.torch

horovod.mxnet
-------------
.. automodule:: horovod.mxnet

horovod.spark
-------------
.. automodule:: horovod.spark
@@ -0,0 +1,97 @@
# Configuration file for the Sphinx documentation builder.
#
# This file only contains a selection of the most common options. For a full
# list see the documentation:
# http://www.sphinx-doc.org/en/master/config

# -- Path setup --------------------------------------------------------------

# If extensions (or modules to document with autodoc) are in another directory,
# add these directories to sys.path here. If the directory is relative to the
# documentation root, use os.path.abspath to make it absolute, like shown here.
#
import os
import sys
sys.path.insert(0, os.path.abspath('.'))
sys.path.insert(0, os.path.abspath('..'))


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

project = 'Horovod'
copyright = '2019, The Horovod Authors'
author = 'The Horovod Authors'

from horovod import __version__
version = __version__


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

import mocks
mocks.instrument()


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

# Add any Sphinx extension module names here, as strings. They can be
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
# ones.
extensions = [
'sphinx.ext.autodoc',
'sphinx.ext.viewcode',
'sphinxcontrib.napoleon',
]

# Add any paths that contain templates here, relative to this directory.
templates_path = ['_templates']

# The master toctree document.
master_doc = 'index'

# List of patterns, relative to source directory, that match files and
# directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path.
exclude_patterns = ['_build', 'Thumbs.db', '.DS_Store']


# -- Autodoc configuration ---------------------------------------------------

autodoc_default_options = {
'members': None,
'member-order': 'bysource',
'special-members': '__init__',
'imported-members': None,
'undoc-members': None,
}


# -- Options for HTML output -------------------------------------------------

# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.
#
html_theme = 'alabaster'

# Theme options are theme-specific and customize the look and feel of a theme
# further. For a list of options available for each theme, see the
# documentation.
#
# For alabaster: https://alabaster.readthedocs.io/en/latest/customization.html
#
html_theme_options = {
'logo': 'logo.png',
'description': 'Distributed training framework for TensorFlow, Keras, PyTorch, and Apache MXNet.',
'github_user': 'horovod',
'github_repo': 'horovod',
'github_button': True,
'github_type': 'star',
'github_count': 'true',
'fixed_sidebar': True,
'sidebar_collapse': True,
}

# 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".
html_static_path = ['_static']
@@ -0,0 +1,14 @@
Welcome to Horovod's documentation!
===================================

.. toctree::
:maxdepth: 2

api

Indices and tables
==================

* :ref:`genindex`
* :ref:`modindex`
* :ref:`search`
@@ -0,0 +1,35 @@
@ECHO OFF

pushd %~dp0

REM Command file for Sphinx documentation

if "%SPHINXBUILD%" == "" (
set SPHINXBUILD=sphinx-build
)
set SOURCEDIR=.
set BUILDDIR=_build

if "%1" == "" goto help

%SPHINXBUILD% >NUL 2>NUL
if errorlevel 9009 (
echo.
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
echo.installed, then set the SPHINXBUILD environment variable to point
echo.to the full path of the 'sphinx-build' executable. Alternatively you
echo.may add the Sphinx directory to PATH.
echo.
echo.If you don't have Sphinx installed, grab it from
echo.http://sphinx-doc.org/
exit /b 1
)

%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%
goto end

:help
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS%

:end
popd
@@ -0,0 +1,101 @@
# 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',
'pyspark',

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

'keras',
'keras.backend',

'torch',

'mxnet',
'mxnet.base',

'horovod.common.util',
'horovod.torch.mpi_lib_v2',
]


MOCK_TREE = {
'tensorflow': {
'__version__': '1.12.0',
'train': {
'Optimizer': MagicMock,
'SessionRunMock': MagicMock,
},
'keras': {
'callbacks': {
'Callback': MagicMock,
},
},
},
'keras': {
'callbacks': {
'Callback': MagicMock,
},
},
'torch': {
'__version__': '1.0.0',
},
'horovod': {
'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)
@@ -0,0 +1,3 @@
git+https://github.com/alsrgv/sphinx@horovod
sphinxcontrib-napoleon
alabaster
Oops, something went wrong.

0 comments on commit abc3d88

Please sign in to comment.
You can’t perform that action at this time.