##// END OF EJS Templates
catch ConfigFileNotFound where appropriate...
catch ConfigFileNotFound where appropriate a few IOError catches were not updated in earlier commit 200a760b96f799fa26da295d7842ffb0bdbc3136

File last commit:

r4637:d919e2ec
r4909:54778f0a
Show More
taskmap.ipynb
70 lines | 3.2 KiB | text/plain | TextLexer

Load balanced map and parallel function decorator

In [4]:
from IPython.parallel import Client
In [5]:
rc = Client()
v = rc.load_balanced_view()
In [6]:
result = v.map(lambda x: 2*x, range(10))
print "Simple, default map: ", list(result)
Simple, default map:  [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
In [7]:
ar = v.map_async(lambda x: 2*x, range(10))
print "Submitted tasks, got ids: ", ar.msg_ids
result = ar.get()
print "Using a mapper: ", result
Submitted tasks, got ids:  ['2a25ff3f-f0d0-4428-909a-3fe808ca61f9', 'edd42168-fac2-4b3f-a696-ce61b37aa71d', '8a548908-7812-44e6-a8b1-68e941bee608', '26435a77-fe86-49b6-b59f-de864d59c99f', '6750c7b4-2168-49ec-bcc4-feb1e17c5e53', '117240d1-5dfc-4783-948f-e9523b2b2f6a', '6de16d46-f2e2-49bd-8180-e43d1d875529', '3d372b84-0c68-4315-92c8-a080c68478b7', '43acedae-e35c-4a17-87f0-9e5e672500f7', 'eb71dd1f-9500-4375-875d-c2c42999848c']
Using a mapper:  [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]
In [8]:
@v.parallel(block=True)
def f(x): return 2*x

result = f.map(range(10))
print "Using a parallel function: ", result
Using a parallel function:  [0, 2, 4, 6, 8, 10, 12, 14, 16, 18]