Skip to main content

Tools for running an IPython notebook in batch mode.

Project description

DO NOT USE THIS LIBRARY

Matthias Bussonnier was kind enough to point out that Paul Butler et al had written a library runipy that precede mine and is more mature. Consequently, this library, BatchNotebook is deprecated.

Please use: runipy instead.

Why Use This Library

  1. Explore data by writing an series of IPython notebooks.

  2. The Data are updated. Rerun all notebooks.

  3. Use nbconvert to generate reports from the executed notebooks.

This library saves time on step 2. That is, it allows you to rerun your notebooks from the command line, in batch mode, rather than running them manually or hacking together some browser runner with Selenium or something similar. It assumes that your executed notebook(s) will be used as a reporting tool (e.g. you want the inline html graphs.) If you do not need to use the executed notebook as a report, this library is not necessary; there are other scripts that can extract the code and turn it into a plain old py script.

According to this stackoverflow post, non-interactive IPython notebook execution will be added to the 2.0 core. Until then, I patched together this library from the work of others.

How To Use This Library

This library installs a script run_ipython_script.py. The following is the output of of run_ipython_script.py --help:

usage: run_ipython_script.py [-h] [--timeout TIMEOUT] [--verbose] src dst

Run IPython notebook scripts in batch mode.

positional arguments:
  src                   source notebook path
  dst                   destination notebook path

optional arguments:
  -h, --help            show this help message and exit
  --timeout TIMEOUT, -T TIMEOUT
                        max execution time in seconds per cell
  --verbose, -V         print status messages as processing proceeds

Caveats

Don’t use print. I’m not an IPython developer so I can’t explain why something does or does not work, but calls to print will break the output. Instead, do from IPython.display import HTML and return the HTML object in a cell where you want printed string output.

Contributing

If you have any bug fixes or contributions, please send a pull request to the BatchNotebook repository on github. However, please keep in mind this library is a temporary workaround to a problem that is being addressed by those developers who know IPython best. Therefore, you may want lend your typing hands to the next IPython 2.0 core, rather than me.

See also

This library was based off of: minrk’s script and davidshinn’s script.

Acknowledgements

This library was written to generate reports for a project funded by AFRL, managed by JHU/APL. I (John B Nelson) am the sole author, and I am responsible for any bugs or errors.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

BatchNotebook-0.0.3.tar.gz (4.2 kB view hashes)

Uploaded Source

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page