小编Alb*_*sco的帖子

我可以在Dask/Distributed中使用从.py文件导入的函数吗?

我有关于序列化和导入的问题.

  • 功能应该有自己的进口吗?就像我见过的PySpark一样
  • 以下是完全错误的吗?是否mod.py需要一个畅达/ PIP封装?mod.py被写入共享文件系统.

In [1]: from distributed import Executor

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

In [3]: e
Out[3]: <Executor: scheduler="127.0.0.1:8786" processes=2 cores=2>

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'
Run Code Online (Sandbox Code Playgroud)

python distributed-computing dask

10
推荐指数
1
解决办法
2645
查看次数

标签 统计

dask ×1

distributed-computing ×1

python ×1