Quick response
Download the mod.py file to all your employees. You can do this using any mechanism that you used to configure dask.distributed, or you can use the upload_file method
e.upload_file('mod.py')
Alternatively, if your function is executed in IPython, and is not part of the module, it will be sent without problems.
Long answer
All this has to do with how functions are serialized in Python. Functions from modules are serialized by their module name and function name
In [1]: from math import sin In [2]: import pickle In [3]: pickle.dumps(sin) Out[3]: b'\x80\x03cmath\nsin\nq\x00.'
So, if the client computer wants to refer to the math.sin function, which it sends along with this byte (which you will notice, there is 'math' and 'sin' in it, hidden among other bytes) on the working computer. The employee looks at this byte message and says: “OK, the function I want is in such-and-such module, let me go and find it in my local file system. If the module is missing, then it will cause an error, like that, what you got above.
For dynamically created functions (functions that you create in IPython), it takes a completely different approach, combining all the code. This approach usually works great.
Generally speaking, Dask assumes that the workers and the client have the same software environment. Usually this is mainly handled by those who are setting up your cluster using some other tool like Docker. Methods like upload_file should fill in the blanks if you have files or scripts that are updated more often.
source share