Example form this site: https://ipython.org/ipython-doc/2/parallel/parallel_demos.html
In this section we describe two more involved examples of using an IPython cluster to perform a parallel computation. We will be doing some plotting, so we start IPython with matplotlib integration by typing:
download a needed file from: https://github.com/ipython/ipython-py3k/blob/master/docs/examples/newparallel/pidigits.py
In [5]:
from IPython.parallel import Client
In [6]:
c = Client(profile='slurm')
In [9]:
v = c[:]
c.ids
Out[9]:
Download a helper file
In [18]:
%%bash
wget https://raw.githubusercontent.com/ipython/ipython-py3k/master/docs/examples/newparallel/pidigits.py
In [19]:
# init content of the downloaded file
run pidigits.py
In [20]:
filestring = 'pi200m.ascii.%(i)02dof20'
In [24]:
files = [filestring % {'i':i} for i in range(len(c.ids))]
files
Out[24]:
In [25]:
v.map(fetch_pi_file, files)
Out[25]:
In [ ]:
# This is the parallel calculation using the Client.map method
# which applies compute_two_digit_freqs to each file in files in parallel