Skip to content

Commit

Permalink
Merge branch 'master' into master
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda authored Sep 21, 2023
2 parents e824d84 + e2150c5 commit 5e129d2
Show file tree
Hide file tree
Showing 10 changed files with 75 additions and 33 deletions.
15 changes: 12 additions & 3 deletions .devcontainer/Dockerfile
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,21 @@ FROM mcr.microsoft.com/vscode/devcontainers/python:${VARIANT}

# [Choice] Node.js version: none, lts/*, 16, 14, 12, 10
ARG NODE_VERSION="none"
RUN if [ "${NODE_VERSION}" != "none" ]; then su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; fi
RUN if [ "${NODE_VERSION}" != "none" ]; then \
su vscode -c "umask 0002 && . /usr/local/share/nvm/nvm.sh && nvm install ${NODE_VERSION} 2>&1"; \
fi

COPY requirements/ /tmp/pip-tmp/requirements/
COPY requirements.txt /tmp/pip-tmp/
RUN pip3 --disable-pip-version-check --no-cache-dir install -r /tmp/pip-tmp/requirements/devel.txt -r /tmp/pip-tmp/requirements/docs.txt \
&& rm -rf /tmp/pip-tmp
RUN \
pip3 install awscli && \
aws s3 sync --no-sign-request s3://sphinx-packages/ dist/ && \
pip3 --disable-pip-version-check --no-cache-dir install \
-r /tmp/pip-tmp/requirements/devel.txt \
-r /tmp/pip-tmp/requirements/docs.txt \
--find-links="https://download.pytorch.org/whl/cpu/torch_stable.html" \
--find-links="dist/" && \
rm -rf /tmp/pip-tmp

# [Optional] If your pip requirements rarely change, uncomment this section to add them to the image.
# COPY requirements.txt /tmp/pip-tmp/
Expand Down
1 change: 1 addition & 0 deletions .github/labeling-config.yml
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
documentation:
- docs/**/*
- README.md

"topic: Audio":
- src/torchmetrics/audio/*
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,9 @@
"ignorePatterns": [
{
"pattern": "^https://github.com/Lightning-AI/torchmetrics/pull/.*"
},
{
"pattern": ".*https://dev.azure.com/Lightning-AI/Metrics/_apis/build/status.*"
}
],
"httpHeaders": [
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ci-checks.yml
Original file line number Diff line number Diff line change
Expand Up @@ -36,4 +36,4 @@ jobs:
check-md-links:
uses: Lightning-AI/utilities/.github/workflows/[email protected]
with:
config-file: ".github/markdown.links.config.json"
config-file: ".github/markdown-links-config.json"
21 changes: 12 additions & 9 deletions .github/workflows/docs-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,8 @@ env:
PYPI_CACHE: "_ci-cache_PyPI"
PROTOCOL_BUFFERS_PYTHON_IMPLEMENTATION: "python"
TOKENIZERS_PARALLELISM: false
SPHINX_MOCK_REQUIREMENTS: 0
SPHINX_FETCH_ASSETS: 0

jobs:
docs-make:
Expand All @@ -30,8 +32,6 @@ jobs:
fail-fast: false
matrix:
check: [html, doctest, linkcheck]
env:
SPHINX_MOCK_REQUIREMENTS: 0
timeout-minutes: 30
steps:
- uses: actions/checkout@v3
Expand All @@ -50,24 +50,26 @@ jobs:
if: ${{ matrix.check == 'html' }}
# install Texlive, see https://linuxconfig.org/how-to-install-latex-on-ubuntu-20-04-focal-fossa-linux
run: |
sudo apt-get update
sudo apt-get update --fix-missing
sudo apt-get install -y \
texlive-latex-extra texlive-pictures texlive-fonts-recommended dvipng cm-super
- name: Pull sphinx template
run: |
pip install awscli
aws s3 sync --no-sign-request s3://sphinx-packages/ dist/
- name: Install package & dependencies
run: |
sudo apt-get update --fix-missing
sudo apt-get install -y cmake
pip --version
pip install . -U -r requirements/docs.txt \
--find-links=${PYPI_CACHE} --find-links=${TORCH_URL}
--find-links="${PYPI_CACHE}" --find-links="${TORCH_URL}" --find-links="dist/"
pip list
- name: Test Examples in Documentation
if: ${{ matrix.check == 'doctest' }}
working-directory: ./docs
env:
SPHINX_FETCH_ASSETS: 0
run: |
make doctest
make coverage
Expand All @@ -76,14 +78,15 @@ jobs:
if: ${{ matrix.check == 'linkcheck' }}
working-directory: ./docs
env:
SPHINX_FETCH_ASSETS: 0
SPHINX_MOCK_REQUIREMENTS: 1
run: make --jobs $(nproc) linkcheck SPHINXOPTS="--keep-going"

- name: Full build for deployment
if: github.event_name == 'push'
run: echo "SPHINX_FETCH_ASSETS=1" >> $GITHUB_ENV
- name: Make Documentation
if: ${{ matrix.check == 'html' }}
working-directory: ./docs
env:
SPHINX_FETCH_ASSETS: 1
run: make html --debug SPHINXOPTS="-W --keep-going"

- name: Upload built docs
Expand Down
40 changes: 27 additions & 13 deletions .readthedocs.yml
Original file line number Diff line number Diff line change
@@ -1,3 +1,17 @@
# Copyright The Lightning AI team.
#
# 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.yml
# Read the Docs configuration file
# See https://docs.readthedocs.io/en/stable/config-file/v2.html for details
Expand All @@ -6,23 +20,23 @@
version: 2

# Build documentation in the docs/ directory with Sphinx
# reference: https://docs.readthedocs.io/en/stable/config-file/v2.html#sphinx
sphinx:
configuration: docs/source/conf.py
fail_on_warning: true

# Optionally build your docs in additional formats such as PDF and ePub
formats:
- htmlzip
# - pdf # building both takes too log :(

build:
os: "ubuntu-22.04"
tools:
python: "3.9"

# Optionally set the version of Python and requirements required to build your docs
python:
install:
- requirements: requirements/docs.txt
- method: pip
path: .
commands:
- printenv
- pwd ; ls -lh
- pip install -U pip awscli --user
- python -m awscli s3 sync --no-sign-request s3://sphinx-packages/ dist/ ; ls -lh dist/
- >
pip install -e . -q -r requirements/docs.txt \
-f 'https://download.pytorch.org/whl/cpu/torch_stable.html' -f dist/ ;
pip list
# this need to be split so `sphinx-build` is picked from previous installation
- bash docs/rtfd-build.sh
- mkdir -p _readthedocs ; mv docs/build/html _readthedocs/html
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,7 @@ You can use TorchMetrics with any PyTorch model or with [PyTorch Lightning](http

### Module metrics

The [module-based metrics](https://pytorchlightning.github.io/metrics/references/modules.html) contain internal metric states (similar to the parameters of the PyTorch module) that automate accumulation and synchronization across devices!
The [module-based metrics](https://torchmetrics.readthedocs.io/en/stable/references/metric.html) contain internal metric states (similar to the parameters of the PyTorch module) that automate accumulation and synchronization across devices!

- Automatic accumulation over multiple batches
- Automatic synchronization between multiple devices
Expand Down
12 changes: 12 additions & 0 deletions docs/rtfd-build.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
# building for PRs and skip stable and latest states

if ! [ $READTHEDOCS_VERSION == "latest" -o $READTHEDOCS_VERSION == "stable" ];
then
cd ./docs ;
export SPHINX_FETCH_ASSETS=0 ;
make html --jobs $(nproc) ;
ls -lh build
else
echo "Void build... :-]" ;
mkdir -p ./docs/build/html
fi
10 changes: 5 additions & 5 deletions docs/source/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
import shutil
import sys

import pt_lightning_sphinx_theme
import lai_sphinx_theme
from lightning_utilities.docs import fetch_external_assets
from lightning_utilities.docs.formatting import _transform_changelog

Expand All @@ -30,7 +30,7 @@

FOLDER_GENERATED = "generated"
SPHINX_MOCK_REQUIREMENTS = int(os.environ.get("SPHINX_MOCK_REQUIREMENTS", True))
SPHINX_FETCH_ASSETS = int(os.environ.get("SPHINX_FETCH_ASSETS", True))
SPHINX_FETCH_ASSETS = int(os.environ.get("SPHINX_FETCH_ASSETS", False))

html_favicon = "_static/images/icon.svg"

Expand Down Expand Up @@ -112,7 +112,7 @@ def _set_root_image_path(page_path: str):
"sphinx_autodoc_typehints",
"sphinx_paramlinks",
"sphinx.ext.githubpages",
"pt_lightning_sphinx_theme.extensions.lightning",
"lai_sphinx_theme.extensions.lightning",
"matplotlib.sphinxext.plot_directive",
]

Expand Down Expand Up @@ -168,8 +168,8 @@ def _set_root_image_path(page_path: str):
# The theme to use for HTML and HTML Help pages. See the documentation for
# a list of builtin themes.

html_theme = "pt_lightning_sphinx_theme"
html_theme_path = [pt_lightning_sphinx_theme.get_html_theme_path()]
html_theme = "lai_sphinx_theme"
html_theme_path = [lai_sphinx_theme.get_html_theme_path()]

# 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
Expand Down
2 changes: 1 addition & 1 deletion requirements/docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pandoc ==2.3
docutils ==0.19
sphinxcontrib-fulltoc >=1.0
sphinxcontrib-mockautodoc
pt-lightning-sphinx-theme @ https://github.com/Lightning-AI/lightning_sphinx_theme/archive/master.zip
lai-sphinx-theme # need to be downloaded from s3://sphinx-packages/
sphinx-autodoc-typehints ==1.23.0
sphinx-paramlinks ==0.5.4
sphinx-togglebutton ==0.3.2
Expand Down

0 comments on commit 5e129d2

Please sign in to comment.