Skip to content

Commit 349cbf1

Browse files
committed
1 parent b15c304 commit 349cbf1

File tree

354 files changed

+27502
-26393
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

354 files changed

+27502
-26393
lines changed
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
import sys
2+
import os
3+
4+
html_file_path = sys.argv[1]
5+
6+
with open(html_file_path, 'r', encoding='utf-8') as html_file:
7+
html = html_file.read()
8+
9+
if "%%%%%%RUNNABLE_CODE_REMOVED%%%%%%" in html:
10+
print("Removing " + html_file_path)
11+
os.remove(html_file_path)

.build/insert_last_verified.py

Lines changed: 160 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,160 @@
1+
import json
2+
import os
3+
import subprocess
4+
import sys
5+
from datetime import datetime
6+
7+
from bs4 import BeautifulSoup
8+
9+
10+
json_file_path = "tutorials-review-data.json"
11+
12+
# paths to skip from the post-processing script
13+
paths_to_skip = [
14+
"beginner/examples_autograd/two_layer_net_custom_function", # not present in the repo
15+
"beginner/examples_nn/two_layer_net_module", # not present in the repo
16+
"beginner/examples_tensor/two_layer_net_numpy", # not present in the repo
17+
"beginner/examples_tensor/two_layer_net_tensor", # not present in the repo
18+
"beginner/examples_autograd/two_layer_net_autograd", # not present in the repo
19+
"beginner/examples_nn/two_layer_net_optim", # not present in the repo
20+
"beginner/examples_nn/two_layer_net_nn", # not present in the repo
21+
"intermediate/coding_ddpg", # not present in the repo - will delete the carryover
22+
]
23+
# Mapping of source directories to build directories
24+
source_to_build_mapping = {
25+
"beginner": "beginner_source",
26+
"recipes": "recipes_source",
27+
"distributed": "distributed",
28+
"intermediate": "intermediate_source",
29+
"prototype": "prototype_source",
30+
"advanced": "advanced_source",
31+
"": "", # root dir for index.rst
32+
}
33+
34+
def get_git_log_date(file_path, git_log_args):
35+
try:
36+
result = subprocess.run(
37+
["git", "log"] + git_log_args + ["--", file_path],
38+
capture_output=True,
39+
text=True,
40+
check=True,
41+
)
42+
if result.stdout:
43+
date_str = result.stdout.splitlines()[0]
44+
return datetime.strptime(date_str, "%a, %d %b %Y %H:%M:%S %z")
45+
except subprocess.CalledProcessError:
46+
pass
47+
raise ValueError(f"Could not find date for {file_path}")
48+
49+
def get_creation_date(file_path):
50+
return get_git_log_date(file_path, ["--diff-filter=A", "--format=%aD"]).strftime("%b %d, %Y")
51+
52+
53+
def get_last_updated_date(file_path):
54+
return get_git_log_date(file_path, ["-1", "--format=%aD"]).strftime("%b %d, %Y")
55+
56+
# Try to find the source file with the given base path and the extensions .rst and .py
57+
def find_source_file(base_path):
58+
for ext in [".rst", ".py"]:
59+
source_file_path = base_path + ext
60+
if os.path.exists(source_file_path):
61+
return source_file_path
62+
return None
63+
64+
65+
# Function to process a JSON file and insert the "Last Verified" information into the HTML files
66+
def process_json_file(build_dir , json_file_path):
67+
with open(json_file_path, "r", encoding="utf-8") as json_file:
68+
json_data = json.load(json_file)
69+
70+
for entry in json_data:
71+
path = entry["Path"]
72+
last_verified = entry["Last Verified"]
73+
status = entry.get("Status", "")
74+
if path in paths_to_skip:
75+
print(f"Skipping path: {path}")
76+
continue
77+
if status in ["needs update", "not verified"]:
78+
formatted_last_verified = "Not Verified"
79+
elif last_verified:
80+
try:
81+
last_verified_date = datetime.strptime(last_verified, "%Y-%m-%d")
82+
formatted_last_verified = last_verified_date.strftime("%b %d, %Y")
83+
except ValueError:
84+
formatted_last_verified = "Unknown"
85+
else:
86+
formatted_last_verified = "Not Verified"
87+
if status == "deprecated":
88+
formatted_last_verified += "Deprecated"
89+
90+
for build_subdir, source_subdir in source_to_build_mapping.items():
91+
if path.startswith(build_subdir):
92+
html_file_path = os.path.join(build_dir, path + ".html")
93+
base_source_path = os.path.join(
94+
source_subdir, path[len(build_subdir) + 1 :]
95+
)
96+
source_file_path = find_source_file(base_source_path)
97+
break
98+
else:
99+
print(f"Warning: No mapping found for path {path}")
100+
continue
101+
102+
if not os.path.exists(html_file_path):
103+
print(
104+
f"Warning: HTML file not found for path {html_file_path}."
105+
"If this is a new tutorial, please add it to the audit JSON file and set the Verified status and todays's date."
106+
)
107+
continue
108+
109+
if not source_file_path:
110+
print(f"Warning: Source file not found for path {base_source_path}.")
111+
continue
112+
113+
created_on = get_creation_date(source_file_path)
114+
last_updated = get_last_updated_date(source_file_path)
115+
116+
with open(html_file_path, "r", encoding="utf-8") as file:
117+
soup = BeautifulSoup(file, "html.parser")
118+
# Check if the <p> tag with class "date-info-last-verified" already exists
119+
existing_date_info = soup.find("p", {"class": "date-info-last-verified"})
120+
if existing_date_info:
121+
print(
122+
f"Warning: <p> tag with class 'date-info-last-verified' already exists in {html_file_path}"
123+
)
124+
continue
125+
126+
h1_tag = soup.find("h1") # Find the h1 tag to insert the dates
127+
if h1_tag:
128+
date_info_tag = soup.new_tag("p", **{"class": "date-info-last-verified"})
129+
date_info_tag["style"] = "color: #6c6c6d; font-size: small;"
130+
# Add the "Created On", "Last Updated", and "Last Verified" information
131+
date_info_tag.string = (
132+
f"Created On: {created_on} | "
133+
f"Last Updated: {last_updated} | "
134+
f"Last Verified: {formatted_last_verified}"
135+
)
136+
# Insert the new tag after the <h1> tag
137+
h1_tag.insert_after(date_info_tag)
138+
# Save back to the HTML.
139+
with open(html_file_path, "w", encoding="utf-8") as file:
140+
file.write(str(soup))
141+
else:
142+
print(f"Warning: <h1> tag not found in {html_file_path}")
143+
144+
145+
def main():
146+
if len(sys.argv) < 2:
147+
print("Error: Build directory not provided. Exiting.")
148+
exit(1)
149+
build_dir = sys.argv[1]
150+
print(f"Build directory: {build_dir}")
151+
process_json_file(build_dir , json_file_path)
152+
print(
153+
"Finished processing JSON file. Please check the output for any warnings. "
154+
"Pages like `nlp/index.html` are generated only during the full `make docs` "
155+
"or `make html` build. Warnings about these files when you run `make html-noplot` "
156+
"can be ignored."
157+
)
158+
159+
if __name__ == "__main__":
160+
main()

.build/post_process_notebooks.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,14 +5,14 @@
55
"""
66
This post-processing script needs to run after the .ipynb files are
77
generated. The script removes extraneous ```{=html} syntax from the
8-
admonitions and splits the cells that have video iframe into a
8+
admonitions and splits the cells that have video iframe into a
99
separate code cell that can be run to load the video directly
1010
in the notebook. This script is included in build.sh.
1111
"""
1212

1313

1414
# Pattern to search ``` {.python .jupyter-code-cell}
15-
pattern = re.compile(r'(.*?)``` {.python .jupyter-code-cell}\n\n(from IPython.display import display, HTML\nhtml_code = """\n.*?\n"""\ndisplay\(HTML\(html_code\)\))\n```(.*)', re.DOTALL)
15+
pattern = re.compile(r'(.*?)``` {\.python \.jupyter-code-cell}\n(.*?from IPython\.display import display, HTML.*?display\(HTML\(html_code\)\))\n```(.*)', re.DOTALL)
1616

1717

1818
def process_video_cell(notebook_path):
@@ -36,7 +36,7 @@ def process_video_cell(notebook_path):
3636
before_html_block = match.group(1)
3737
code_block = match.group(2)
3838

39-
# Add a comment to run the cell to display the video
39+
# Add a comment to run the cell to display the video
4040
code_block = "# Run this cell to load the video\n" + code_block
4141
# Create a new code cell
4242
new_code_cell = nbf.v4.new_code_cell(source=code_block)

.build/requirements-full.txt

Lines changed: 16 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,15 @@
33

44
# use `make docs` to build the tutorials fully
55

6-
pypandoc==1.12
7-
pandocfilters
8-
markdown
6+
# Tutorial dependencies
97
tqdm==4.66.1
108
numpy==1.24.4
119
matplotlib
1210
librosa
11+
torch==2.8
12+
torchvision
13+
torchdata
14+
networkx
1315
PyHamcrest
1416
bs4
1517
awscliv2==2.1.1
@@ -20,25 +22,24 @@ tensorboard
2022
jinja2==3.1.3
2123
pytorch-lightning
2224
torchx
23-
torchrl==0.3.0
24-
tensordict==0.3.0
25-
ax-platform
26-
nbformat>==5.9.2
25+
torchrl==0.9.2
26+
tensordict==0.9.1
27+
# For ax_multiobjective_nas_tutorial.py
28+
ax-platform>=0.4.0,<0.5.0
29+
nbformat>=5.9.2
2730
datasets
2831
transformers
29-
torchmultimodal-nightly # needs to be updated to stable as soon as it's avaialable
3032
onnx
31-
onnxscript
33+
onnxscript>=0.2.2
3234
onnxruntime
3335
evaluate
3436
accelerate>=0.20.1
3537

3638
importlib-metadata==6.8.0
3739

38-
39-
4040
ipython
4141

42+
sphinxcontrib.katex
4243
# to run examples
4344
boto3
4445
pandas
@@ -53,9 +54,10 @@ gym-super-mario-bros==7.4.0
5354
pyopengl
5455
gymnasium[mujoco]==0.27.0
5556
timm
56-
iopath
57-
pygame==2.1.2
57+
pygame==2.6.0
5858
pycocotools
5959
semilearn==0.3.2
60-
torchao==0.0.3
60+
torchao==0.10.0
6161
segment_anything==1.0
62+
torchrec==1.2.0; platform_system == "Linux"
63+
fbgemm-gpu==1.2.0; platform_system == "Linux"

.build/requirements-minimal.txt

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -3,21 +3,21 @@
33

44
# use `make html-noplot` for htmls only (without evaluating sphinx-gallery)
55

6-
sphinx==5.0.0
7-
sphinx-gallery==0.11.1
8-
sphinx_design
9-
docutils==0.16
10-
sphinx-copybutton
11-
sphinx-sitemap
6+
# Sphinx dependencies
7+
sphinx==7.2.6
8+
sphinx-gallery==0.19.0
9+
sphinx-reredirects==0.1.4
10+
sphinx_design==0.6.1
11+
docutils>=0.18.1,<0.21
12+
sphinx-copybutton==0.5.2
13+
sphinx_sitemap==2.7.1
1214
sphinxext-opengraph
13-
sphinxcontrib-katex
15+
sphinxcontrib-mermaid==1.0.0
16+
sphinxcontrib.katex==0.9.10
17+
pypandoc==1.15
18+
pandocfilters==1.5.1
19+
markdown==3.8.2
1420
plotly==5.14.0
15-
torch
16-
torchvision
17-
torchtext
18-
torchaudio
19-
torchdata
20-
networkx
2121

2222
# PyTorch Korea Theme
2323
# pytorch-sphinx-theme@https://github.com/PyTorchKorea/pytorch_sphinx_theme/archive/master.zip

.build/validate_tutorials_built.py

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -10,52 +10,36 @@
1010

1111
NOT_RUN = [
1212
"beginner_source/basics/intro", # no code
13+
"beginner_source/introyt/introyt_index", # no code
1314
"beginner_source/onnx/intro_onnx",
14-
"beginner_source/translation_transformer",
1515
"beginner_source/profiler",
1616
"beginner_source/saving_loading_models",
1717
"beginner_source/introyt/captumyt",
1818
"beginner_source/examples_nn/polynomial_module",
1919
"beginner_source/examples_nn/dynamic_net",
2020
"beginner_source/examples_nn/polynomial_optim",
21-
"beginner_source/former_torchies/autograd_tutorial_old",
22-
"beginner_source/former_torchies/tensor_tutorial_old",
2321
"beginner_source/examples_autograd/polynomial_autograd",
2422
"beginner_source/examples_autograd/polynomial_custom_function",
25-
"beginner_source/torchtext_custom_dataset_tutorial", # not building with 2.3 RC, might be able to turn on with GA
26-
"beginner_source/text_sentiment_ngrams_tutorial", # not building with 2.3 RC, might be able to turn on with GA
27-
"beginner_source/t5_tutorial", # re-enable after this is fixed: https://github.com/pytorch/text/issues/1756
23+
"intermediate_source/dqn_with_rnn_tutorial", #not working on 2.8 release reenable after 3514
2824
"intermediate_source/mnist_train_nas", # used by ax_multiobjective_nas_tutorial.py
29-
"intermediate_source/torchvision_tutorial", # disable due to RuntimeError: DataLoader worker (pid(s) 20092) exited unexpectedly
30-
"intermediate_source/fx_conv_bn_fuser",
25+
"intermediate_source/torch_compile_conv_bn_fuser",
3126
"intermediate_source/_torch_export_nightly_tutorial", # does not work on release
32-
"advanced_source/super_resolution_with_onnxruntime",
33-
"advanced_source/ddp_pipeline", # requires 4 gpus
3427
"advanced_source/usb_semisup_learn", # fails with CUDA OOM error, should try on a different worker
35-
"prototype_source/fx_graph_mode_ptq_dynamic",
36-
"prototype_source/vmap_recipe",
37-
"prototype_source/torchscript_freezing",
38-
"prototype_source/nestedtensor",
39-
"recipes_source/recipes/saving_and_loading_models_for_inference",
40-
"recipes_source/recipes/saving_multiple_models_in_one_file",
41-
"recipes_source/recipes/loading_data_recipe",
28+
"unstable_source/gpu_direct_storage", # requires specific filesystem + GPUDirect Storage to be set up
4229
"recipes_source/recipes/tensorboard_with_pytorch",
4330
"recipes_source/recipes/what_is_state_dict",
4431
"recipes_source/recipes/profiler_recipe",
45-
"recipes_source/recipes/save_load_across_devices",
4632
"recipes_source/recipes/warmstarting_model_using_parameters_from_a_different_model",
47-
"recipes_source/recipes/dynamic_quantization",
48-
"recipes_source/recipes/saving_and_loading_a_general_checkpoint",
4933
"recipes_source/recipes/benchmark",
5034
"recipes_source/recipes/tuning_guide",
5135
"recipes_source/recipes/zeroing_out_gradients",
5236
"recipes_source/recipes/defining_a_neural_network",
5337
"recipes_source/recipes/timer_quick_start",
5438
"recipes_source/recipes/amp_recipe",
5539
"recipes_source/recipes/Captum_Recipe",
56-
"intermediate_source/flask_rest_api_tutorial",
57-
"intermediate_source/text_to_speech_with_torchaudio",
58-
"intermediate_source/tensorboard_profiler_tutorial" # reenable after 2.0 release.
40+
"intermediate_source/tensorboard_profiler_tutorial", # reenable after 2.0 release.
41+
"advanced_source/semi_structured_sparse", # reenable after 3303 is fixed.
42+
"intermediate_source/torchrec_intro_tutorial.py", #failing with 2.8 reenable after 3498
5943
]
6044

6145
def tutorial_source_dirs() -> List[Path]:

README.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44

55
PyTorch에서 제공하는 튜토리얼의 한국어 번역을 위한 저장소입니다.\
66
번역의 결과물은 [https://tutorials.pytorch.kr](https://tutorials.pytorch.kr)에서 확인하실 수 있습니다. (번역을 진행하며 **비정기적으로** 반영합니다.)\
7-
현재 버전의 번역 / 변경 관련 이슈는 [#799 이슈](https://github.com/PyTorchKorea/tutorials-kr/issues/799)를 참고해주세요.
7+
현재 버전의 번역 / 변경 관련 이슈는 [#972 이슈](https://github.com/PyTorchKorea/tutorials-kr/issues/972)를 참고해주세요.
88

99
## 기여하기
1010

@@ -22,7 +22,7 @@ PyTorch에서 제공하는 튜토리얼의 한국어 번역을 위한 저장소
2222

2323
## 원문
2424

25-
현재 PyTorch v2.0 튜토리얼([pytorch/tutorials@6537199](https://github.com/pytorch/tutorials/commit/653719940f7c4d908811da415f190465d8c3189d) 기준) 번역이 진행 중입니다.
25+
현재 PyTorch v2.8 튜토리얼([pytorch/tutorials@c4d9d93](https://github.com/pytorch/tutorials/commit/c4d9d935655cf754c90d5ce7f37024afc015f054) 기준) 번역이 진행 중입니다.
2626

2727
최신 버전의 튜토리얼(공식, 영어)은 [PyTorch tutorials 사이트](https://pytorch.org/tutorials)[PyTorch tutorials 저장소](https://github.com/pytorch/tutorials)를 참고해주세요.
2828

@@ -51,5 +51,5 @@ v1.0 이후 번역은 별도 저장소로 관리하지 않습니다. [이 저장
5151
자세한 내용은 [LICENSE 파일](https://github.com/PyTorchKorea/tutorials-kr/blob/master/LICENSE)을 참조해주세요.
5252

5353
---
54-
This is a project to translate [pytorch/tutorials@6537199](https://github.com/pytorch/tutorials/commit/653719940f7c4d908811da415f190465d8c3189d) into Korean.
54+
This is a project to translate [pytorch/tutorials@c4d9d93](https://github.com/pytorch/tutorials/commit/c4d9d935655cf754c90d5ce7f37024afc015f054) into Korean.
5555
For the latest version, please visit to the [official PyTorch tutorials repo](https://github.com/pytorch/tutorials).

0 commit comments

Comments
 (0)