ci/docs: enable not fetch assets (#18333)

This commit is contained in:
Jirka Borovec 2023-08-21 20:22:21 +02:00 committed by GitHub
parent 300e6cf500
commit 3f73231d5c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 32 additions and 26 deletions

View File

@ -43,6 +43,7 @@ jobs:
check: ["doctest", "linkcheck"] check: ["doctest", "linkcheck"]
env: env:
SPHINX_MOCK_REQUIREMENTS: 0 SPHINX_MOCK_REQUIREMENTS: 0
FAST_DOCS_DEV: 1
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:
@ -106,6 +107,8 @@ jobs:
fail-fast: false fail-fast: false
matrix: matrix:
pkg-name: ["app", "fabric", "pytorch"] pkg-name: ["app", "fabric", "pytorch"]
env:
FAST_DOCS_DEV: 0
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
with: with:

View File

@ -64,10 +64,10 @@ To speed this up, enable this flag in before building docs:
```bash ```bash
# builds notebooks which is slow # builds notebooks which is slow
export PL_FAST_DOCS_DEV=0 export FAST_DOCS_DEV=0
# fast notebook build which is fast # fast notebook build which is fast
export PL_FAST_DOCS_DEV=1 export FAST_DOCS_DEV=1
``` ```
## docs CSS/theme ## docs CSS/theme

View File

@ -3,7 +3,7 @@
if ! [ $READTHEDOCS_VERSION == "latest" -o $READTHEDOCS_VERSION == "stable" ]; if ! [ $READTHEDOCS_VERSION == "latest" -o $READTHEDOCS_VERSION == "stable" ];
then then
cd ./docs/source-pytorch ; cd ./docs/source-pytorch ;
export PL_FAST_DOCS_DEV=1 ; export FAST_DOCS_DEV=1 ;
make html --jobs $(nproc) ; make html --jobs $(nproc) ;
ls -lh ../build ls -lh ../build
else else

View File

@ -25,7 +25,8 @@ _PATH_HERE = os.path.abspath(os.path.dirname(__file__))
_PATH_ROOT = os.path.realpath(os.path.join(_PATH_HERE, "..", "..")) _PATH_ROOT = os.path.realpath(os.path.join(_PATH_HERE, "..", ".."))
sys.path.insert(0, os.path.abspath(_PATH_ROOT)) sys.path.insert(0, os.path.abspath(_PATH_ROOT))
SPHINX_MOCK_REQUIREMENTS = int(os.environ.get("SPHINX_MOCK_REQUIREMENTS", True)) _SPHINX_MOCK_REQUIREMENTS = int(os.environ.get("SPHINX_MOCK_REQUIREMENTS", True))
_FAST_DOCS_DEV = int(os.environ.get("FAST_DOCS_DEV", True))
# -- Project information ----------------------------------------------------- # -- Project information -----------------------------------------------------
@ -46,10 +47,10 @@ github_repo = project
# -- Project documents ------------------------------------------------------- # -- Project documents -------------------------------------------------------
if not _FAST_DOCS_DEV:
fetch_external_assets( fetch_external_assets(
docs_folder=_PATH_HERE, assets_folder="_static/fetched-s3-assets", retrieve_pattern=r"https?://[-a-zA-Z0-9_]+\.s3\.[-a-zA-Z0-9()_\\+.\\/=]+" docs_folder=_PATH_HERE, assets_folder="_static/fetched-s3-assets", retrieve_pattern=r"https?://[-a-zA-Z0-9_]+\.s3\.[-a-zA-Z0-9()_\\+.\\/=]+"
) )
# -- General configuration --------------------------------------------------- # -- General configuration ---------------------------------------------------
@ -303,7 +304,7 @@ PACKAGE_MAPPING = {
"PyYAML": "yaml", "PyYAML": "yaml",
} }
MOCK_PACKAGES = [] MOCK_PACKAGES = []
if SPHINX_MOCK_REQUIREMENTS: if _SPHINX_MOCK_REQUIREMENTS:
# mock also base packages when we are on RTD since we don't install them there # mock also base packages when we are on RTD since we don't install them there
MOCK_PACKAGES += _package_list_from_file(os.path.join(_PATH_ROOT, "requirements.txt")) MOCK_PACKAGES += _package_list_from_file(os.path.join(_PATH_ROOT, "requirements.txt"))
MOCK_PACKAGES = [PACKAGE_MAPPING.get(pkg, pkg) for pkg in MOCK_PACKAGES] MOCK_PACKAGES = [PACKAGE_MAPPING.get(pkg, pkg) for pkg in MOCK_PACKAGES]

View File

@ -25,7 +25,8 @@ _PATH_HERE = os.path.abspath(os.path.dirname(__file__))
_PATH_ROOT = os.path.realpath(os.path.join(_PATH_HERE, "..", "..")) _PATH_ROOT = os.path.realpath(os.path.join(_PATH_HERE, "..", ".."))
sys.path.insert(0, os.path.abspath(_PATH_ROOT)) sys.path.insert(0, os.path.abspath(_PATH_ROOT))
SPHINX_MOCK_REQUIREMENTS = int(os.environ.get("SPHINX_MOCK_REQUIREMENTS", True)) _SPHINX_MOCK_REQUIREMENTS = int(os.environ.get("SPHINX_MOCK_REQUIREMENTS", True))
_FAST_DOCS_DEV = int(os.environ.get("FAST_DOCS_DEV", True))
# -- Project information ----------------------------------------------------- # -- Project information -----------------------------------------------------
@ -46,11 +47,12 @@ github_repo = project
# -- Project documents ------------------------------------------------------- # -- Project documents -------------------------------------------------------
fetch_external_assets( if not _FAST_DOCS_DEV:
docs_folder=_PATH_HERE, fetch_external_assets(
assets_folder="_static/fetched-s3-assets", docs_folder=_PATH_HERE,
retrieve_pattern=r"https?://[-a-zA-Z0-9_]+\.s3\.[-a-zA-Z0-9()_\\+.\\/=]+", assets_folder="_static/fetched-s3-assets",
) retrieve_pattern=r"https?://[-a-zA-Z0-9_]+\.s3\.[-a-zA-Z0-9()_\\+.\\/=]+",
)
# -- General configuration --------------------------------------------------- # -- General configuration ---------------------------------------------------
@ -286,7 +288,7 @@ PACKAGE_MAPPING = {
"PyYAML": "yaml", "PyYAML": "yaml",
} }
MOCK_PACKAGES = [] MOCK_PACKAGES = []
if SPHINX_MOCK_REQUIREMENTS: if _SPHINX_MOCK_REQUIREMENTS:
# mock also base packages when we are on RTD since we don't install them there # mock also base packages when we are on RTD since we don't install them there
MOCK_PACKAGES += _package_list_from_file(os.path.join(_PATH_ROOT, "requirements.txt")) MOCK_PACKAGES += _package_list_from_file(os.path.join(_PATH_ROOT, "requirements.txt"))
MOCK_PACKAGES = [PACKAGE_MAPPING.get(pkg, pkg) for pkg in MOCK_PACKAGES] MOCK_PACKAGES = [PACKAGE_MAPPING.get(pkg, pkg) for pkg in MOCK_PACKAGES]

View File

@ -27,7 +27,8 @@ import lightning
# ----------------------- # -----------------------
# VARIABLES WHEN WORKING ON DOCS... MAKE THIS TRUE TO BUILD FASTER # VARIABLES WHEN WORKING ON DOCS... MAKE THIS TRUE TO BUILD FASTER
# ----------------------- # -----------------------
_PL_FAST_DOCS_DEV = bool(int(os.getenv("PL_FAST_DOCS_DEV", 0))) _SPHINX_MOCK_REQUIREMENTS = int(os.environ.get("SPHINX_MOCK_REQUIREMENTS", 1))
_FAST_DOCS_DEV = bool(int(os.getenv("FAST_DOCS_DEV", 0)))
# ----------------------- # -----------------------
# BUILD stuff # BUILD stuff
@ -36,6 +37,7 @@ _PATH_HERE = os.path.abspath(os.path.dirname(__file__))
_PATH_ROOT = os.path.join(_PATH_HERE, "..", "..") _PATH_ROOT = os.path.join(_PATH_HERE, "..", "..")
_PATH_RAW_NB = os.path.join(_PATH_ROOT, "_notebooks") _PATH_RAW_NB = os.path.join(_PATH_ROOT, "_notebooks")
_SHOULD_COPY_NOTEBOOKS = True _SHOULD_COPY_NOTEBOOKS = True
_FOLDER_GENERATED = "generated"
def _load_py_module(name: str, location: str) -> ModuleType: def _load_py_module(name: str, location: str) -> ModuleType:
@ -53,8 +55,6 @@ else:
_SHOULD_COPY_NOTEBOOKS = False _SHOULD_COPY_NOTEBOOKS = False
warnings.warn("To build the code, please run: `git submodule update --init --recursive`", stacklevel=2) warnings.warn("To build the code, please run: `git submodule update --init --recursive`", stacklevel=2)
FOLDER_GENERATED = "generated"
SPHINX_MOCK_REQUIREMENTS = int(os.environ.get("SPHINX_MOCK_REQUIREMENTS", True))
# -- Project documents ------------------------------------------------------- # -- Project documents -------------------------------------------------------
@ -80,14 +80,14 @@ if _SHOULD_COPY_NOTEBOOKS:
os.remove(file) os.remove(file)
os.makedirs(os.path.join(_PATH_HERE, FOLDER_GENERATED), exist_ok=True) os.makedirs(os.path.join(_PATH_HERE, _FOLDER_GENERATED), exist_ok=True)
# copy all documents from GH templates like contribution guide # copy all documents from GH templates like contribution guide
for md in glob.glob(os.path.join(_PATH_ROOT, ".github", "*.md")): for md in glob.glob(os.path.join(_PATH_ROOT, ".github", "*.md")):
shutil.copy(md, os.path.join(_PATH_HERE, FOLDER_GENERATED, os.path.basename(md))) shutil.copy(md, os.path.join(_PATH_HERE, _FOLDER_GENERATED, os.path.basename(md)))
# copy also the changelog # copy also the changelog
_transform_changelog( _transform_changelog(
os.path.join(_PATH_ROOT, "src", "lightning", "fabric", "CHANGELOG.md"), os.path.join(_PATH_ROOT, "src", "lightning", "fabric", "CHANGELOG.md"),
os.path.join(_PATH_HERE, FOLDER_GENERATED, "CHANGELOG.md"), os.path.join(_PATH_HERE, _FOLDER_GENERATED, "CHANGELOG.md"),
) )
@ -97,7 +97,7 @@ assist_local.AssistantCLI.pull_docs_files(
checkout="tags/1.0.0", checkout="tags/1.0.0",
) )
if not _PL_FAST_DOCS_DEV: if not _FAST_DOCS_DEV:
fetch_external_assets( fetch_external_assets(
docs_folder=_PATH_HERE, docs_folder=_PATH_HERE,
assets_folder="_static/fetched-s3-assets", assets_folder="_static/fetched-s3-assets",
@ -196,11 +196,11 @@ language = "en"
# directories to ignore when looking for source files. # directories to ignore when looking for source files.
# This pattern also affects html_static_path and html_extra_path. # This pattern also affects html_static_path and html_extra_path.
exclude_patterns = [ exclude_patterns = [
f"{FOLDER_GENERATED}/PULL_REQUEST_TEMPLATE.md", f"{_FOLDER_GENERATED}/PULL_REQUEST_TEMPLATE.md",
"notebooks/sample-template*", "notebooks/sample-template*",
] ]
if _PL_FAST_DOCS_DEV: if _FAST_DOCS_DEV:
exclude_patterns.append("notebooks/*") exclude_patterns.append("notebooks/*")
exclude_patterns.append("tutorials.rst") exclude_patterns.append("tutorials.rst")
@ -372,7 +372,7 @@ PACKAGE_MAPPING = {
"hydra-core": "hydra", "hydra-core": "hydra",
} }
MOCK_PACKAGES = [] MOCK_PACKAGES = []
if SPHINX_MOCK_REQUIREMENTS: if _SPHINX_MOCK_REQUIREMENTS:
_path_require = lambda fname: os.path.join(_PATH_ROOT, "requirements", "pytorch", fname) _path_require = lambda fname: os.path.join(_PATH_ROOT, "requirements", "pytorch", fname)
# mock also base packages when we are on RTD since we don't install them there # mock also base packages when we are on RTD since we don't install them there
MOCK_PACKAGES += package_list_from_file(_path_require("base.txt")) MOCK_PACKAGES += package_list_from_file(_path_require("base.txt"))