From b47658625d269d0d3a8585f525c8d5ef1cb70cd8 Mon Sep 17 00:00:00 2001 From: Catherine Lee Date: Wed, 7 Sep 2022 15:52:10 -0700 Subject: [PATCH 01/10] script to validate 0.000 --- .jenkins/build.sh | 1 + .jenkins/validate_tutorial_built_correct.py | 95 +++++++++++++++++++++ 2 files changed, 96 insertions(+) create mode 100644 .jenkins/validate_tutorial_built_correct.py diff --git a/.jenkins/build.sh b/.jenkins/build.sh index da54b961ed2..71508d8ad7c 100755 --- a/.jenkins/build.sh +++ b/.jenkins/build.sh @@ -105,6 +105,7 @@ if [[ "${JOB_BASE_NAME}" == *worker_* ]]; then # 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_tutorial_built_correct.py docs # Step 6: Copy generated files to S3, tag with commit ID 7z a worker_${WORKER_ID}.7z docs diff --git a/.jenkins/validate_tutorial_built_correct.py b/.jenkins/validate_tutorial_built_correct.py new file mode 100644 index 00000000000..037d40f7ba9 --- /dev/null +++ b/.jenkins/validate_tutorial_built_correct.py @@ -0,0 +1,95 @@ +import sys +import glob +import re + +from bs4 import BeautifulSoup + +KNOWN_BAD = [ + "beginner/translation_transformer.html", + "beginner/torchtext_translation.html", + "beginner/profiler.html", + "beginner/saving_loading_models.html", + "beginner/basics/intro.html", + "beginner/introyt/captumyt.html", + "beginner/introyt/trainingyt.html", + "beginner/examples_nn/polynomial_module.html", + "beginner/examples_nn/two_layer_net_optim.html", + "beginner/examples_nn/dynamic_net.html", + "beginner/examples_nn/two_layer_net_module.html", + "beginner/examples_nn/polynomial_optim.html", + "beginner/examples_nn/polynomial_nn.html", + "beginner/examples_nn/two_layer_net_nn.html", + "beginner/examples_tensor/two_layer_net_tensor.html", + "beginner/examples_tensor/two_layer_net_numpy.html", + "beginner/examples_tensor/polynomial_numpy.html", + "beginner/examples_tensor/polynomial_tensor.html", + "beginner/former_torchies/autograd_tutorial_old.html", + "beginner/former_torchies/tensor_tutorial_old.html", + "beginner/examples_autograd/two_layer_net_autograd.html", + "beginner/examples_autograd/polynomial_autograd.html", + "beginner/examples_autograd/tf_two_layer_net.html", + "beginner/examples_autograd/polynomial_custom_function.html", + "beginner/examples_autograd/two_layer_net_custom_function.html", + "intermediate/forward_ad_usage.html", + "intermediate/parametrizations.html", + "intermediate/reinforcement_q_learning.html", + "intermediate/text_to_speech_with_torchaudio.html", + "intermediate/fx_conv_bn_fuser.html", + "advanced/super_resolution_with_onnxruntime.html", + "advanced/super_resolution_with_caffe2.html", + "advanced/ddp_pipeline.html", + "prototype/fx_graph_mode_ptq_dynamic.html", + "prototype/vmap_recipe.html", + "prototype/torchscript_freezing.html", + "recipes/recipes/saving_and_loading_models_for_inference.html", + "recipes/recipes/saving_multiple_models_in_one_file.html", + "recipes/recipes/loading_data_recipe.html", + "recipes/recipes/tensorboard_with_pytorch.html", + "recipes/recipes/what_is_state_dict.html", + "recipes/recipes/profiler_recipe.html", + "recipes/recipes/save_load_across_devices.html", + "recipes/recipes/warmstarting_model_using_parameters_from_a_different_model.html", + "recipes/recipes/dynamic_quantization.html", + "recipes/recipes/saving_and_loading_a_general_checkpoint.html", + "recipes/recipes/benchmark.html", + "recipes/recipes/tuning_guide.html", + "recipes/recipes/custom_dataset_transforms_loader.html", + "recipes/recipes/zeroing_out_gradients.html", + "recipes/recipes/intel_extension_for_pytorch.html", + "recipes/recipes/defining_a_neural_network.html", + "recipes/recipes/timer_quick_start.html", + "recipes/recipes/amp_recipe.html", +] + + +def main(): + build_dir = sys.argv[1] + + html_file_paths = [] + + for difficulty in ["beginner", "intermediate", "advanced", "prototype", "recipes"]: + glob_path = f"{build_dir}/{difficulty}/**/*.html" + html_file_paths += glob.glob(glob_path, recursive=True) + + did_not_run = [] + for html_file_path in html_file_paths: + with open(html_file_path, "r", encoding="utf-8") as html_file: + html = html_file.read() + html_soup = BeautifulSoup(html, "html.parser") + elems = html_soup.find_all("p", {"class": "sphx-glr-timing"}) + for elem in elems: + if ( + "Total running time of the script: ( 0 minutes 0.000 seconds)" + in elem.text + and not any(html_file_path.endswith(file) for file in KNOWN_BAD) + ): + did_not_run.append(html_file_path) + + if len(did_not_run) != 0: + raise RuntimeError( + f"Files {' '.join(did_not_run)} are not known bad but ran in 0.000 sec, meaning that any python code in this tutorial probably didn't run" + ) + + +if __name__ == "__main__": + main() From cf4d0768b87cd93c0e788effed60a0d38fa63319 Mon Sep 17 00:00:00 2001 From: Catherine Lee Date: Wed, 7 Sep 2022 16:05:27 -0700 Subject: [PATCH 02/10] make wget less verbose --- Makefile | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 0f3bde6aadb..8c21384967c 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ download: # NOTE: Please consider using the Step1 and one of Step2 for new dataset, # [something] should be replaced with the actual value. - # Step1. DOWNLOAD: wget -N [SOURCE_FILE] -P $(DATADIR) + # Step1. DOWNLOAD: wget -nv -N [SOURCE_FILE] -P $(DATADIR) # Step2-1. UNZIP: unzip -o $(DATADIR)/[SOURCE_FILE] -d [*_source/data/] # Step2-2. UNTAR: tar -xzf $(DATADIR)/[SOURCE_FILE] -C [*_source/data/] # Step2-3. AS-IS: cp $(DATADIR)/[SOURCE_FILE] [*_source/data/] @@ -46,18 +46,18 @@ download: mkdir -p prototype_source/data # transfer learning tutorial data - wget -N https://download.pytorch.org/tutorial/hymenoptera_data.zip -P $(DATADIR) + wget -nv -N https://download.pytorch.org/tutorial/hymenoptera_data.zip -P $(DATADIR) unzip $(ZIPOPTS) $(DATADIR)/hymenoptera_data.zip -d beginner_source/data/ # nlp tutorial data - wget -N https://download.pytorch.org/tutorial/data.zip -P $(DATADIR) + wget -nv -N https://download.pytorch.org/tutorial/data.zip -P $(DATADIR) unzip $(ZIPOPTS) $(DATADIR)/data.zip -d intermediate_source/ # This will unzip all files in data.zip to intermediate_source/data/ folder # data loader tutorial - wget -N https://download.pytorch.org/tutorial/faces.zip -P $(DATADIR) + wget -nv -N https://download.pytorch.org/tutorial/faces.zip -P $(DATADIR) unzip $(ZIPOPTS) $(DATADIR)/faces.zip -d beginner_source/data/ - wget -N https://download.pytorch.org/models/tutorials/4000_checkpoint.tar -P $(DATADIR) + wget -nv -N https://download.pytorch.org/models/tutorials/4000_checkpoint.tar -P $(DATADIR) cp $(DATADIR)/4000_checkpoint.tar beginner_source/data/ # neural style images @@ -66,40 +66,40 @@ download: cp -r _static/img/neural-style/ advanced_source/data/images/ # Download dataset for beginner_source/dcgan_faces_tutorial.py - wget -N https://s3.amazonaws.com/pytorch-tutorial-assets/img_align_celeba.zip -P $(DATADIR) + wget -nv -N https://s3.amazonaws.com/pytorch-tutorial-assets/img_align_celeba.zip -P $(DATADIR) unzip $(ZIPOPTS) $(DATADIR)/img_align_celeba.zip -d beginner_source/data/celeba # Download dataset for beginner_source/hybrid_frontend/introduction_to_hybrid_frontend_tutorial.py - wget -N https://s3.amazonaws.com/pytorch-tutorial-assets/iris.data -P $(DATADIR) + wget -nv -N https://s3.amazonaws.com/pytorch-tutorial-assets/iris.data -P $(DATADIR) cp $(DATADIR)/iris.data beginner_source/data/ # Download dataset for beginner_source/chatbot_tutorial.py - wget -N https://s3.amazonaws.com/pytorch-tutorial-assets/cornell_movie_dialogs_corpus_v2.zip -P $(DATADIR) + wget -nv -N https://s3.amazonaws.com/pytorch-tutorial-assets/cornell_movie_dialogs_corpus_v2.zip -P $(DATADIR) unzip $(ZIPOPTS) $(DATADIR)/cornell_movie_dialogs_corpus_v2.zip -d beginner_source/data/ # Download dataset for beginner_source/audio_classifier_tutorial.py - wget -N https://s3.amazonaws.com/pytorch-tutorial-assets/UrbanSound8K.tar.gz -P $(DATADIR) + wget -nv -N https://s3.amazonaws.com/pytorch-tutorial-assets/UrbanSound8K.tar.gz -P $(DATADIR) tar $(TAROPTS) -xzf $(DATADIR)/UrbanSound8K.tar.gz -C ./beginner_source/data/ # Download model for beginner_source/fgsm_tutorial.py - wget -N https://s3.amazonaws.com/pytorch-tutorial-assets/lenet_mnist_model.pth -P $(DATADIR) + wget -nv -N https://s3.amazonaws.com/pytorch-tutorial-assets/lenet_mnist_model.pth -P $(DATADIR) cp $(DATADIR)/lenet_mnist_model.pth ./beginner_source/data/lenet_mnist_model.pth # Download model for advanced_source/dynamic_quantization_tutorial.py - wget -N https://s3.amazonaws.com/pytorch-tutorial-assets/word_language_model_quantize.pth -P $(DATADIR) + wget -nv -N https://s3.amazonaws.com/pytorch-tutorial-assets/word_language_model_quantize.pth -P $(DATADIR) cp $(DATADIR)/word_language_model_quantize.pth advanced_source/data/word_language_model_quantize.pth # Download data for advanced_source/dynamic_quantization_tutorial.py - wget -N https://s3.amazonaws.com/pytorch-tutorial-assets/wikitext-2.zip -P $(DATADIR) + wget -nv -N https://s3.amazonaws.com/pytorch-tutorial-assets/wikitext-2.zip -P $(DATADIR) unzip $(ZIPOPTS) $(DATADIR)/wikitext-2.zip -d advanced_source/data/ # Download model for advanced_source/static_quantization_tutorial.py - wget -N https://download.pytorch.org/models/mobilenet_v2-b0353104.pth -P $(DATADIR) + wget -nv -N https://download.pytorch.org/models/mobilenet_v2-b0353104.pth -P $(DATADIR) cp $(DATADIR)/mobilenet_v2-b0353104.pth advanced_source/data/mobilenet_pretrained_float.pth # Download model for prototype_source/graph_mode_static_quantization_tutorial.py - wget -N https://download.pytorch.org/models/resnet18-5c106cde.pth -P $(DATADIR) + wget -nv -N https://download.pytorch.org/models/resnet18-5c106cde.pth -P $(DATADIR) cp $(DATADIR)/resnet18-5c106cde.pth prototype_source/data/resnet18_pretrained_float.pth From 1172e71e30960ad7d6a71492bd7f028c4f4805bd Mon Sep 17 00:00:00 2001 From: Catherine Lee Date: Wed, 7 Sep 2022 16:16:56 -0700 Subject: [PATCH 03/10] more files --- .jenkins/validate_tutorial_built_correct.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/.jenkins/validate_tutorial_built_correct.py b/.jenkins/validate_tutorial_built_correct.py index 037d40f7ba9..52962bac7c8 100644 --- a/.jenkins/validate_tutorial_built_correct.py +++ b/.jenkins/validate_tutorial_built_correct.py @@ -34,6 +34,7 @@ "intermediate/parametrizations.html", "intermediate/reinforcement_q_learning.html", "intermediate/text_to_speech_with_torchaudio.html", + "intermediate/mnist_train_nas.html", "intermediate/fx_conv_bn_fuser.html", "advanced/super_resolution_with_onnxruntime.html", "advanced/super_resolution_with_caffe2.html", @@ -41,6 +42,7 @@ "prototype/fx_graph_mode_ptq_dynamic.html", "prototype/vmap_recipe.html", "prototype/torchscript_freezing.html", + "prototype/nestedtensor.html", "recipes/recipes/saving_and_loading_models_for_inference.html", "recipes/recipes/saving_multiple_models_in_one_file.html", "recipes/recipes/loading_data_recipe.html", @@ -87,7 +89,7 @@ def main(): if len(did_not_run) != 0: raise RuntimeError( - f"Files {' '.join(did_not_run)} are not known bad but ran in 0.000 sec, meaning that any python code in this tutorial probably didn't run" + f"File(s) {' '.join(did_not_run)} are not known bad but ran in 0.000 sec, meaning that any python code in this tutorial probably didn't run" ) From 8758ffb87c7c71a869ad97d9f75f4428f3957d94 Mon Sep 17 00:00:00 2001 From: Catherine Lee Date: Wed, 7 Sep 2022 16:50:27 -0700 Subject: [PATCH 04/10] refactor --- .jenkins/build.sh | 2 +- ...rial_built_correct.py => validate_tutorials_built.py} | 9 +++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) rename .jenkins/{validate_tutorial_built_correct.py => validate_tutorials_built.py} (95%) diff --git a/.jenkins/build.sh b/.jenkins/build.sh index 71508d8ad7c..6debc9132c6 100755 --- a/.jenkins/build.sh +++ b/.jenkins/build.sh @@ -105,7 +105,7 @@ if [[ "${JOB_BASE_NAME}" == *worker_* ]]; then # 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_tutorial_built_correct.py docs + python .jenkins/validate_tutorials_built.py docs # Step 6: Copy generated files to S3, tag with commit ID 7z a worker_${WORKER_ID}.7z docs diff --git a/.jenkins/validate_tutorial_built_correct.py b/.jenkins/validate_tutorials_built.py similarity index 95% rename from .jenkins/validate_tutorial_built_correct.py rename to .jenkins/validate_tutorials_built.py index 52962bac7c8..881fb1b4f4c 100644 --- a/.jenkins/validate_tutorial_built_correct.py +++ b/.jenkins/validate_tutorials_built.py @@ -4,12 +4,16 @@ from bs4 import BeautifulSoup +# files that are ok to have 0 min 0 sec time, probably because they don't have any python code +OK_TO_NOT_RUN = [ + "beginner/basics/intro.html", +] + KNOWN_BAD = [ "beginner/translation_transformer.html", "beginner/torchtext_translation.html", "beginner/profiler.html", "beginner/saving_loading_models.html", - "beginner/basics/intro.html", "beginner/introyt/captumyt.html", "beginner/introyt/trainingyt.html", "beginner/examples_nn/polynomial_module.html", @@ -61,6 +65,7 @@ "recipes/recipes/defining_a_neural_network.html", "recipes/recipes/timer_quick_start.html", "recipes/recipes/amp_recipe.html", + "recipes/recipes/Captum_Recipe.html", ] @@ -83,7 +88,7 @@ def main(): if ( "Total running time of the script: ( 0 minutes 0.000 seconds)" in elem.text - and not any(html_file_path.endswith(file) for file in KNOWN_BAD) + and not any(html_file_path.endswith(file) for file in KNOWN_BAD + OK_TO_NOT_RUN) ): did_not_run.append(html_file_path) From a8586036bee664c49e237bdd4ecd79ef874760de Mon Sep 17 00:00:00 2001 From: Catherine Lee Date: Thu, 8 Sep 2022 10:15:30 -0700 Subject: [PATCH 05/10] update --- .jenkins/build.sh | 1 + .jenkins/validate_tutorials_built.py | 9 +++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/.jenkins/build.sh b/.jenkins/build.sh index 6debc9132c6..48680bc7458 100755 --- a/.jenkins/build.sh +++ b/.jenkins/build.sh @@ -139,6 +139,7 @@ elif [[ "${JOB_BASE_NAME}" == *manager ]]; then # 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 docs # Step 6: Copy generated HTML files and static files to S3 7z a manager.7z docs diff --git a/.jenkins/validate_tutorials_built.py b/.jenkins/validate_tutorials_built.py index 881fb1b4f4c..b104d48f6a9 100644 --- a/.jenkins/validate_tutorials_built.py +++ b/.jenkins/validate_tutorials_built.py @@ -88,13 +88,18 @@ def main(): if ( "Total running time of the script: ( 0 minutes 0.000 seconds)" in elem.text - and not any(html_file_path.endswith(file) for file in KNOWN_BAD + OK_TO_NOT_RUN) + and not any( + html_file_path.endswith(file) for file in KNOWN_BAD + OK_TO_NOT_RUN + ) ): did_not_run.append(html_file_path) if len(did_not_run) != 0: raise RuntimeError( - f"File(s) {' '.join(did_not_run)} are not known bad but ran in 0.000 sec, meaning that any python code in this tutorial probably didn't run" + "The following file(s) are not known bad but ran in 0.000 sec, meaning that any " + + "python code in this tutorial probably didn't run:\n{}".format( + "\n".join(did_not_run) + ) ) From 71b585a9b842eba6eb013d8b14a52c5ed3c6c5d6 Mon Sep 17 00:00:00 2001 From: Catherine Lee Date: Thu, 8 Sep 2022 11:32:14 -0700 Subject: [PATCH 06/10] undo makefile changes, will put in separate pr --- Makefile | 28 ++++++++++++++-------------- 1 file changed, 14 insertions(+), 14 deletions(-) diff --git a/Makefile b/Makefile index 8c21384967c..0f3bde6aadb 100644 --- a/Makefile +++ b/Makefile @@ -33,7 +33,7 @@ download: # NOTE: Please consider using the Step1 and one of Step2 for new dataset, # [something] should be replaced with the actual value. - # Step1. DOWNLOAD: wget -nv -N [SOURCE_FILE] -P $(DATADIR) + # Step1. DOWNLOAD: wget -N [SOURCE_FILE] -P $(DATADIR) # Step2-1. UNZIP: unzip -o $(DATADIR)/[SOURCE_FILE] -d [*_source/data/] # Step2-2. UNTAR: tar -xzf $(DATADIR)/[SOURCE_FILE] -C [*_source/data/] # Step2-3. AS-IS: cp $(DATADIR)/[SOURCE_FILE] [*_source/data/] @@ -46,18 +46,18 @@ download: mkdir -p prototype_source/data # transfer learning tutorial data - wget -nv -N https://download.pytorch.org/tutorial/hymenoptera_data.zip -P $(DATADIR) + wget -N https://download.pytorch.org/tutorial/hymenoptera_data.zip -P $(DATADIR) unzip $(ZIPOPTS) $(DATADIR)/hymenoptera_data.zip -d beginner_source/data/ # nlp tutorial data - wget -nv -N https://download.pytorch.org/tutorial/data.zip -P $(DATADIR) + wget -N https://download.pytorch.org/tutorial/data.zip -P $(DATADIR) unzip $(ZIPOPTS) $(DATADIR)/data.zip -d intermediate_source/ # This will unzip all files in data.zip to intermediate_source/data/ folder # data loader tutorial - wget -nv -N https://download.pytorch.org/tutorial/faces.zip -P $(DATADIR) + wget -N https://download.pytorch.org/tutorial/faces.zip -P $(DATADIR) unzip $(ZIPOPTS) $(DATADIR)/faces.zip -d beginner_source/data/ - wget -nv -N https://download.pytorch.org/models/tutorials/4000_checkpoint.tar -P $(DATADIR) + wget -N https://download.pytorch.org/models/tutorials/4000_checkpoint.tar -P $(DATADIR) cp $(DATADIR)/4000_checkpoint.tar beginner_source/data/ # neural style images @@ -66,40 +66,40 @@ download: cp -r _static/img/neural-style/ advanced_source/data/images/ # Download dataset for beginner_source/dcgan_faces_tutorial.py - wget -nv -N https://s3.amazonaws.com/pytorch-tutorial-assets/img_align_celeba.zip -P $(DATADIR) + wget -N https://s3.amazonaws.com/pytorch-tutorial-assets/img_align_celeba.zip -P $(DATADIR) unzip $(ZIPOPTS) $(DATADIR)/img_align_celeba.zip -d beginner_source/data/celeba # Download dataset for beginner_source/hybrid_frontend/introduction_to_hybrid_frontend_tutorial.py - wget -nv -N https://s3.amazonaws.com/pytorch-tutorial-assets/iris.data -P $(DATADIR) + wget -N https://s3.amazonaws.com/pytorch-tutorial-assets/iris.data -P $(DATADIR) cp $(DATADIR)/iris.data beginner_source/data/ # Download dataset for beginner_source/chatbot_tutorial.py - wget -nv -N https://s3.amazonaws.com/pytorch-tutorial-assets/cornell_movie_dialogs_corpus_v2.zip -P $(DATADIR) + wget -N https://s3.amazonaws.com/pytorch-tutorial-assets/cornell_movie_dialogs_corpus_v2.zip -P $(DATADIR) unzip $(ZIPOPTS) $(DATADIR)/cornell_movie_dialogs_corpus_v2.zip -d beginner_source/data/ # Download dataset for beginner_source/audio_classifier_tutorial.py - wget -nv -N https://s3.amazonaws.com/pytorch-tutorial-assets/UrbanSound8K.tar.gz -P $(DATADIR) + wget -N https://s3.amazonaws.com/pytorch-tutorial-assets/UrbanSound8K.tar.gz -P $(DATADIR) tar $(TAROPTS) -xzf $(DATADIR)/UrbanSound8K.tar.gz -C ./beginner_source/data/ # Download model for beginner_source/fgsm_tutorial.py - wget -nv -N https://s3.amazonaws.com/pytorch-tutorial-assets/lenet_mnist_model.pth -P $(DATADIR) + wget -N https://s3.amazonaws.com/pytorch-tutorial-assets/lenet_mnist_model.pth -P $(DATADIR) cp $(DATADIR)/lenet_mnist_model.pth ./beginner_source/data/lenet_mnist_model.pth # Download model for advanced_source/dynamic_quantization_tutorial.py - wget -nv -N https://s3.amazonaws.com/pytorch-tutorial-assets/word_language_model_quantize.pth -P $(DATADIR) + wget -N https://s3.amazonaws.com/pytorch-tutorial-assets/word_language_model_quantize.pth -P $(DATADIR) cp $(DATADIR)/word_language_model_quantize.pth advanced_source/data/word_language_model_quantize.pth # Download data for advanced_source/dynamic_quantization_tutorial.py - wget -nv -N https://s3.amazonaws.com/pytorch-tutorial-assets/wikitext-2.zip -P $(DATADIR) + wget -N https://s3.amazonaws.com/pytorch-tutorial-assets/wikitext-2.zip -P $(DATADIR) unzip $(ZIPOPTS) $(DATADIR)/wikitext-2.zip -d advanced_source/data/ # Download model for advanced_source/static_quantization_tutorial.py - wget -nv -N https://download.pytorch.org/models/mobilenet_v2-b0353104.pth -P $(DATADIR) + wget -N https://download.pytorch.org/models/mobilenet_v2-b0353104.pth -P $(DATADIR) cp $(DATADIR)/mobilenet_v2-b0353104.pth advanced_source/data/mobilenet_pretrained_float.pth # Download model for prototype_source/graph_mode_static_quantization_tutorial.py - wget -nv -N https://download.pytorch.org/models/resnet18-5c106cde.pth -P $(DATADIR) + wget -N https://download.pytorch.org/models/resnet18-5c106cde.pth -P $(DATADIR) cp $(DATADIR)/resnet18-5c106cde.pth prototype_source/data/resnet18_pretrained_float.pth From a012d324ee464ae85c5f7a625894da397acc0700 Mon Sep 17 00:00:00 2001 From: Catherine Lee Date: Thu, 8 Sep 2022 13:17:46 -0700 Subject: [PATCH 07/10] update --- .jenkins/build.sh | 4 ++-- .jenkins/validate_tutorials_built.py | 28 +++++++++++++++++----------- 2 files changed, 19 insertions(+), 13 deletions(-) diff --git a/.jenkins/build.sh b/.jenkins/build.sh index 48680bc7458..50535cdab58 100755 --- a/.jenkins/build.sh +++ b/.jenkins/build.sh @@ -105,7 +105,7 @@ if [[ "${JOB_BASE_NAME}" == *worker_* ]]; then # 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 docs + python .jenkins/validate_tutorials_built.py # Step 6: Copy generated files to S3, tag with commit ID 7z a worker_${WORKER_ID}.7z docs @@ -139,7 +139,7 @@ elif [[ "${JOB_BASE_NAME}" == *manager ]]; then # 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 docs + python .jenkins/validate_tutorials_built.py # Step 6: Copy generated HTML files and static files to S3 7z a manager.7z docs diff --git a/.jenkins/validate_tutorials_built.py b/.jenkins/validate_tutorials_built.py index b104d48f6a9..353f9b5b55b 100644 --- a/.jenkins/validate_tutorials_built.py +++ b/.jenkins/validate_tutorials_built.py @@ -1,9 +1,10 @@ -import sys -import glob -import re +from pathlib import Path +from typing import List from bs4 import BeautifulSoup +REPO_ROOT = Path(__file__).parent.parent + # files that are ok to have 0 min 0 sec time, probably because they don't have any python code OK_TO_NOT_RUN = [ "beginner/basics/intro.html", @@ -69,14 +70,19 @@ ] -def main(): - build_dir = sys.argv[1] +def tutorial_source_dirs() -> List[Path]: + return [ + p.relative_to(REPO_ROOT).with_stem(p.stem[:-7]) + for p in REPO_ROOT.glob("*_source") + ] - html_file_paths = [] - for difficulty in ["beginner", "intermediate", "advanced", "prototype", "recipes"]: - glob_path = f"{build_dir}/{difficulty}/**/*.html" - html_file_paths += glob.glob(glob_path, recursive=True) +def main() -> None: + docs_dir = REPO_ROOT / "docs" + html_file_paths = [] + for tutorial_source_dir in tutorial_source_dirs(): + glob_path = f"{tutorial_source_dir}/**/*.html" + html_file_paths += docs_dir.glob(glob_path) did_not_run = [] for html_file_path in html_file_paths: @@ -89,10 +95,10 @@ def main(): "Total running time of the script: ( 0 minutes 0.000 seconds)" in elem.text and not any( - html_file_path.endswith(file) for file in KNOWN_BAD + OK_TO_NOT_RUN + html_file_path.match(file) for file in KNOWN_BAD + OK_TO_NOT_RUN ) ): - did_not_run.append(html_file_path) + did_not_run.append(html_file_path.as_posix()) if len(did_not_run) != 0: raise RuntimeError( From 473a2a808ca20346d7fd3e411121f569ebef78f5 Mon Sep 17 00:00:00 2001 From: Catherine Lee Date: Thu, 8 Sep 2022 14:53:50 -0700 Subject: [PATCH 08/10] python3.7 --- .jenkins/validate_tutorials_built.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.jenkins/validate_tutorials_built.py b/.jenkins/validate_tutorials_built.py index 353f9b5b55b..13d9eec97f9 100644 --- a/.jenkins/validate_tutorials_built.py +++ b/.jenkins/validate_tutorials_built.py @@ -72,7 +72,7 @@ def tutorial_source_dirs() -> List[Path]: return [ - p.relative_to(REPO_ROOT).with_stem(p.stem[:-7]) + p.relative_to(REPO_ROOT).with_name(p.stem[:-7]) for p in REPO_ROOT.glob("*_source") ] From b6726411d590f8462afc07e59107d5c00e9a2b48 Mon Sep 17 00:00:00 2001 From: Catherine Lee Date: Thu, 8 Sep 2022 16:29:06 -0700 Subject: [PATCH 09/10] remove some files --- .jenkins/validate_tutorials_built.py | 16 ++-------------- 1 file changed, 2 insertions(+), 14 deletions(-) diff --git a/.jenkins/validate_tutorials_built.py b/.jenkins/validate_tutorials_built.py index 13d9eec97f9..96a705b3709 100644 --- a/.jenkins/validate_tutorials_built.py +++ b/.jenkins/validate_tutorials_built.py @@ -7,34 +7,26 @@ # files that are ok to have 0 min 0 sec time, probably because they don't have any python code OK_TO_NOT_RUN = [ - "beginner/basics/intro.html", + "beginner/basics/intro.html", # no code ] +# when the tutorial is fixed, remove it from this list KNOWN_BAD = [ "beginner/translation_transformer.html", - "beginner/torchtext_translation.html", "beginner/profiler.html", "beginner/saving_loading_models.html", "beginner/introyt/captumyt.html", "beginner/introyt/trainingyt.html", "beginner/examples_nn/polynomial_module.html", - "beginner/examples_nn/two_layer_net_optim.html", "beginner/examples_nn/dynamic_net.html", - "beginner/examples_nn/two_layer_net_module.html", "beginner/examples_nn/polynomial_optim.html", "beginner/examples_nn/polynomial_nn.html", - "beginner/examples_nn/two_layer_net_nn.html", - "beginner/examples_tensor/two_layer_net_tensor.html", - "beginner/examples_tensor/two_layer_net_numpy.html", "beginner/examples_tensor/polynomial_numpy.html", "beginner/examples_tensor/polynomial_tensor.html", "beginner/former_torchies/autograd_tutorial_old.html", "beginner/former_torchies/tensor_tutorial_old.html", - "beginner/examples_autograd/two_layer_net_autograd.html", "beginner/examples_autograd/polynomial_autograd.html", - "beginner/examples_autograd/tf_two_layer_net.html", "beginner/examples_autograd/polynomial_custom_function.html", - "beginner/examples_autograd/two_layer_net_custom_function.html", "intermediate/forward_ad_usage.html", "intermediate/parametrizations.html", "intermediate/reinforcement_q_learning.html", @@ -42,7 +34,6 @@ "intermediate/mnist_train_nas.html", "intermediate/fx_conv_bn_fuser.html", "advanced/super_resolution_with_onnxruntime.html", - "advanced/super_resolution_with_caffe2.html", "advanced/ddp_pipeline.html", "prototype/fx_graph_mode_ptq_dynamic.html", "prototype/vmap_recipe.html", @@ -60,13 +51,10 @@ "recipes/recipes/saving_and_loading_a_general_checkpoint.html", "recipes/recipes/benchmark.html", "recipes/recipes/tuning_guide.html", - "recipes/recipes/custom_dataset_transforms_loader.html", "recipes/recipes/zeroing_out_gradients.html", - "recipes/recipes/intel_extension_for_pytorch.html", "recipes/recipes/defining_a_neural_network.html", "recipes/recipes/timer_quick_start.html", "recipes/recipes/amp_recipe.html", - "recipes/recipes/Captum_Recipe.html", ] From 4b263e1d236cc69e570ed028c5fb493395d031c6 Mon Sep 17 00:00:00 2001 From: Catherine Lee Date: Thu, 8 Sep 2022 17:22:27 -0700 Subject: [PATCH 10/10] update --- .jenkins/validate_tutorials_built.py | 1 + 1 file changed, 1 insertion(+) diff --git a/.jenkins/validate_tutorials_built.py b/.jenkins/validate_tutorials_built.py index 96a705b3709..09b35f64905 100644 --- a/.jenkins/validate_tutorials_built.py +++ b/.jenkins/validate_tutorials_built.py @@ -55,6 +55,7 @@ "recipes/recipes/defining_a_neural_network.html", "recipes/recipes/timer_quick_start.html", "recipes/recipes/amp_recipe.html", + "recipes/recipes/Captum_Recipe.html", ]