从客户端接口停止dask ssh创建的计划程序

从客户端接口停止dask ssh创建的计划程序,dask,Dask,我正在SLURM管理的群集上运行Dask dask-ssh --nprocs 2 --nthreads 1 --scheduler-port 8786 --log-directory `pwd` --hostfile hostfile.$JOBID & sleep 10 # We need to tell dask Client (inside python) where the scheduler is running scheduler="`hostname`:8786" echo

我正在SLURM管理的群集上运行Dask

dask-ssh --nprocs 2 --nthreads 1 --scheduler-port 8786 --log-directory `pwd` --hostfile hostfile.$JOBID &
sleep 10

# We need to tell dask Client (inside python) where the scheduler is running
scheduler="`hostname`:8786"
echo "Scheduler is running at ${scheduler}"
export ARL_DASK_SCHEDULER=${scheduler}

echo "About to execute $CMD"

eval $CMD

# Wait for dash-ssh to be shutdown from the python
wait %1
我在python代码中创建了一个客户机,然后在完成后将其关闭

c=Client(scheduler_id)
...
c.shutdown()
我对dask ssh帮助的理解是,关闭将关闭所有工作进程,然后关闭调度程序。但它不会停止后台dask ssh,因此最终会导致作业超时

我已经在shell中以交互方式尝试过了。我看不出如何停止调度程序

我将感谢任何帮助

谢谢, Tim

建议使用--scheduler文件

首先,当使用SLURM设置时,您可以考虑使用<代码>调度程序文件< /Cord>选项,它允许您使用NFS(我假定您已经使用SLURM)来协调调度器地址。建议阅读本文档部分:

因此,直接使用sbatch或qsub命令也变得更容易。以下是SGE的qsub示例

# Start a dask-scheduler somewhere and write connection information to file
qsub -b y /path/to/dask-scheduler --scheduler-file /path/to/scheduler.json

# Start 100 dask-worker processes in an array job pointing to the same file
qsub -b y -t 1-100 /path/to/dask-worker --scheduler-file /path/to/scheduler.json
客户端关闭 看起来client.shutdown只会关闭客户端。这与docstring不一致是正确的。我在这里提出了一个问题:跟踪进一步的发展

同时 这三个命令应该足以中断工作进程、关闭调度程序和停止调度程序进程

client.loop.add_callback(client.scheduler.retire_workers, close_workers=True)
client.loop.add_callback(client.scheduler.terminate)
client.run_on_scheduler(lambda dask_scheduler: dask_scheduler.loop.stop())
人们通常做什么
通常情况下,人们启动和停止集群的方式是什么。这可能涉及使用SLURM的kill命令。无论如何,我们应该使以客户为中心的方式更加一致

谢谢你的及时答复。该解决方案确实有效,并且比我使用psutil发送消息要好。现在我的测试还为时过早,所以我可能会花时间以更智能的方式驾驶slurm。顺便说一句,Dask给我留下了深刻的印象。我正在利用延迟创建用于相当复杂射电天文处理的图表。很高兴听到@TimCornwell。该项目目前需要人们写下他们的经历。如果你愿意的话,公开记录dask.delayed的非玩具用途真的很有价值。是的,我想是的。我会和我这边的负责人核实一下,“同时”解决方案对我来说是失败的。第三行从distributed.core的内部抛出一个
CommClosedError
,调度程序仍在运行。这个解决方案不再有效吗?
client.loop.add_callback(client.scheduler.retire_workers, close_workers=True)
client.loop.add_callback(client.scheduler.terminate)
client.run_on_scheduler(lambda dask_scheduler: dask_scheduler.loop.stop())