【问题标题】:how to pass client side dependency to the dask-worker node如何将客户端依赖项传递给 dask-worker 节点
【发布时间】:2018-06-29 14:20:22
【问题描述】:

scriptA.py 内容:

import shlex, subprocess
from dask.distributed import Client

def my_task(params):
  print("params[1]", params[1]) ## prints python scriptB.py arg1 arg2
  child = subprocess.Popen(shlex.split(params[1]), shell=False)
  child.communicate()

if __name__ == '__main__':

    clienta = Client("192.168.1.3:8786")
    params=["dummy_arguments", "python scriptB.py arg1 arg2"]
    future = clienta.submit(my_task, params)
    print(future.result())

print("over.!")

scriptB.py 内容:

import file1, file2
from folder1 import file4
import time

for _ in range(3):
  file1.do_something();
  file4.try_something();
  print("sleeping for 1 sec")
  time.sleep(1)
print("waked up..")

scriptA.py 在 node-1(192.168.23.12:9784) 上运行,而 dask-worker 在另一个 node-2 (198.168.54.86:4658) 上运行,而 dask-scheduler 在不同的 node-3(198.168.1.3) 上:8786)。

这里的问题是如何将scriptB.py所需的依赖项,例如folder1,file1,file2等从运行在node-1上的scriptA.py传递给dask-worker node-2。?

【问题讨论】:

    标签: dask dask-distributed dask-delayed


    【解决方案1】:

    您可能想查看Client.upload_file 方法。

    client.upload_file('/path/to/file1.py')
    

    对于任何较大的依赖项,尽管通常希望您自己处理依赖项。在大型部署中,人们通常依赖其他一些机制(例如 Docker 或网络文件系统)来确保统一的软件依赖关系。

    【讨论】:

      猜你喜欢
      • 2011-12-02
      • 1970-01-01
      • 1970-01-01
      • 2019-07-26
      • 1970-01-01
      • 2016-10-08
      • 1970-01-01
      • 1970-01-01
      • 2015-01-02
      相关资源
      最近更新 更多