Skip to content

Commit

Permalink
docs: include external pages 2/2 (#17890)
Browse files Browse the repository at this point in the history
  • Loading branch information
Borda authored Oct 3, 2023
1 parent 87708d8 commit 45237c7
Show file tree
Hide file tree
Showing 14 changed files with 36 additions and 293 deletions.
13 changes: 12 additions & 1 deletion .actions/assistant.py
Original file line number Diff line number Diff line change
Expand Up @@ -442,6 +442,7 @@ def pull_docs_files(
target_dir: str = "docs/source-pytorch/XXX",
checkout: str = "tags/1.0.0",
source_dir: str = "docs/source",
as_orphan: bool = False,
) -> None:
"""Pull docs pages from external source and append to local docs."""
import zipfile
Expand Down Expand Up @@ -473,7 +474,17 @@ def pull_docs_files(
if os.path.isfile(new_rst):
logging.warning(f"Page {new_rst} already exists in the local tree so it will be skipped.")
continue
shutil.copy(rst, new_rst)
AssistantCLI._copy_rst(rst, new_rst, as_orphan=as_orphan)

@staticmethod
def _copy_rst(rst_in, rst_out, as_orphan: bool = False):
"""Copy RST page with optional inserting orphan statement."""
with open(rst_in, encoding="utf-8") as fopen:
page = fopen.read()
if as_orphan and ":orphan:" not in page:
page = ":orphan:\n\n" + page
with open(rst_in, "w", encoding="utf-8") as fopen:
fopen.write(page)


if __name__ == "__main__":
Expand Down
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,9 @@ docs/source-pytorch/notebooks
docs/source-pytorch/_static/images/course_UvA-DL
docs/source-pytorch/_static/images/lightning_examples
docs/source-pytorch/_static/fetched-s3-assets
docs/source-pytorch/_static/images/ipu/
docs/source-pytorch/integrations/hpu
docs/source-pytorch/integrations/ipu

docs/source-fabric/*/generated

Expand Down
2 changes: 0 additions & 2 deletions docs/source-pytorch/accelerators/accelerator_prepare.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,5 @@
:orphan:

.. _gpu_prepare:

########################################
Hardware agnostic training (preparation)
########################################
Expand Down
144 changes: 0 additions & 144 deletions docs/source-pytorch/accelerators/ipu_advanced.rst

This file was deleted.

72 changes: 0 additions & 72 deletions docs/source-pytorch/accelerators/ipu_basic.rst

This file was deleted.

65 changes: 0 additions & 65 deletions docs/source-pytorch/accelerators/ipu_intermediate.rst

This file was deleted.

4 changes: 2 additions & 2 deletions docs/source-pytorch/common/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
../advanced/model_parallel
Train on single or multiple GPUs <../accelerators/gpu>
Train on single or multiple HPUs <../integrations/hpu/index>
Train on single or multiple IPUs <../accelerators/ipu>
Train on single or multiple IPUs <../integrations/ipu/index>
Train on single or multiple TPUs <../accelerators/tpu>
Train on MPS <../accelerators/mps>
Use a pretrained model <../advanced/pretrained>
Expand Down Expand Up @@ -171,7 +171,7 @@ How-to Guides
.. displayitem::
:header: Train on single or multiple IPUs
:description: Train models faster with IPU accelerators
:button_link: ../accelerators/ipu.html
:button_link: ../integrations/ipu/index.html
:col_css: col-md-4
:height: 180

Expand Down
2 changes: 1 addition & 1 deletion docs/source-pytorch/common_usecases.rst
Original file line number Diff line number Diff line change
Expand Up @@ -137,7 +137,7 @@ Customize and extend Lightning for things like custom hardware or distributed st
:header: Train on single or multiple IPUs
:description: Train models faster with IPUs.
:col_css: col-md-12
:button_link: accelerators/ipu.html
:button_link: integrations/ipu/index.html
:height: 100

.. displayitem::
Expand Down
13 changes: 13 additions & 0 deletions docs/source-pytorch/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
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
Expand Down Expand Up @@ -101,6 +102,18 @@ def _load_py_module(name: str, location: str) -> ModuleType:
target_dir="docs/source-pytorch/integrations/hpu",
checkout="tags/1.1.0",
)
assist_local.AssistantCLI.pull_docs_files(
gh_user_repo="Lightning-AI/lightning-Graphcore",
target_dir="docs/source-pytorch/integrations/ipu",
checkout="tags/v0.1.0",
as_orphan=True, # todo: this can be dropped after new IPU release
)
# the IPU also need one image
URL_RAW_DOCS_GRAPHCORE = "https://raw.githubusercontent.com/Lightning-AI/lightning-Graphcore/v0.1.0/docs/source"
for img in ["_static/images/ipu/profiler.png"]:
os.makedirs(os.path.dirname(os.path.join(_PATH_HERE, img)), exist_ok=True)
urllib.request.urlretrieve(f"{URL_RAW_DOCS_GRAPHCORE}/{img}", os.path.join(_PATH_HERE, img))


if _FETCH_S3_ASSETS:
fetch_external_assets(
Expand Down
2 changes: 1 addition & 1 deletion docs/source-pytorch/extensions/accelerator.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ Currently there are accelerators for:
- CPU
- :doc:`GPU <../accelerators/gpu>`
- :doc:`TPU <../accelerators/tpu>`
- :doc:`IPU <../accelerators/ipu>`
- :doc:`IPU <../integrations/ipu/index>`
- :doc:`HPU <../integrations/hpu/index>`
- :doc:`MPS <../accelerators/mps>`

Expand Down
Loading

0 comments on commit 45237c7

Please sign in to comment.