Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs: pin version in links to external docs [1/n] #19584

Merged
merged 8 commits into from
Mar 19, 2024
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 4 additions & 2 deletions .actions/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -359,17 +359,19 @@ def copy_replace_imports(


def create_mirror_package(source_dir: str, package_mapping: Dict[str, str]) -> None:
"""Create a mirror package with adjusted imports."""
# replace imports and copy the code
mapping = package_mapping.copy()
mapping.pop("lightning", None) # pop this key to avoid replacing `lightning` to `lightning.lightning`

mapping = {f"lightning.{sp}": sl for sp, sl in mapping.items()}
for pkg_from, pkg_to in mapping.items():
source_imports, target_imports = zip(*package_mapping.items())
copy_replace_imports(
source_dir=os.path.join(source_dir, pkg_from.replace(".", os.sep)),
# pytorch_lightning uses lightning_fabric, so we need to replace all imports for all directories
source_imports=mapping.keys(),
target_imports=mapping.values(),
source_imports=source_imports,
target_imports=target_imports,
target_dir=os.path.join(source_dir, pkg_to.replace(".", os.sep)),
lightning_by=pkg_from,
)
Expand Down
4 changes: 3 additions & 1 deletion .github/workflows/docs-build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -106,7 +106,9 @@ jobs:

- name: Full build for deployment
if: github.event_name != 'pull_request'
run: echo "DOCS_FETCH_ASSETS=1" >> $GITHUB_ENV
run: |
echo "DOCS_FETCH_ASSETS=1" >> $GITHUB_ENV
echo "PIN_RELEASE_VERSIONS=1" >> $GITHUB_ENV
- name: Make ${{ matrix.target }}
working-directory: ./docs/source-${{ matrix.pkg-name }}
# allow failing link check and doctest if you run with dispatch
Expand Down
23 changes: 20 additions & 3 deletions docs/source-pytorch/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,12 @@
import glob
import os
import shutil
import urllib.request
import warnings
from importlib.util import module_from_spec, spec_from_file_location
from types import ModuleType

import lai_sphinx_theme
from lightning_utilities.docs import fetch_external_assets
from lightning_utilities.docs import adjust_linked_external_docs, fetch_external_assets
from lightning_utilities.docs.formatting import _transform_changelog

import lightning
Expand All @@ -32,6 +31,7 @@
_FAST_DOCS_DEV = int(os.getenv("FAST_DOCS_DEV", True))
_COPY_NOTEBOOKS = int(os.getenv("DOCS_COPY_NOTEBOOKS", not _FAST_DOCS_DEV))
_FETCH_S3_ASSETS = int(os.getenv("DOCS_FETCH_ASSETS", not _FAST_DOCS_DEV))
_PIN_RELEASE_VERSIONS = int(os.getenv("PIN_RELEASE_VERSIONS", not _FAST_DOCS_DEV))

# -----------------------
# BUILD stuff
Expand Down Expand Up @@ -111,6 +111,23 @@ def _load_py_module(name: str, location: str) -> ModuleType:
)


if _PIN_RELEASE_VERSIONS:
adjust_linked_external_docs(
"https://numpy.org/doc/stable/", "https://numpy.org/doc/{numpy.__version__}/", _PATH_ROOT
)
adjust_linked_external_docs(
"https://pytorch.org/docs/stable/", "https://pytorch.org/docs/{torch.__version__}/", _PATH_ROOT
)
adjust_linked_external_docs(
"https://lightning.ai/docs/torchmetrics", "https://lightning.ai/docs/torchmetrics/v{torchmetrics.__version__}/", _PATH_ROOT, version_digits=3
)
adjust_linked_external_docs(
"https://lightning.ai/docs/fabric/stable/", "https://lightning.ai/docs/fabric/{lightning_fabric.__version__}/", _PATH_ROOT, version_digits=3
)
adjust_linked_external_docs(
"https://tensorboardx.readthedocs.io/en/stable/", "https://tensorboardx.readthedocs.io/en/v{tensorboard.__version__}/", _PATH_ROOT
)

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

project = "PyTorch Lightning"
Expand Down Expand Up @@ -327,7 +344,7 @@ def _load_py_module(name: str, location: str) -> ModuleType:
"torch": ("https://pytorch.org/docs/stable/", None),
"numpy": ("https://numpy.org/doc/stable/", None),
"PIL": ("https://pillow.readthedocs.io/en/stable/", None),
"torchmetrics": ("https://torchmetrics.readthedocs.io/en/stable/", None),
"torchmetrics": ("https://lightning.ai/docs/torchmetrics/stable/", None),
"lightning_habana": ("https://lightning-ai.github.io/lightning-Habana/", None),
"tensorboardX": ("https://tensorboardx.readthedocs.io/en/stable/", None),
# needed for referencing App from lightning scope
Expand Down
5 changes: 4 additions & 1 deletion requirements/docs.txt
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,9 @@ sphinx-rtd-dark-mode
sphinxcontrib-video ==0.2.0
jinja2 <3.2.0

lightning-utilities >=0.9.0
# lightning-utilities >=0.11.0
# todo: until the release of 0.11.0, use the following line
lightning-utilities @ https://github.com/Lightning-AI/utilities/archive/refs/heads/main.zip
Borda marked this conversation as resolved.
Show resolved Hide resolved

# installed from S3 location and fetched in advance
lai-sphinx-theme
Loading