A year later, I managed to get what I wanted.
1) Create a function with what you want to do on different processors. Here it just calls the script from bash with the command ! magic ipython. I assume that it will work with the call() function.
def my_func(my_file): !python pgm.py {my_file}
Do not forget {} when using !
Please note that the path to my_file must be absolute, since clusters are the place where you started the notebook (when running jupyter notebook or ipython notebook ), which is not necessarily located where you are.
2) Run your ipython laptop cluster with the right amount of CPU. Wait 2 seconds and execute the following cell:
from IPython import parallel rc = parallel.Client() view = rc.load_balanced_view()
3) Get a list of files that you want to process:
files = list_of_files
4) Asynchronously compare your function with all your files with the view your engines you created. (not sure of the wording).
r = view.map_async(my_func, files)
While it works, you can do something else on the laptop (it works in the background !). You can also call r.wait_interactive() , which lists interactively the number of files processed and the amount of time spent so far and the number of remaining files. This will prevent other cells from starting (but you can interrupt it).
And if you have more files than engines, do not worry, they will be processed as soon as the engine finishes with 1 file.
Hope this helps others!
This tutorial can help:
http://nbviewer.ipython.org/github/minrk/IPython-parallel-tutorial/blob/master/Index.ipynb
Note that I still have IPython 2.3.1 , I donβt know if it has changed with Jupyter .
Edit: still working with Jupyter, see here for the difference and potential problems you might encounter
Please note that if you use external libraries in your function, you need to import them on different machines with:
%px import numpy as np
or
%%px import numpy as np import pandas as pd
Same with variables and other functions, you have to push them into the engine namespace:
rc[:].push(dict( foo=foo, bar=bar))