Hi,<div><br></div><div>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:</div><div><br></div><div><div> from IPython import parallel</div>
<div><br></div><div> def run_stuff():</div><div> def func(x):</div><div> return x</div><div> rc = parallel.Client(profile='sge')</div><div> dview = rc[:]</div>
<div> dview['func'] = func</div><div> print dview.map_sync(func, range(10))</div><div><br></div><div> run_stuff()</div></div><div><br></div><div>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</div>
<div><br></div><div><div> from IPython import parallel</div><div><br> def run_stuff(f):</div><div> rc = parallel.Client(profile='sge')</div><div> dview = rc[:]</div><div> dview['f'] = f</div>
<div> def func(x,f=f):</div><div> return f(x)</div><div> print dview.map_sync(func, range(10))</div><div><br></div><div> def g(x):</div><div> return x</div><div><br></div>
<div> run_stuff(g)</div></div><div><br></div><div>This script fails with the error:</div><div><br></div><div> AttributeError: 'module' object has no attribute 'g'.</div><div><br></div><div>The name "g" is not accessible to the function "run_stuff". The two scripts are attached. Can anyone help?</div>
<div><br></div><div>-Robert</div>