Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Jupyter Notebook: command for save the current notebook?

I can automatically save the notebook into HTML after running code. However, sometimes the results are generated too quick, so the output HTML does not have the output in the last cells.

I'm wondering, if it is possible to tell the file to save itself?

Something like

# In last cell
current_filename = 'my_file.ipynb'
save_current_notebook(current_filename)
output_HTML(current_filename)

Now I can get away with:

display(Javascript("IPython.notebook.save_notebook()"),            
        include=['application/javascript'])
like image 516
cqcn1991 Avatar asked Apr 19 '16 07:04

cqcn1991


1 Answers

When the following cell is run, it automatically saves the notebook.

%%javascript
IPython.notebook.save_notebook()

I put it as the last cell of the notebook I want to be saved as soon as its execution is completed.

The suggestion made by OP didn't work for me, but the above did. Thank you for the idea.

like image 105
stason Avatar answered Oct 21 '22 11:10

stason