<jupyter_start><jupyter_text>Currently, there is no official auto-grading solution for grading student notebooks. There are a few options out there, but they will require some custom set up for each connector.The `connectortools` module has some functionality for making the process more simple. Currently this is in the form of a single function that lets you run a student's notbeook and collect the output of each cell. This may make it easier to auto-grade notebooks without manually running the cells.If there is another function or service you'd find useful, don't hesitate to ask the data 8 support team and we can try to throw something together if it's feasible. Running student notebooksLet's say that you've given a homework assignment to two students. You've added an assertion statement to test whether a function they created is correct. One student did this the right way, one did it the wrong way.You've got both student notebooks in a folder called `student_submissions`. Below we'll show how you can automatically run these notebooks.<jupyter_code>import nbclean as nbc<jupyter_output><empty_output><jupyter_text>Running a notebook individuallyYour first option is to use the `run_notebook` function. This will take a path to a notebook (or a notebook instance) as an input. It will execute the notebook and return the new notebook instance. You can then save the notebook if you wish.<jupyter_code># We can simply point to the notebook path
path_notebook = './test_notebooks/test_notebook.ipynb'
notebook = nbc.run_notebook(path_notebook)

# The output is an instance of `NotebookNode`
notebook['cells']
# Notebooks with an error will still be run
# The error message is collected in the output<jupyter_output><empty_output><jupyter_text>Running a directory of notebooksOften you just want to run a whole directory of notebooks and save the results so you can look at them later. You can do this with the `run_notebook_directory` function. In this case, you can easily save the outputs to a new folder for inspection.<jupyter_code>import os.path as op
directory = op.join('.', 'test_notebooks')
path_save = op.join(directory, 'executed_notebooks')
nbc.run_notebook_directory(directory, path_save=path_save, overwrite=True)<jupyter_output>100%|██████████| 2/2 [00:09<00:00,  4.53s/it]
{'fraction_non_alphanumeric': 0.059079061685490875, 'fraction_numerical': 0.007384882710686359, 'mean_word_length': 5.487323943661972, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 12, '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}}
{'chain_length': '3', 'dir': 'jupyter-structured-clean-dedup', 'id': '99740', 'license': 'MIT', 'n_tokens_mistral': 642, 'n_tokens_neox': 607, 'n_words': 313, 'path': 'examples/run_notebooks.ipynb', 'repo_name': 'betatim/nbclean', 'size': '2302'}