[IPython-User] parallelism with arbitrary function handles
Robert Nishihara
robertnishihara@gmail....
Tue Jun 19 21:14:20 CDT 2012
Hi,
I have been running into a problem using map_sync in IPython.parallel
(please tell me if this is the wrong place to ask this question). The
script below works fine:
from IPython import parallel
def run_stuff():
def func(x):
return x
rc = parallel.Client(profile='sge')
dview = rc[:]
dview['func'] = func
print dview.map_sync(func, range(10))
run_stuff()
The issue occurs when I want "func" to be parametrized by some arbitrary
function "f". The script below is the simple example that illustrates the
failure I am seeing
from IPython import parallel
def run_stuff(f):
rc = parallel.Client(profile='sge')
dview = rc[:]
dview['f'] = f
def func(x,f=f):
return f(x)
print dview.map_sync(func, range(10))
def g(x):
return x
run_stuff(g)
This script fails with the error:
AttributeError: 'module' object has no attribute 'g'.
The name "g" is not accessible to the function "run_stuff". The two scripts
are attached. Can anyone help?
-Robert
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://mail.scipy.org/pipermail/ipython-user/attachments/20120619/ee9cf020/attachment.html
-------------- next part --------------
A non-text attachment was scrubbed...
Name: run_working.py
Type: application/octet-stream
Size: 221 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/ipython-user/attachments/20120619/ee9cf020/attachment.obj
-------------- next part --------------
A non-text attachment was scrubbed...
Name: run_fail.py
Type: application/octet-stream
Size: 247 bytes
Desc: not available
Url : http://mail.scipy.org/pipermail/ipython-user/attachments/20120619/ee9cf020/attachment-0001.obj
More information about the IPython-User
mailing list