Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Automatic Notebook Testing #84

Open
r-pascua opened this issue Feb 15, 2020 · 0 comments
Open

Add Automatic Notebook Testing #84

r-pascua opened this issue Feb 15, 2020 · 0 comments

Comments

@r-pascua
Copy link
Contributor

To help ensure that our tutorial notebooks stay up-to-date with each new release, we should add a testing script that runs each notebook in the docs/tutorials folder. Here's a rough outline of a test that will do just that and clean things up afterward.

import os
import hera_sim

def test_tutorial_notebooks():
    base_path = os.path.split(hera_sim.__path__[0])[0]
    nb_path = os.path.join(base_path, "docs/tutorials")
    nb_names = [nb for nb in os.listdir(nb_path) if nb.endswith(".ipynb")]
    nb_files = [os.path.join(nb_path, nb_name) for nb_name in nb_names]
    for nb_file in nb_files:
        os.system("jupyter nbconvert --execute %s" % nb_file)

    # clean up all of the html files created by the above command
    nb_names_html = [nb for nb in os.listdir(nb_path) if nb.endswith(".html")]
    nb_files_html = [os.path.join(nb_path, nb_name) for nb_name in nb_names_html]
    assert len(nb_files) == len(nb_files_html)
    for nb_file_html in nb_files_html:
        os.remove(nb_file_html)

This should be the bare minimum needed for a test script that ensures each tutorial notebook runs successfully, but there will likely be complications (in particular, some fine tuning might be needed to make sure that none of the cells in the VisibilitySimulator tutorial time out). When this is implemented, the travis build will need to be updated to ensure that any extra dependencies (e.g. pygsm), as well as jupyter and nbconvert, are installed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants