Created
January 17, 2018 02:51
-
-
Save qiuwch/cf0ac51b70f77ca1355d68d57392723d to your computer and use it in GitHub Desktop.
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
config_content = \ | |
''' | |
# Reference: https://svds.com/jupyter-notebook-best-practices-for-data-science/ | |
import os | |
from subprocess import check_call | |
def post_save(model, os_path, contents_manager): | |
"""post-save hook for converting notebooks to .py scripts""" | |
if model['type'] != 'notebook': | |
return # only do this for notebooks | |
d, fname = os.path.split(os_path) | |
check_call(['jupyter', 'nbconvert', '--to', 'script', fname], cwd=d) | |
check_call(['jupyter', 'nbconvert', '--to', 'html', fname], cwd=d) | |
c.FileContentsManager.post_save_hook = post_save | |
''' | |
with open('./jupyter_notebook_config.py', 'w') as f: | |
f.write(config_content) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment