Page MenuHomec4science

pbsCoat.py
No OneTemporary

File Metadata

Created
Thu, Aug 15, 20:20

pbsCoat.py

#!/usr/bin/env python
import run
import os,stat
import subprocess
import re
import socket
admissible_params = {"walltime":str,"email":str,"nproc":int,"pbs_option":[str]}
default_params = {"walltime":"48:00:00"}
help = {"walltime":"Specify the wall time for the runs",
"email":"Specify the email to notify",
"nproc":"Force the number of processors and update the run",
"pbs_option":"Allow to provide additional PBS options"}
def launch(run,params):
_exec = run.getExecFile()
head = \
"""#!/bin/bash
#PBS -l walltime={0}
""".format(params["walltime"])
if ("email" in params):
head += "#PBS -m abe"
head += "#PBS -M {0}\n".format(params["email"])
pbs_head_name = "#PBS -N " + "run" + str(run.id) + "\n"
head += pbs_head_name
run["state"] = "PBS submit"
if ("nproc" in params):
run["nproc"] = params["nproc"]
nproc = run["nproc"]
head += "#PBS -l nodes=" + str(nproc) + "\n"
if ("pbs_option" in params):
for i in params["pbs_option"]:
head += "#PBS {0}\n".format(i)
run.update()
head += """
on_kill()
{
updateRuns.py --study=$SCHEMA --host=$HOST --run_constraints \"id = $RUN_ID\" --updates \"state = PBS killed\" --truerun
exit 0
}
on_stop()
{
updateRuns.py --study=$SCHEMA --host=$HOST --run_constraints \"id = $RUN_ID\" --updates \"state = PBS stopped\" --truerun
exit 0
}
# Execute function on_die() receiving TERM signal
#
trap on_stop SIGUSR1
trap on_kill SIGUSR2
"""
if (socket.gethostname() == "lsmscluster1"):
head += "module load libqview\n"
head += "module load mpi/openmpi/openmpi-generic"
_exec["file"] = head + _exec["file"]
f = open(_exec["filename"], 'w')
f.write(_exec["file"])
f.close()
# os.chmod(_exec["filename"], stat.S_IRWXU)
print ("execute qsub ./" + _exec["filename"])
print ("in dir ")
subprocess.call("pwd")
if (params["truerun"] == True):
ret = subprocess.call("qsub " + _exec["filename"],shell=True)

Event Timeline