Can I use functions imported from .py files in Dask/Distributed? : <p>I have a question about serialization and imports. </p>

<ul>
<li>should functions have their own imports? <a href="https://docs.continuum.io/anaconda-scale/howto/spark-basic#modify-std-script" rel="noreferrer">like I've seen done with PySpark</a></li>
<li>Is the following just plain wrong? Does <code>mod.py</code> need to be a conda/pip package? <code>mod.py</code> was written to a shared filesystem.</li>
</ul>

<p></p>

<pre><code>In [1]: from distributed import Executor

In [2]: e = Executor('127.0.0.1:8786')

In [3]: e
Out[3]: &lt;Executor: scheduler="127.0.0.1:8786" processes=2 cores=2&gt;

In [4]: import socket

In [5]: e.run(socket.gethostname)
Out[5]: {'172.20.12.7:53405': 'n1015', '172.20.12.8:53779': 'n1016'}

In [6]: %%file mod.py
   ...: def hostname():
   ...:     return 'the hostname'
   ...: 
Overwriting mod.py

In [7]: import mod

In [8]: mod.hostname()
Out[8]: 'the hostname'

In [9]: e.run(mod.hostname)
distributed.utils - ERROR - No module named 'mod'
</code></pre>
