While Jupyter notebooks are commonly used interactively, with cells executed individually, on Code Ocean we ask that the notebook be executable as a whole and serve as a reproducible record of the analysis from start to finish. To render a Jupyter notebook from the command-line, or (in this case) from your run.sh  shell script, use the following command:

jupyter nbconvert \
  --ExecutePreprocessor.allow_errors=True \
  --ExecutePreprocessor.timeout=-1 \
  --FilesWriter.build_directory=../results \
  --execute notebook.ipynb

Notes:

  • The --ExecutePreprocessor.allow_errors=True flag isn't strictly necessary, but will reveal errors within the notebook, which makes debugging much easier.
  • The --ExecutePreprocessor.timeout=-1  flag will disable execution timeouts, allowing each cell to take as much time as it needs to execute.
  • If you are using Python 3 you may need to specify the following flag:
    --ExecutePreprocessor.kernel_name="python3"
     
  • See nbconvert's excellent documentation for more details.


For an example of a Jupyter running on Code Ocean, see Fractal Generation with L-Systems.

Did this answer your question?