From 8134c7f4f1554e10b147f01cb1c94ffa78c2e137 Mon Sep 17 00:00:00 2001 From: Sean Morgan Date: Sun, 12 Apr 2020 23:04:53 -0400 Subject: [PATCH 1/3] Add test for tutorial table of contents --- .github/workflows/ci_test.yml | 12 +++++++ .github/workflows/verify_tutorial_toc.py | 46 ++++++++++++++++++++++++ docs/tutorials/_toc.yaml | 4 +++ 3 files changed, 62 insertions(+) create mode 100644 .github/workflows/verify_tutorial_toc.py diff --git a/.github/workflows/ci_test.yml b/.github/workflows/ci_test.yml index 6adced9572..3311a6f32f 100644 --- a/.github/workflows/ci_test.yml +++ b/.github/workflows/ci_test.yml @@ -106,3 +106,15 @@ jobs: - run: pip install pygithub click - name: Check that the CODEOWNERS is valid run: python .github/workflows/notify_codeowners.py .github/CODEOWNERS + tutorial-table-of-contents: + name: Check that all tutorials are included in documentation + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v2 + - uses: actions/setup-python@v1 + with: + python-version: 3.7 + - run: pip install pyyaml + - name: Check that all tutorials are included in table of contents + run: python .github/workflow/verify_tutorial_toc.py docs/tutorials/ + diff --git a/.github/workflows/verify_tutorial_toc.py b/.github/workflows/verify_tutorial_toc.py new file mode 100644 index 0000000000..c77cb6c769 --- /dev/null +++ b/.github/workflows/verify_tutorial_toc.py @@ -0,0 +1,46 @@ +import yaml +from pathlib import Path + + +def get_yaml_links(): + with open("docs/tutorials/_toc.yaml", "r") as stream: + toc = yaml.safe_load(stream)["toc"] + + links = [x["path"].split("/")[-1] for x in toc if "path" in x] + links.remove("overview") + + links_set = set(links) + assert len(links) == len( + links_set + ), "There are duplicate links in the table of contents" + + return links_set + + +def get_tutorial_notebooks(): + tutorial_dir = Path("docs/tutorials") + notebooks = [x.stem for x in tutorial_dir.glob("*.ipynb")] + notebooks.remove("_template") + + notebook_set = set(notebooks) + + assert len(notebooks) == len(notebook_set), "There are duplicate notebook filenames" + + return notebook_set + + +def verify_table_of_contents(): + + links = get_yaml_links() + tutorials = get_tutorial_notebooks() + difference = links ^ tutorials + + assert ( + len(difference) == 0 + ), "{0} tutorials were not found as ipython notebooks and table of contents links".format( + difference + ) + + +if __name__ == "__main__": + verify_table_of_contents() diff --git a/docs/tutorials/_toc.yaml b/docs/tutorials/_toc.yaml index 59757066f7..995781a46b 100644 --- a/docs/tutorials/_toc.yaml +++ b/docs/tutorials/_toc.yaml @@ -18,3 +18,7 @@ toc: path: /addons/tutorials/tqdm_progress_bar - title: Seq2Seq for Translation path: /addons/tutorials/networks_seq2seq_nmt +- title: Moving Average Optimizer Checkpoint + path: /addons/tutorials/average_optimizers_callback +- title: Time Stopping Callback + path: /addons/tutorials/time_stopping \ No newline at end of file From 76d7f048060325f65dac514c5c4288305a713f16 Mon Sep 17 00:00:00 2001 From: Sean Morgan Date: Sun, 12 Apr 2020 23:07:45 -0400 Subject: [PATCH 2/3] Remove arg --- .github/workflows/ci_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_test.yml b/.github/workflows/ci_test.yml index 3311a6f32f..d51d18fa4c 100644 --- a/.github/workflows/ci_test.yml +++ b/.github/workflows/ci_test.yml @@ -116,5 +116,5 @@ jobs: python-version: 3.7 - run: pip install pyyaml - name: Check that all tutorials are included in table of contents - run: python .github/workflow/verify_tutorial_toc.py docs/tutorials/ + run: python .github/workflow/verify_tutorial_toc.py From 674e7b68650c11635d566f95be38a545ff2c2052 Mon Sep 17 00:00:00 2001 From: Sean Morgan Date: Sun, 12 Apr 2020 23:09:24 -0400 Subject: [PATCH 3/3] typo --- .github/workflows/ci_test.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.github/workflows/ci_test.yml b/.github/workflows/ci_test.yml index d51d18fa4c..fe0c822e32 100644 --- a/.github/workflows/ci_test.yml +++ b/.github/workflows/ci_test.yml @@ -116,5 +116,5 @@ jobs: python-version: 3.7 - run: pip install pyyaml - name: Check that all tutorials are included in table of contents - run: python .github/workflow/verify_tutorial_toc.py + run: python .github/workflows/verify_tutorial_toc.py