<jupyter_start><jupyter_text>Master NotebookReference> https://github.com/tritemio/nbrunThis notebook executes the [template notebook](example-template-notebook.ipynb) passing different arguments.  Import nbrun.py<jupyter_code>import os
import sys
master_dir_path = os.getcwd()
print(master_dir_path)
os.chdir('../../')
qfog_path = os.getcwd()
print(qfog_path)
sys.path.insert(0,qfog_path)
# this doesn't work because of hyphen
# from jupyter-notebooks.nbrun import run_notebook

import importlib
mod = importlib.import_module("jupyter-notebooks.nbrun")<jupyter_output><empty_output><jupyter_text>Execute notebooks<jupyter_code># nbrun.py assumes that python cwd is the dir of the master notebook
os.chdir(master_dir_path)

nb_name = 'example-template-notebook'
for data_id in (0, 1):
    for analysis_type in ('a', 'b'):
        nb_kwargs = {'data_id': data_id, 'analysis_type': analysis_type}
        mod.run_notebook(nb_name, nb_suffix='-out_%d_%s' % (data_id, analysis_type), nb_kwargs=nb_kwargs)

# restore preferred cwd
os.chdir(qfog_path)<jupyter_output><empty_output><jupyter_text>How to generate links by hand I could generate my own links in a markdown cell this way:* link to out_0_a* [link to out_0_a](./example-template-notebook-out_0_a.ipynb)Note that html links are relative to dir of notebook in which they appear and independent of python cwd<jupyter_code># I could generate my own links in the output cell this way
from IPython.display import display, FileLink, HTML
def show_link(target, text):
    display(HTML('<a href=' + target + ' target="_blank">' + text + '</a>'))
    
fname = 'example-template-notebook-out_0_a.ipynb'
text = 'look here'
show_link(fname, text)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.11182294700058241, 'fraction_numerical': 0.004076878276062901, 'mean_word_length': 5.955465587044534, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 16, 'https://': 1, '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}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '242416', 'license': 'BSD-3-Clause', 'n_tokens_mistral': 611, 'n_tokens_neox': 604, 'n_words': 153, 'path': 'jupyter-notebooks/nbrun-example/example-master-notebook.ipynb', 'repo_name': 'NunoEdgarGFlowHub/quantum-fog', 'size': '1717'}