ATLAS Offline Software
Loading...
Searching...
No Matches
slurm_barnard.py
Go to the documentation of this file.
1# Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2
3import subprocess,sys,os
4
6 for line in open("qsub.log"):
7 pass
8 parts = line.split(" ")
9 return parts[3].split("\n")[0]
10
11from . import batchJobBase
12
14
15 def submit(self, dryRun=False):
16 cpt = 1
17 if self.memMB == 1499 or self.memMB == 2499:
18 self.memMB = 4800
19 cmd = "sbatch -e "+self.basedir+"/"+self.name+".log -o "+self.basedir+"/"+self.name+".log --time="+str(self.hours)+":00:00 --mem-per-cpu="+str(self.memMB)+" -p barnard --cpus-per-task="+str(cpt)+" -N 1 --ntasks "+str(self.nCores)
20 if os.environ.get('SLURM_MAIL_USER'):
21 cmd += " --mail-type='END,FAIL,TIME_LIMIT' --mail-user='"+os.environ.get('SLURM_MAIL_USER')+"'"
22
23 if len(self.dependsOnOk)>0 or len(self.dependsOnAny)>0:
24 cmd += " -d "
25 if len(self.dependsOnOk)>0:
26 okdeps = "afterok:"+",afterok:".join(self.dependsOnOk)
27 cmd += okdeps+","
28 if len(self.dependsOnAny)>0:
29 anydeps = "afterany:"+",afterany:".join(self.dependsOnAny)
30 cmd += anydeps+","
31 cmd = cmd[:-1]
32
33 if "ecm" in self.basedir:
34 jobname = os.path.relpath(self.basedir+"/"+self.name+".log", self.basedir+"/../..")
35 else:
36 jobname = os.path.relpath(self.basedir+"/"+self.name+".log", self.basedir+"/..")
37 cmd += " -J "+jobname+" "+self.basedir+"/"+self.name+".sh >> qsub.log \n"
38
39 if dryRun:
40 print (cmd)
41 self.id = "-1"
42 else:
43 print(cmd)
44 p = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
45 retcode = p.communicate()
46 if len(retcode[0]):
47 print (retcode[0])
48 if len(retcode[1]):
49 print (retcode[1])
50 if p.returncode:
51 print ("ERROR: error while submitting job")
52 print ("return code: " + str(p.returncode))
53 sys.exit(11)
54
55 p.wait()
56
57 self.id = getJobIDfromlastJob()
58
59 print("Submitted "+str(self.id)+" ("+self.name+")\n\n")
60
61def finalizeJobs(dryRun):
62 return True
63
void print(char *figname, TCanvas *c1)
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177