##// END OF EJS Templates
Delete all references to old IPython.external.guid...
Delete all references to old IPython.external.guid This reverts commit a36c8d5b0e660e57d2a3051d06670780c1e75c97, where uuid was replaced with guid. Signed-off-by: Thomas Spura <thomas.spura@gmail.com>

File last commit:

r4910:0dc49390
r5807:3ba61c59
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:  [&apos;2a25ff3f-f0d0-4428-909a-3fe808ca61f9&apos;, &apos;edd42168-fac2-4b3f-a696-ce61b37aa71d&apos;, &apos;8a548908-7812-44e6-a8b1-68e941bee608&apos;, &apos;26435a77-fe86-49b6-b59f-de864d59c99f&apos;, &apos;6750c7b4-2168-49ec-bcc4-feb1e17c5e53&apos;, &apos;117240d1-5dfc-4783-948f-e9523b2b2f6a&apos;, &apos;6de16d46-f2e2-49bd-8180-e43d1d875529&apos;, &apos;3d372b84-0c68-4315-92c8-a080c68478b7&apos;, &apos;43acedae-e35c-4a17-87f0-9e5e672500f7&apos;, &apos;eb71dd1f-9500-4375-875d-c2c42999848c&apos;]
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]