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在另一个节点-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。 >
答案 0 :(得分:1)
您可能希望查看Client.upload_file
方法。
client.upload_file('/path/to/file1.py')
对于任何较大的依赖项,尽管通常希望您自己处理依赖项。在较大的部署中,人们通常依赖其他一些机制(如Docker或网络文件系统)来确保统一的软件依赖性。