Skip to content

Converting Jupyter Notebooks to Scripts

The Jupyter nbconvert tool allows you to convert an .ipynb notebook file into an executable python, Julia, Matlab, or R script.

In a terminal window go to the directory with your notebook. Then run:

jupyter nbconvert --to script notebook.ipynb

where notebook.ipynb is the name of the notebook you'd like to convert.

This will create a python script called notebook.py which you can run from the command line or launch to run as a job on the SuperCloud.

Running your python script as a SuperCloud job

In order to run your python script as a batch job on SuperCloud, you will need to create a launch script. In this example, the script is called train.sh and we will load the Anaconda 2022b module:

#!/bin/bash

module load anaconda/2022b
python notebook.py

To launch your script, use the LLsub command:

$ LLsub train.sh

Please note that this is the basic instruction on how to convert and submit a Jupyter Notebook as a batch job. This job as is will only request a single core. If you need to use additional resources, you will need additional scheduler options. Please refer to the Submitting Jobs page for how to request additional resources.