[IPython-User] Pushing Code to Engines?
Min RK
benjaminrk@gmail....
Tue Aug 16 11:16:05 CDT 2011
Not exactly. Push/execute are not available to the load balanced view (because you don't even know where you pushed to).
If you want to define and push a function locally, you can do that with the direct view. Once you have pushed it, it is available to call from the load balanced view, because 'g' ( in the example below) will be in globals.
-MinRK
On Aug 16, 2011, at 7:21, <darren@ontrenet.com> wrote:
>
> Hi,
> Thanks for the tip.
>
> Does this approach work for load balanced view? that's what I've been
> using
> and couldn't get it to work exactly, but I will try again when I get home.
>
> Darren
>
> On Mon, 15 Aug 2011 13:51:29 -0700, MinRK <benjaminrk@gmail.com> wrote:
>> To call a function on args remotely, you just use apply:
>>
>> rc = Client()
>> dview = Client[:]
>>
>> def f(a):
>> return a*2
>>
>> # call f(5) on every engine:
>> dview.apply(f, 5)
>>
>> # send f to all engines (as 'g', you can give it any name), so you can
> use
>> it many times:
>> dview['g'] = f
>>
>> # now you can call it with execute:
>> dview.execute('b=g(10)')
>>
>> -MinRK
>>
>> On Mon, Aug 15, 2011 at 13:34, Darren Govoni <darren@ontrenet.com>
> wrote:
>>
>>> Hi,
>>> I have a cluster and create a Client() from ip shell.
>>> I define a function in my shell space. Is it possible to have it pushed
>>> to the engines to execute? Or does all the code have to reside
>>> on the engines already?
>>>
>>> thanks for any tips. I'm reading all the docs, but missing these
>>> particulars.
>>>
>>> Darren
>>> _______________________________________________
>>> IPython-User mailing list
>>> IPython-User@scipy.org
>>> http://mail.scipy.org/mailman/listinfo/ipython-user
>>>
More information about the IPython-User
mailing list