File size: 799 Bytes
697fc54 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 |
"""Module for submitting jobs"""
import subprocess
def submit_slurm(
cmd: str,
time: str,
partition: str,
nodes: int,
ntasks_per_node: int,
job_name: str,
account: str,
**kwargs,
):
"""Submit a job to the slurm scheduler."""
scmd = [
*f"""sbatch
--time={time}
--account={account}
--qos={partition}
--job-name={job_name}
--output=%x-%j.out
--error=%x-%j.err
--nodes={nodes}
--ntasks-per-node={ntasks_per_node}""".replace("'", "").split(),
]
if kwargs.get("constraint", False):
scmd += [f"--constraint={kwargs['constraint']}"]
if kwargs.get("exclude", False):
scmd += ["--exclude"]
scmd += ["--wrap", cmd]
return subprocess.run(scmd, check=True)
|