简体   繁体   English

使用Python子进程运行SLURM脚本以将多个长作业提交到队列中,并在继续python脚本之前等待作业完成

[英]Using Python subprocess to run SLURM script to submit multiple long jobs to queue and waiting for jobs to finish before continuing python script

Basics of the situation are that I'm using Python's subprocess module to run a SLURM script which submits a number of jobs to a queue on some HPC resources that I use. 这种情况的基本原理是,我正在使用Python的subprocess进程模块运行SLURM脚本,该脚本将许多作业提交到我使用的某些HPC资源上的队列中。 I would like the Python script to wait until all the jobs submitted are finished. 我希望Python脚本等待所有提交的作业完成。 I tried doing this with: 我尝试这样做:

proc = subprocess.Popen(['sbatch slurm.sh'],shell=True)
proc.wait()

However, it only waits for the jobs to be submitted and not for all the jobs to finish. 但是,它仅等待作业提交,而不等待所有作业完成。 Anyone have any suggestions for how to make this work? 有人对如何进行这项工作有任何建议吗?

Note: One idea I had was potentially having subprocess communicate somehow with the .out file produced by the SLURM script (and wait for that to finish being edited maybe?), but I'm not sure how that would work. 注意:我曾经有一个想法可能是让子进程以某种方式与SLURM脚本生成的.out文件进行通信(并等待它完成编辑工作?),但是我不确定这将如何工作。

Thanks for any ideas! 感谢您的任何想法!

Use a python library to interface with Slurm, such as 使用python库与Slurm交互,例如

and you will be able to manage the slurm jobs in a very easy way. 并且您将能够以非常简单的方式来管理slurm作业。

I have recently worked on slurm and have used -W or --wait parameter of sbatch to make the sbatch command first complete its execution and then execute the python code. 我最近研究了slurm,并使用sbatch的-W或--wait参数使sbatch命令首先完成其执行,然后执行python代码。 Something like this sbatch -W slurm.sh 像这样的sbatch -W slurm.sh

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM