[IPython-User] HOWTO invoke a script in parallel

Brian Granger ellisonbg@gmail....
Mon Dec 27 11:46:46 CST 2010


On Tue, Dec 21, 2010 at 10:25 AM, Stefan Seefeld
<stefan.seefeld@gmail.com> wrote:
> On 12/21/2010 12:09 PM, Brian Granger wrote:
>> On Tue, Dec 21, 2010 at 7:37 AM, Stefan Seefeld
>> <stefan.seefeld@gmail.com>  wrote:
>>
>>> I'm still trying to figure out how to run a script interactively in parallel
>>> (akin to `mpirun -np N<binary>` on the command line). Is this supported at
>>> all ? Is there some documentation explaining the semantics of such an
>>> operation ?
>> Yes, I think what you want is MultiEngineClient.run:
>>
>> https://github.com/ipython/ipython/blob/master/IPython/kernel/multiengineclient.py#L825
>
> That works fine, thanks.
>
> I still wonder, though: What does `px run script.py` mean ? Is it
> well-defined at all ? If not, couldn't it become a convenient alias for
> `mec.run('script.py')` ?

No that is not defined at the current.  Think of px this way.
Whatever follows the px is simply sent to the engines for execution.
It must be valid Python code.  It is just a short hand for
mec.execute:

px a = 10

is the same as:

mec.execute('a = 10')

Thus, when you do px run myscript.py you get:

mec.execute('run myscript.py')

Because run is not a valid Python command, it should give a
SyntaxError.  You could possibly use execfile:

px execfile('myscript.py', globals(), locals())

But using mec.run is probably best.

Cheers,

Brian



> Thanks,
>         Stefan
>
> --
>
>       ...ich hab' noch einen Koffer in Berlin...
>
> _______________________________________________
> IPython-User mailing list
> IPython-User@scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-user
>



-- 
Brian E. Granger, Ph.D.
Assistant Professor of Physics
Cal Poly State University, San Luis Obispo
bgranger@calpoly.edu
ellisonbg@gmail.com


More information about the IPython-User mailing list