To call a function on args remotely, you just use apply:<div><br></div><div>rc = Client()</div><div>dview = Client[:]</div><div><br></div><div>def f(a):</div><div> return a*2</div><div><br></div><div># call f(5) on every engine:</div>
<div>dview.apply(f, 5)</div><div><br></div><div># send f to all engines (as 'g', you can give it any name), so you can use it many times:</div><div>dview['g'] = f</div><div><br></div><div># now you can call it with execute:</div>
<div>dview.execute('b=g(10)')</div><div><br></div><div>-MinRK</div><div><br><div class="gmail_quote">On Mon, Aug 15, 2011 at 13:34, Darren Govoni <span dir="ltr"><<a href="mailto:darren@ontrenet.com">darren@ontrenet.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;">Hi,<br>
I have a cluster and create a Client() from ip shell.<br>
I define a function in my shell space. Is it possible to have it pushed<br>
to the engines to execute? Or does all the code have to reside<br>
on the engines already?<br>
<br>
thanks for any tips. I'm reading all the docs, but missing these<br>
particulars.<br>
<br>
Darren<br>
_______________________________________________<br>
IPython-User mailing list<br>
<a href="mailto:IPython-User@scipy.org">IPython-User@scipy.org</a><br>
<a href="http://mail.scipy.org/mailman/listinfo/ipython-user" target="_blank">http://mail.scipy.org/mailman/listinfo/ipython-user</a><br>
</blockquote></div><br></div>