Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # This file has to be saved in your Jupyter config directory (found by running
- # jupyter --config-dir
- # but usually C:\Users\<username>\.jupyter\jupyter_notebook_config.py on Windows
- 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
- if 'collapsed' in cell['metadata']:
- cell['metadata'].pop('collapsed', 0)
- c.FileContentsManager.pre_save_hook = scrub_output_pre_save
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement