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

William Shipman shipman.william at gmail.com
Tue Aug 12 12:43:11 EDT 2014


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.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/ipython-dev/attachments/20140812/dcbecf00/attachment.html>


More information about the IPython-dev mailing list