Created
August 30, 2020 02:08
-
-
Save ayoskovich/e1af9db79a25ab0a4de7b5d4f98150e5 to your computer and use it in GitHub Desktop.
Add this to jupyter_notebook_config.py in order to auto remove cell numbers and output from jupyter notebooks.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def scrub_output_pre_save(model, **kwargs): | |
"""scrub output before saving notebooks""" | |
# only run on notebooks | |
if model['type'] != 'notebook': | |
return | |
# only run on nbformat v4 | |
if model['content']['nbformat'] != 4: | |
return | |
for cell in model['content']['cells']: | |
if cell['cell_type'] != 'code': | |
continue | |
cell['outputs'] = [] | |
cell['execution_count'] = None | |
c.FileContentsManager.pre_save_hook = scrub_output_pre_save |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
To show config directory:
$ jupyter --config-dir
To create a config file if one doesn't already exist:
$ jupyter notebook --generate-config