使所有迟钝的工作人员都可以使用服务中的所有导入的最佳方法是什么? [英] What is the best approach to make all the imports with in the service available across all dask workers?

查看:63
本文介绍了使所有迟钝的工作人员都可以使用服务中的所有导入的最佳方法是什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对如何使Dask工人可以使用这些进口品有一些疑问.1)我看到使用upload_file功能可以使文件可供worker使用.除此之外,还有什么其他方法可以做到这一点?2)如果我们为所有导入都包含upload_file,那么对于后端中的每个服务调用,它将继续上传给工作人员吗?执行任务后,它会被删除吗?

I had a few questions around how to make the imports available across the Dask workers. 1) I see that using upload_file functionality you can make files available for workers . Other than this what are the other options to get this done? 2) If we include the upload_file for all the imports, For every service call in backend will it keep on uploading to workers ? will it get removed after the task is executed?

推荐答案

是的,有很多方法可以做到这一点,具体取决于您部署dask的方式.

Yes, there are lots of ways to do this, depending on how you are deploying dask.

几个例子:

  • 所有工作人员都可以访问NFS,因此请将您的代码文件放在此处,并将其包含在python路径中
  • 可通过SSH访问工作人员,因此请使用scp将代码复制到所有工作人员计算机上
  • 您正在通过docker/kubernetes进行部署,因此请在映像中包含代码
  • 您正在通过dask-yarn进行部署:查找 conda-pack

upload_file将代码放置在工作程序python路径上的临时位置.该文件将保留在那里,直到至少在工作进程结束时为止,在任务之间将不会重新上传该文件.它会由代码作为普通的python模块导入(即,再次导入将使用缓存的版本).在upload_file命令之后加入的新工作线程将没有该文件的副本.

upload_file puts the code into a temporary location which is on the worker's python path. The file will persist there until at least when the worker process ends, it will not be re-uploaded between tasks. It will be imported by the code as normal python modules (i.e., importing again will use the cached version). New workers that join after the upload_file command will not have a copy of the file.

这篇关于使所有迟钝的工作人员都可以使用服务中的所有导入的最佳方法是什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆