From 2f3850ee260b01585637eedfa10a59f3f8bf74d0 Mon Sep 17 00:00:00 2001 From: atalman Date: Tue, 16 May 2023 07:53:41 -0700 Subject: [PATCH 1/7] Build docs in GHA --- .github/workflows/build-docs.yml | 0 1 file changed, 0 insertions(+), 0 deletions(-) create mode 100644 .github/workflows/build-docs.yml diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml new file mode 100644 index 0000000000..e69de29bb2 From d2783d1b554c887064bb1a8f37c6eba49eb62c97 Mon Sep 17 00:00:00 2001 From: atalman Date: Tue, 16 May 2023 07:57:33 -0700 Subject: [PATCH 2/7] Save file --- .github/workflows/build-docs.yml | 107 +++++++++++++++++++++++++++++++ 1 file changed, 107 insertions(+) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index e69de29bb2..b41d5a6cd0 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -0,0 +1,107 @@ +name: Build documentation + +on: + pull_request: + push: + branches: + - nightly + - main + - release/* + tags: + - v[0-9]+.[0-9]+.[0-9] + - v[0-9]+.[0-9]+.[0-9]+-rc[0-9]+ + workflow_dispatch: + +jobs: + build: + strategy: + matrix: + python_version: ["3.8"] + fail-fast: false + uses: pytorch/test-infra/.github/workflows/linux_job.yml@main + with: + job-name: Build doc + runner: linux.2xlarge + repository: pytorch/text + gpu-arch-type: cpu + timeout: 120 + upload-artifact: docs + + script: | + # Mark Build Directory Safe + git config --global --add safe.directory /__w/text/text + + # Set up Environment Variables + export PYTHON_VERSION="${{ matrix.python_version }}" + + # Set CHANNEL + if [[(${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then + export CHANNEL=test + else + export CHANNEL=nightly + fi + + # Create Conda Env + conda create --quiet -y --prefix ci_env python="${PYTHON_VERSION}" + conda activate ./ci_env + + # Install PyTorch + set -ex + set +u # don't know why + conda install \ + --yes \ + --quiet \ + pytorch cpuonly \ + -c "pytorch-${CHANNEL}" + + + pip --quiet install cmake>=3.18.0 ninja + cd packaging + . ./pkg_helpers.bash + setup_build_version + cd ../ + + + # Install build tools + conda install --quiet -y -c conda-forge pandoc doxygen pysoundfile + pip install --quiet -r docs/requirements.txt -r docs/requirements-tutorials.txt + + # Build docs + export BUILD_GALLERY=true + (cd docs && make html) + + cp -rf docs/build/html/* "${RUNNER_DOCS_DIR}" + mv docs/build/html /artifacts/ + + commit: + if: ${{ (github.repository == 'pytorch/text') && ((github.event_name == 'push') && (github.ref_name == 'nightly')) }} + permissions: + # Required for `git push` + # Note: + # This is not effective from fork. + # When you debug this, make sure to make a branch on pytorch and + # make PR from there. + contents: write + runs-on: ubuntu-latest + needs: build + steps: + - uses: actions/checkout@v3 + with: + ref: gh-pages + - uses: actions/download-artifact@v3 + with: + name: docs + - name: Update nightly doc + run: | + set -x + + # TODO: add tag-based process (need to handle the main directory name) + rm -rf main + mv html main + + # Update the main doc + git add --all main || true + git config user.name "pytorchbot" + git config user.email "soumith+bot@pytorch.org" + git commit -m "auto-generating sphinx docs" || true + git push From 9aeb094de5780df6af26c0e9b98203fc679adfda Mon Sep 17 00:00:00 2001 From: atalman Date: Tue, 16 May 2023 08:09:40 -0700 Subject: [PATCH 3/7] fix build docs --- .github/workflows/build-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index b41d5a6cd0..8aa9f2e407 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -64,7 +64,7 @@ jobs: # Install build tools conda install --quiet -y -c conda-forge pandoc doxygen pysoundfile - pip install --quiet -r docs/requirements.txt -r docs/requirements-tutorials.txt + pip install --quiet -r docs/requirements.txt # Build docs export BUILD_GALLERY=true From c6d220328998217f767f958cb7f5b6b758abb052 Mon Sep 17 00:00:00 2001 From: atalman Date: Tue, 16 May 2023 08:50:42 -0700 Subject: [PATCH 4/7] Fix install docs --- .github/workflows/build-docs.yml | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 8aa9f2e407..1f7beeb083 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -51,15 +51,10 @@ jobs: conda install \ --yes \ --quiet \ - pytorch cpuonly \ + pytorch torchtext cpuonly \ -c "pytorch-${CHANNEL}" - pip --quiet install cmake>=3.18.0 ninja - cd packaging - . ./pkg_helpers.bash - setup_build_version - cd ../ # Install build tools @@ -68,7 +63,7 @@ jobs: # Build docs export BUILD_GALLERY=true - (cd docs && make html) + (cd docs && make make 'SPHINXOPTS=-W' html) cp -rf docs/build/html/* "${RUNNER_DOCS_DIR}" mv docs/build/html /artifacts/ From 2965061913d40c6d6b1ed1ea16fca4b292a8cc51 Mon Sep 17 00:00:00 2001 From: atalman Date: Tue, 16 May 2023 09:16:02 -0700 Subject: [PATCH 5/7] test --- .github/workflows/build-docs.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 1f7beeb083..60d6422140 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -63,7 +63,7 @@ jobs: # Build docs export BUILD_GALLERY=true - (cd docs && make make 'SPHINXOPTS=-W' html) + (cd docs && make 'SPHINXOPTS=-W' html) cp -rf docs/build/html/* "${RUNNER_DOCS_DIR}" mv docs/build/html /artifacts/ From 6627534a49d5dec14deb3797c3272fd1387dcfa1 Mon Sep 17 00:00:00 2001 From: atalman Date: Tue, 16 May 2023 09:30:00 -0700 Subject: [PATCH 6/7] Build docs setup verison --- .github/workflows/build-docs.yml | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index 60d6422140..bd599e3e09 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -56,11 +56,17 @@ jobs: pip --quiet install cmake>=3.18.0 ninja + cd packaging + . ./pkg_helpers.bash + setup_build_version + cd ../ # Install build tools conda install --quiet -y -c conda-forge pandoc doxygen pysoundfile pip install --quiet -r docs/requirements.txt + + # Build docs export BUILD_GALLERY=true (cd docs && make 'SPHINXOPTS=-W' html) From fd6bdb5975cde50bfab5ebe80f05d5844171315e Mon Sep 17 00:00:00 2001 From: atalman Date: Tue, 16 May 2023 09:40:57 -0700 Subject: [PATCH 7/7] Adding doc uild --- .github/workflows/build-docs.yml | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/.github/workflows/build-docs.yml b/.github/workflows/build-docs.yml index bd599e3e09..3ea03dd7a1 100644 --- a/.github/workflows/build-docs.yml +++ b/.github/workflows/build-docs.yml @@ -14,10 +14,6 @@ on: jobs: build: - strategy: - matrix: - python_version: ["3.8"] - fail-fast: false uses: pytorch/test-infra/.github/workflows/linux_job.yml@main with: job-name: Build doc @@ -26,13 +22,12 @@ jobs: gpu-arch-type: cpu timeout: 120 upload-artifact: docs - script: | # Mark Build Directory Safe git config --global --add safe.directory /__w/text/text # Set up Environment Variables - export PYTHON_VERSION="${{ matrix.python_version }}" + export PYTHON_VERSION="3.8" # Set CHANNEL if [[(${GITHUB_EVENT_NAME} = 'pull_request' && (${GITHUB_BASE_REF} = 'release'*)) || (${GITHUB_REF} = 'refs/heads/release'*) ]]; then @@ -65,8 +60,6 @@ jobs: conda install --quiet -y -c conda-forge pandoc doxygen pysoundfile pip install --quiet -r docs/requirements.txt - - # Build docs export BUILD_GALLERY=true (cd docs && make 'SPHINXOPTS=-W' html)