diff --git a/.github/workflows/ci_test.yml b/.github/workflows/ci_test.yml index 6adced9572..fe0c822e32 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/workflows/verify_tutorial_toc.py + 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