Skip to content

Commit ff57d61

Browse files
committed
tc
1 parent 9d45f12 commit ff57d61

File tree

6 files changed

+28
-37
lines changed

6 files changed

+28
-37
lines changed

.ci/docker/requirements.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# Refer to ./jenkins/build.sh for tutorial build instructions
33

44
sphinx==5.0.0
5-
sphinx-gallery==0.19.0
5+
sphinx-gallery==0.11.1
66
sphinx_design
77
docutils==0.16
88
sphinx-copybutton

.jenkins/build.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,10 @@ if [[ "${JOB_TYPE}" == "worker" ]]; then
5858

5959
# Step 3: Run `make docs` to generate HTML files and static files for these tutorialis
6060
pip3 install -e git+https://github.com/pytorch/pytorch_sphinx_theme.git#egg=pytorch_sphinx_theme
61-
make docs
61+
make download
62+
make download-last-reviewed-json
63+
python .jenkins/sphinx_files.py
64+
make postprocess
6265

6366
# Step 3.1: Run the post-processing script:
6467
python .jenkins/post_process_notebooks.py

.jenkins/sphinx_files.py

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
import subprocess
2+
import os
3+
4+
def main() -> None:
5+
files_to_run = os.environ["FILES_TO_RUN"]
6+
env = os.environ.copy()
7+
for file in files_to_run.split(" "):
8+
print(f"Running {file}")
9+
env["RUNTHIS"] = file
10+
subprocess.check_output(["make", "html"], env=env)
11+
12+
if __name__ == "__main__":
13+
main()

Makefile

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,16 +90,20 @@ download-last-reviewed-json:
9090
@echo "Downloading tutorials-review-data.json..."
9191
curl -o tutorials-review-data.json https://raw.githubusercontent.com/pytorch/tutorials/refs/heads/last-reviewed-data-json/tutorials-review-data.json
9292
@echo "Finished downloading tutorials-review-data.json."
93-
docs:
94-
make download
95-
make download-last-reviewed-json
96-
make html
93+
94+
postprocess:
9795
@python .jenkins/insert_last_verified.py $(BUILDDIR)/html
9896
rm -rf docs
9997
cp -r $(BUILDDIR)/html docs
10098
touch docs/.nojekyll
10199
rm -rf tutorials-review-data.json
102100

101+
docs:
102+
make download
103+
make download-last-reviewed-json
104+
make html
105+
make postprocess
106+
103107
html-noplot:
104108
$(SPHINXBUILD) -D plot_gallery=0 -b html $(SPHINXOPTS) "$(SOURCEDIR)" "$(BUILDDIR)/html"
105109
# bash .jenkins/remove_invisible_code_block_batch.sh "$(BUILDDIR)/html"

conf.py

Lines changed: 1 addition & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -48,35 +48,6 @@
4848
from pathlib import Path
4949
pio.renderers.default = 'sphinx_gallery'
5050

51-
import sphinx_gallery.gen_rst
52-
import multiprocessing
53-
54-
# Save the original function
55-
def isolated_call(func, args, kwargs, result_queue):
56-
try:
57-
result = func(*args, **kwargs)
58-
result_queue.put((True, result))
59-
except Exception as e:
60-
result_queue.put((False, str(e)))
61-
62-
def make_isolated_version(func):
63-
def wrapper(*args, **kwargs):
64-
result_queue = multiprocessing.Queue()
65-
p = multiprocessing.Process(
66-
target=isolated_call,
67-
args=(func, args, kwargs, result_queue)
68-
)
69-
p.start()
70-
p.join()
71-
success, result = result_queue.get()
72-
if success:
73-
return result
74-
else:
75-
raise RuntimeError(f"Error in isolated process: {result}")
76-
return wrapper
77-
78-
# Monkey-patch
79-
sphinx_gallery.gen_rst.generate_file_rst = make_isolated_version(sphinx_gallery.gen_rst.generate_file_rst)
8051

8152
try:
8253
import torchvision
@@ -133,7 +104,7 @@ def reset_seeds(gallery_conf, fname):
133104
'examples_dirs': ['beginner_source', 'intermediate_source',
134105
'advanced_source', 'recipes_source', 'prototype_source'],
135106
'gallery_dirs': ['beginner', 'intermediate', 'advanced', 'recipes', 'prototype'],
136-
'filename_pattern': re.compile(SPHINX_SHOULD_RUN),
107+
'filename_pattern': os.getenv("RUNTHIS"),
137108
'promote_jupyter_magic': True,
138109
'backreferences_dir': None,
139110
'first_notebook_cell': ("# For tips on running notebooks in Google Colab, see\n"

custom_directives.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@ def run(self):
8888
if 'intro' in self.options:
8989
intro = self.options['intro'][:195] + '...'
9090
else:
91-
_, blocks = sphinx_gallery.py_source_parser.split_code_and_text_blocks(abs_fname)
91+
_, blocks = sphinx_gallery.gen_rst.split_code_and_text_blocks(abs_fname)
9292
intro, _ = sphinx_gallery.gen_rst.extract_intro_and_title(abs_fname, blocks[0][1])
9393

9494
thumbnail_rst = ''

0 commit comments

Comments
 (0)