Skip to content

Commit

Permalink
ci/docs: build & upload (#1673)
Browse files Browse the repository at this point in the history
* build & upload
* cache
* tokenizer
* torch
  • Loading branch information
Borda authored Mar 31, 2023
1 parent c553325 commit 6f32caf
Show file tree
Hide file tree
Showing 5 changed files with 164 additions and 133 deletions.
1 change: 1 addition & 0 deletions .github/workflows/ci-tests-full.yml
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ jobs:
PYTORCH_URL: "https://download.pytorch.org/whl/cpu/torch_stable.html"
FREEZE_REQUIREMENTS: ${{ ! (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')) }}
PYPI_CACHE: "_ci-cache_PyPI"
TOKENIZERS_PARALLELISM: false

# Timeout: https://stackoverflow.com/a/59076067/4521646
# seems that MacOS jobs take much more than orger OS
Expand Down
161 changes: 161 additions & 0 deletions .github/workflows/docs-build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,161 @@
name: Build Docs

on:
push:
branches: ["master", "release/*"]
tags: ["*"]
# use this event type to share secrets with forks.
# it's important that the PR head SHA is checked out to run the changes
pull_request:
branches: ["master", "release/*"]
paths:
- ".github/workflows/docs-build.yml"
- "requirements/**"
- "docs/**"
- "src/**"
- "setup.py"
- "pyproject.toml" # includes metadata used in the package creation
- "!*.md"
- "!**/*.md"

concurrency:
group: ${{ github.workflow }}-${{ github.ref }}-${{ github.head_ref }}
cancel-in-progress: ${{ ! (github.ref == 'refs/heads/master' || startsWith(github.ref, 'refs/heads/release/')) }}

defaults:
run:
shell: bash

env:
FREEZE_REQUIREMENTS: "1"
TORCH_URL: "https://download.pytorch.org/whl/cpu/torch_stable.html"
PYPI_CACHE: "_ci-cache_PyPI"
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: 'python'
TOKENIZERS_PARALLELISM: false

jobs:
make-doctest:
runs-on: ubuntu-20.04
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.8

- name: source cashing
uses: ./.github/actions/pull-caches
with:
requires: ${{ matrix.requires }}
pytorch-version: ${{ matrix.pytorch-version }}
pypi-dir: ${{ env.PYPI_CACHE }}

- name: Install package & dependencies
run: |
sudo apt-get update && sudo apt-get install -y cmake
pip --version
pip install . -U -r requirements/docs.txt --find-links $PYPI_CACHE -f $TORCH_URL
pip list
- name: Test Documentation
env:
SPHINX_MOCK_REQUIREMENTS: 0
working-directory: ./docs
run: |
make doctest
make coverage
make-html:
runs-on: ubuntu-20.04
timeout-minutes: 20
steps:
- uses: actions/checkout@v3
- uses: actions/setup-python@v4
with:
python-version: 3.8

- name: source cashing
uses: ./.github/actions/pull-caches
with:
requires: ${{ matrix.requires }}
pytorch-version: ${{ matrix.pytorch-version }}
pypi-dir: ${{ env.PYPI_CACHE }}

# Note: This uses an internal pip API and may not always work
# https://github.com/actions/cache/blob/master/examples.md#multiple-oss-in-a-workflow
- name: Cache pip
uses: actions/cache@v3
with:
path: ~/.cache/pip
key: ${{ runner.os }}-pip-${{ hashFiles('requirements.txt') }}-${{ hashFiles('requirements/docs.txt') }}
restore-keys: ${{ runner.os }}-pip-

- name: Install dependencies & package
run: |
# install Texlive, see https://linuxconfig.org/how-to-install-latex-on-ubuntu-20-04-focal-fossa-linux
sudo apt-get update
sudo apt-get install -y texlive-latex-extra dvipng texlive-pictures texlive-fonts-recommended cm-super
pip --version
pip install . -U -r requirements/docs.txt --find-links $PYPI_CACHE -f $TORCH_URL
pip list
shell: bash

- name: Make Documentation
working-directory: ./docs
run: make html --debug SPHINXOPTS="-W --keep-going"

- name: Check External Links (Optional)
working-directory: ./docs
run: make --jobs $(nproc) linkcheck
# ToDO: comment on PR if any link failed
continue-on-error: true

- name: Upload built docs
uses: actions/upload-artifact@v3
with:
name: docs-${{ github.sha }}
path: docs/build/
retention-days: ${{ steps.keep-artifact.outputs.DAYS }}

- name: update cashing
if: ${{ github.event_name == 'push' && github.ref == 'refs/heads/master' }}
uses: ./.github/actions/push-caches
with:
pypi-dir: ${{ env.PYPI_CACHE }}


deploy-docs:
needs: [make-doctest, make-html]
if: github.repository_owner == 'Lightning-AI' && github.event_name == 'push'
runs-on: ubuntu-latest
steps:
- uses: actions/download-artifact@v3
with:
name: docs-${{ github.sha }}
path: docs/build/

- name: Authenticate to Google Cloud
uses: google-github-actions/auth@v1
with:
credentials_json: ${{ secrets.GCS_SA_KEY }}

- name: Setup gcloud
uses: google-github-actions/setup-gcloud@v1
with:
project_id: ${{ secrets.GCS_PROJECT }}

# Uploading docs to GCS, so they can be served on lightning.ai
- name: Upload docs/metrics/stable to GCS 🪣
if: startsWith(github.ref, 'refs/heads/release/')
run: gsutil -m rsync -d -R docs/build/html/ gs://lightning-docs-metrics/stable

# Uploading docs to GCS, so they can be served on lightning.ai
- name: Upload docs/metrics/latest to GCS 🪣
if: github.ref == 'refs/heads/master'
run: gsutil -m rsync -d -R docs/build/html/ gs://lightning-docs-metrics/latest

# Uploading docs to GCS, so they can be served on lightning.ai
- name: Upload docs/metrics/release to GCS 🪣
if: startsWith(github.ref, 'refs/tags/')
run: gsutil -m rsync -d -R docs/build/html/ gs://lightning-docs-metrics/${{ github.ref_name }}
132 changes: 0 additions & 132 deletions .github/workflows/docs-check.yml

This file was deleted.

2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ ______________________________________________________________________
[![license](https://img.shields.io/badge/License-Apache%202.0-blue.svg)](https://github.com/Lightning-AI/metrics/blob/master/LICENSE)

[![CI testing - complete](https://github.com/Lightning-AI/metrics/actions/workflows/ci-tests-full.yml/badge.svg?event=push)](https://github.com/Lightning-AI/metrics/actions/workflows/ci-tests-full.yml)
[![Build Status](https://dev.azure.com/Lightning-AI/Metrics/_apis/build/status/Lightning-AI.metrics?branchName=master)](https://dev.azure.com/Lightning-AI/Metrics/_build/latest?definitionId=3&branchName=master)
[![Build Status](https://dev.azure.com/Lightning-AI/Metrics/_apis/build/status%2FLightning-AI.torchmetrics?branchName=master)](https://dev.azure.com/Lightning-AI/Metrics/_build/latest?definitionId=50&branchName=master)
[![codecov](https://codecov.io/gh/Lightning-AI/metrics/branch/master/graph/badge.svg?token=NER6LPI3HS)](https://codecov.io/gh/Lightning-AI/metrics)

[![Slack](https://img.shields.io/badge/slack-chat-green.svg?logo=slack)](https://www.pytorchlightning.ai/community)
Expand Down
1 change: 1 addition & 0 deletions src/torchmetrics/text/bert.py
Original file line number Diff line number Diff line change
Expand Up @@ -279,6 +279,7 @@ def plot(
:scale: 75
>>> # Example plotting multiple values
>>> import torch
>>> from torchmetrics.text.bert import BERTScore
>>> metric = BERTScore()
>>> preds = ["hello there", "general kenobi"]
Expand Down

0 comments on commit 6f32caf

Please sign in to comment.