Requested by Graham
@miguelgfierro we can use this command (or just add document about a user can convert any notebook by using the following command? what do you think?):
jupyter nbconvert --to script notebook.ipynb
(to other formats, see https://ipython.org/ipython-doc/3/notebook/nbconvert.html)
Here is the example of the conversion results of SAR single node quickstart notebook. See how the cell number and markdown cells are converted:
"# # SAR on MovieLens (Python, CPU)"
"# SAR is a fast scalable adaptive algorithm for ..."
.....
"# # 0 Global Settings and Imports"
"# In[2]:"
"# set the environment path to find Recommenders"
import sys
sys.path.append("../../")
import os
...
(added " because of the github auto conversion to md)
The only Some (see below Le's comment ;-) constraints of this conversion is the notebook module usage, like 'display()'
I tested conversion and run the converted script. It runs well until it sees 'display' call and got error:
NameError: name 'display' is not defined
@loomlike some other things to bear in mind are the magic commands used in the notebooks that may behave unexpectedly.
as mentioned by Le, this should work:
jupyter nbconvert --to script notebook.ipynb
Most helpful comment
@loomlike some other things to bear in mind are the magic commands used in the notebooks that may behave unexpectedly.