diff --git a/.jenkins/build.sh b/.jenkins/build.sh index db0438eb91b..443805ab8b7 100755 --- a/.jenkins/build.sh +++ b/.jenkins/build.sh @@ -52,10 +52,17 @@ if [[ "${JOB_TYPE}" == "worker" ]]; then # Step 2: Keep certain tutorials based on file count, and remove runnable code in all other tutorials # IMPORTANT NOTE: We assume that each tutorial has a UNIQUE filename. FILES_TO_RUN=$(python .jenkins/get_files_to_run.py) - echo "FILES_TO_RUN: " ${FILES_TO_RUN} # Files to run must be accessible to subprocessed (at least to `download_data.py`) export FILES_TO_RUN + make download + python .jenkins/sphinx_files.py + mkdir docs + cp -r beginner docs + cp -r intermediate docs + cp -r prototype docs + cp -r recipes docs + cp -r advanced docs # Step 3: Run `make docs` to generate HTML files and static files for these tutorialis pip3 install -e git+https://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme make docs @@ -110,6 +117,12 @@ if [[ "${JOB_TYPE}" == "worker" ]]; then done set -x + mv docs/prototype docs/prototype_source + mv docs/beginner docs/beginner_source + mv docs/advanced docs/advanced_source + mv docs/intermediate docs/intermediate_source + mv docs/recipes docs/recipes_source + # Step 5: Remove INVISIBLE_CODE_BLOCK from .html/.rst.txt/.ipynb/.py files bash $DIR/remove_invisible_code_block_batch.sh docs python .jenkins/validate_tutorials_built.py @@ -131,9 +144,13 @@ elif [[ "${JOB_TYPE}" == "manager" ]]; then for ((worker_id=1;worker_id None: all_files = get_all_files() files_to_run = calculate_shards(all_files, num_shards=args.num_shards)[args.shard_num - 1] + files_to_run = [x for x in files_to_run if x not in NOT_RUN] if not args.dry_run: remove_other_files(all_files, compute_files_to_keep(files_to_run)) stripped_file_names = [Path(x).stem for x in files_to_run] diff --git a/.jenkins/sphinx_files.py b/.jenkins/sphinx_files.py new file mode 100644 index 00000000000..13fb2357b38 --- /dev/null +++ b/.jenkins/sphinx_files.py @@ -0,0 +1,21 @@ +import shutil +import subprocess +import os +import glob + +def main() -> None: + files_to_run = os.environ["FILES_TO_RUN"] + env = os.environ.copy() + for file in files_to_run.split(" "): + print(f"Running {file}") + env["RUNTHIS"] = file + subprocess.check_output(["make", "html", f"BUILDDIR=_build/{file}"], env=env) + files = glob.glob(f"_build/{file}/**/*", recursive=True) + for gen_file in files: + if file in str(gen_file): + rel_path = os.path.relpath(gen_file, f"_build/{file}") + print(gen_file, f"_build/{rel_path}") + shutil.copy(gen_file, f"_build/{rel_path}") + +if __name__ == "__main__": + main() diff --git a/advanced_source/super_resolution_with_onnxruntime.py b/advanced_source/super_resolution_with_onnxruntime.py index 3f4dd439690..b409fccd2b9 100644 --- a/advanced_source/super_resolution_with_onnxruntime.py +++ b/advanced_source/super_resolution_with_onnxruntime.py @@ -254,8 +254,9 @@ def to_numpy(tensor): from PIL import Image import torchvision.transforms as transforms +import os -img = Image.open("./_static/img/cat.jpg") +img = Image.open(os.cwd() + "../_static/img/cat.jpg") resize = transforms.Resize([224, 224]) img = resize(img) diff --git a/conf.py b/conf.py index f0f4905844c..f734b1fc88d 100644 --- a/conf.py +++ b/conf.py @@ -101,7 +101,7 @@ def reset_seeds(gallery_conf, fname): 'examples_dirs': ['beginner_source', 'intermediate_source', 'advanced_source', 'recipes_source', 'prototype_source'], 'gallery_dirs': ['beginner', 'intermediate', 'advanced', 'recipes', 'prototype'], - 'filename_pattern': re.compile(SPHINX_SHOULD_RUN), + 'filename_pattern': os.getenv("RUNTHIS"), 'promote_jupyter_magic': True, 'backreferences_dir': None, 'first_notebook_cell': ("# For tips on running notebooks in Google Colab, see\n"