[IPython-dev] Fwd: Using DirectView.execute to import modules on worker processes

Thomas Kluyver takowl at gmail.com
Tue Aug 12 12:47:20 EDT 2014


Hi William,

I don't think there should be any problem with using DirectView.execute()
for this. Min, who's the expert on IPython.parallel, is away at the moment,
but he should be able to give you a proper answer when he gets back in a
couple of days.

Thanks,
Thomas


On 12 August 2014 09:43, William Shipman <shipman.william at gmail.com> wrote:

> I have looked through the documentation about importing modules on IPython
> Parallel worker processes, and it seems imports of the form "import foo as
> bar" are not supported.  However, I found that using DirectView.execute
> allows me to get around this.  Is this safe, if not what can go wrong?
>
> Here's the code I'm using to import part of the dateutil library and :
>
>     from IPython.parallel import Client
>     ipython_client = Client()
>     dview = ipython_client.direct_view()
>     dview.execute('from dateutil import parser as dtparser')
>
> I am only using on my local PC, not a cluster.  After executing the above
> I can happily run code that uses dtparser using dview.map_sync.  I can
> rewrite my code to avoid doing this but I'd like to know why I shouldn't
> use this method.
>
> Thanks in advance.
>
> P.S. I posted this to IPython-User but that mailing list seems not to be
> active.  I anyone is receiving this for a second time, I apologize.
>
> _______________________________________________
> IPython-dev mailing list
> IPython-dev at scipy.org
> http://mail.scipy.org/mailman/listinfo/ipython-dev
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140812/ed34af03/attachment.html>


More information about the IPython-dev mailing list