<commit_before># Remove the temp directory and then create a fresh one
import os
import shutil
import pyemu

nbdir = os.path.join('..', 'examples')

# -- make working directories
ddir = os.path.join(nbdir, 'data')
if os.path.isdir(ddir):
    shutil.rmtree(ddir)
os.mkdir(ddir)

tempdir = os.path.join('.', 'temp')
if os.path.isdir(tempdir):
    shutil.rmtree(tempdir)
os.mkdir(tempdir)

testdir = os.path.join('.', 'temp', 'Notebooks')
if os.path.isdir(testdir):
    shutil.rmtree(testdir)
os.mkdir(testdir)


def get_notebooks():
    return [f for f in os.listdir(nbdir) if f.endswith('.ipynb') and not "notest" in f]


def run_notebook(fn):
    #pth = os.path.join(nbdir, fn)
    pth = fn
    cmd = 'jupyter ' + 'nbconvert ' + \
          '--ExecutePreprocessor.kernel_name=python ' + \
          '--ExecutePreprocessor.timeout=6000 ' + '--to ' + 'notebook ' + \
          '--execute ' + '{} '.format(pth) + \
          '--output-dir ' + '{} '.format(testdir) + \
          '--output ' + '{}'.format(fn)
    print(cmd)
    #ival = os.system(cmd)
    ival = pyemu.os_utils.run(cmd,cwd=nbdir)
    assert ival == 0, 'could not run {}'.format(fn)


def test_notebooks():
    files = get_notebooks()

    for fn in files:
        yield run_notebook, fn


if __name__ == '__main__':
    files = get_notebooks()
    for fn in files:
        run_notebook(fn)<commit_msg>changed return value check in notebook tests<commit_after># Remove the temp directory and then create a fresh one
import os
import shutil
import pyemu

nbdir = os.path.join('..', 'examples')

# -- make working directories
ddir = os.path.join(nbdir, 'data')
if os.path.isdir(ddir):
    shutil.rmtree(ddir)
os.mkdir(ddir)

tempdir = os.path.join('.', 'temp')
if os.path.isdir(tempdir):
    shutil.rmtree(tempdir)
os.mkdir(tempdir)

testdir = os.path.join('.', 'temp', 'Notebooks')
if os.path.isdir(testdir):
    shutil.rmtree(testdir)
os.mkdir(testdir)


def get_notebooks():
    return [f for f in os.listdir(nbdir) if f.endswith('.ipynb') and not "notest" in f]


def run_notebook(fn):
    #pth = os.path.join(nbdir, fn)
    pth = fn
    cmd = 'jupyter ' + 'nbconvert ' + \
          '--ExecutePreprocessor.kernel_name=python ' + \
          '--ExecutePreprocessor.timeout=6000 ' + '--to ' + 'notebook ' + \
          '--execute ' + '{} '.format(pth) + \
          '--output-dir ' + '{} '.format(testdir) + \
          '--output ' + '{}'.format(fn)
    
    #ival = os.system(cmd)
    ival = pyemu.os_utils.run(cmd,cwd=nbdir)
    print(ival,cmd)
    assert ival == 0 or ival is None, 'could not run {}'.format(fn)


def test_notebooks():
    files = get_notebooks()

    for fn in files:
        yield run_notebook, fn

if __name__ == '__main__':
    files = get_notebooks()
    for fn in files:
        run_notebook(fn)
{'fraction_non_alphanumeric': 0.16415229885057472, 'fraction_numerical': 0.0035919540229885057, 'mean_word_length': 2.884239888423989, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1758468', 'n_tokens_mistral': 1065, 'n_tokens_neox': 1032, 'n_words': 235}