Skip to content

Commit

Permalink
[Doc] Build docs and push to branch in CI (pytorch#1006)
Browse files Browse the repository at this point in the history
  • Loading branch information
mattip committed Nov 13, 2020
1 parent 0e1d814 commit 8d0c08d
Show file tree
Hide file tree
Showing 6 changed files with 181 additions and 1 deletion.
13 changes: 13 additions & 0 deletions .circleci/build_docs/build_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#!/usr/bin/env bash

set -ex
source ./packaging/pkg_helpers.bash
export NO_CUDA_PACKAGE=1
setup_env 0.8.0
setup_wheel_python

pushd docs
pip install -r requirements.txt
make html
popd

33 changes: 33 additions & 0 deletions .circleci/build_docs/commit_docs.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
#!/usr/bin/env bash

set -ex


if [ "$2" == "" ]; then
echo call as $0 "<src>" "<target branch>"
echo where src is the built documentation and
echo branch should be "master" or "1.7" or so
exit 1
fi

scr=$1
target=$2

set -ex
echo "committing docs from ${stc} to ${target}"

git checkout gh-pages
rm -rf docs/$target/*
cp -r ${src}/build/html/* docs/$target
if [ $target == "master" ]; then
rm -rf docs/_static/*
cp -r ${src}/build/html/_static/* docs/_static
fi
git add docs || true
git config user.email "soumith+bot@pytorch.org"
git config user.name "pytorchbot"
# If there aren't changes, don't make a commit; push is no-op
git commit -m "auto-generating sphinx docs" || true
git push -u origin gh-pages


9 changes: 9 additions & 0 deletions .circleci/build_docs/install_wheels.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
set -ex
source ./packaging/pkg_helpers.bash
export NO_CUDA_PACKAGE=1
setup_env 0.8.0
setup_wheel_python
setup_pip_pytorch_version
# pytorch is already installed
pip install --no-deps ~/workspace/torchaudio*

56 changes: 56 additions & 0 deletions .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,46 @@ jobs:
command: |
.circleci/torchscript_bc_test/setup_master_envs.sh
.circleci/torchscript_bc_test/validate_objects.sh
build_docs:
<<: *binary_common
docker:
- image: "pytorch/manylinux-cuda100"
resource_class: 2xlarge+
steps:
- attach_workspace:
at: ~/workspace
- designate_upload_channel
- checkout
- run:
name: Install pytorch-audio
command: .circleci/build_docs/install_wheels.sh
- run:
name: Build docs
command: .circleci/build_docs/build_docs.sh
- persist_to_workspace:
root: docs
paths:
- "*"

upload_docs:
<<: *binary_common
docker:
- image: "pytorch/manylinux-cuda100"
resource_class: 2xlarge+
steps:
- attach_workspace:
at: ~/workspace
- designate_upload_channel
- checkout
- run:
name: Upload docs
command: |
set -ex
echo $PWD
ls ~/workspace
tag=${CIRCLE_TAG:1:5}
target=${tag:-master}
.circleci/build_docs/commit_docs.sh ~/workspace $target
workflows:
build:
Expand Down Expand Up @@ -739,6 +779,22 @@ workflows:
- binary_windows_conda:
name: binary_windows_conda_py3.8
python_version: '3.8'
- build_docs:
name: build_docs
python_version: '3.8'
requires:
- binary_linux_wheel_py3.8
- upload_docs:
filters:
branches:
only:
- nightly
tags:
only: /v[0-9]+(\.[0-9]+)*-rc[0-9]+/
name: upload_docs
python_version: '3.8'
requires:
- build_docs
unittest:
jobs:
- torchscript_bc_test:
Expand Down
40 changes: 40 additions & 0 deletions .circleci/config.yml.in
Original file line number Diff line number Diff line change
Expand Up @@ -654,6 +654,46 @@ jobs:
command: |
.circleci/torchscript_bc_test/setup_master_envs.sh
.circleci/torchscript_bc_test/validate_objects.sh
build_docs:
<<: *binary_common
docker:
- image: "pytorch/manylinux-cuda100"
resource_class: 2xlarge+
steps:
- attach_workspace:
at: ~/workspace
- designate_upload_channel
- checkout
- run:
name: Install pytorch-audio
command: .circleci/build_docs/install_wheels.sh
- run:
name: Build docs
command: .circleci/build_docs/build_docs.sh
- persist_to_workspace:
root: docs
paths:
- "*"

upload_docs:
<<: *binary_common
docker:
- image: "pytorch/manylinux-cuda100"
resource_class: 2xlarge+
steps:
- attach_workspace:
at: ~/workspace
- designate_upload_channel
- checkout
- run:
name: Upload docs
command: |
set -ex
echo $PWD
ls ~/workspace
tag=${CIRCLE_TAG:1:5}
target=${tag:-master}
.circleci/build_docs/commit_docs.sh ~/workspace $target

workflows:
build:
Expand Down
31 changes: 30 additions & 1 deletion .circleci/regenerate.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@

PYTHON_VERSIONS = ["3.6", "3.7", "3.8"]

DOC_VERSION = ('linux', '3.8')


def build_workflows(prefix='', upload=False, filter_branch=None, indentation=6):
w = []
Expand All @@ -30,6 +32,11 @@ def build_workflows(prefix='', upload=False, filter_branch=None, indentation=6):
for python_version in PYTHON_VERSIONS:
w += build_workflow_pair(btype, os_type, python_version, filter_branch, prefix, upload)

if not filter_branch:
# Build on every pull request, but upload only on nightly and tags
w += build_doc_job(None)
w += upload_doc_job('nightly')

return indent(indentation, w)


Expand Down Expand Up @@ -67,6 +74,28 @@ def build_workflow_pair(btype, os_type, python_version, filter_branch, prefix=''

return w

def build_doc_job(filter_branch):
job = {
"name": "build_docs",
"python_version": "3.8",
"requires": ["binary_linux_wheel_py3.8",],
}

if filter_branch:
job["filters"] = gen_filter_branch_tree(filter_branch)
return [{"build_docs": job}]

def upload_doc_job(filter_branch):
job = {
"name": "upload_docs",
"python_version": "3.8",
"requires": ["build_docs",],
}

if filter_branch:
job["filters"] = gen_filter_branch_tree(filter_branch)
return [{"upload_docs": job}]


def generate_base_workflow(base_workflow_name, python_version, filter_branch, os_type, btype):

Expand All @@ -81,7 +110,7 @@ def generate_base_workflow(base_workflow_name, python_version, filter_branch, os
if filter_branch:
d["filters"] = gen_filter_branch_tree(filter_branch)

return {"binary_{os_type}_{btype}".format(os_type=os_type, btype=btype): d}
return {f"binary_{os_type}_{btype}": d}


def gen_filter_branch_tree(*branches):
Expand Down

0 comments on commit 8d0c08d

Please sign in to comment.