0

I'd like to reproduce the same functionality as described here: Save an IPython notebook programmatically from within itself?

With the one difference that it should be executed from a JuptyerLab notebook. When I use below code I get an error saying Javascript Error: IPython is not defined.

import time
from IPython.display import display, Javascript
import hashlib

def save_notebook(file_path):
    start_md5 = hashlib.md5(open(file_path,'rb').read()).hexdigest()
    display(Javascript('IPython.notebook.save_checkpoint();'))
    current_md5 = start_md5
    
    while start_md5 == current_md5:
        time.sleep(1)
        current_md5 = hashlib.md5(open(file_path,'rb').read()).hexdigest()

Thank you for your consideration.

S-UP
  • 83
  • 1
  • 8
  • Does this answer your question? [How to cause Jupyter Lab to save notebook (programmatically)](https://stackoverflow.com/questions/66880698/how-to-cause-jupyter-lab-to-save-notebook-programmatically) – krassowski Sep 01 '21 at 09:28
  • I deleted my answer here after realising that this is a duplicate, but I added it here: https://stackoverflow.com/a/69011143/6646912 (so there are now two different answers for this question in the duplicate target). – krassowski Sep 01 '21 at 09:30

0 Answers0