ATLAS Offline Software
Loading...
Searching...
No Matches
slurm_sdf.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:
18 self.memMB = 1970
19 elif self.memMB == 2499:
20 self.memMB = 2583
21 cpt = 2
22 cmd = "sbatch --partition=\"usatlas\" --account=\"usatlas\" --kill-on-invalid-dep=yes -e "+self.basedir+"/"+self.name+".log -o "+self.basedir+"/"+self.name+".log --time=96:00:00 --mem-per-cpu="+str(self.memMB)+" --cpus-per-task="+str(cpt)+" -N 1 --ntasks "+str(self.nCores)
23 if os.environ.get('SLURM_MAIL_USER'):
24 cmd += " --mail-type='END,FAIL,TIME_LIMIT' --mail-user='"+os.environ.get('SLURM_MAIL_USER')+"'"
25
26 if len(self.dependsOnOk)>0 or len(self.dependsOnAny)>0:
27 cmd += " -d "
28 if len(self.dependsOnOk)>0:
29 okdeps = "afterok:"+",afterok:".join(self.dependsOnOk)
30 cmd += okdeps+","
31 if len(self.dependsOnAny)>0:
32 anydeps = "afterany:"+",afterany:".join(self.dependsOnAny)
33 cmd += anydeps+","
34 cmd = cmd[:-1]
35
36 if "ecm" in self.basedir:
37 jobname = os.path.relpath(self.basedir+"/"+self.name+".log", self.basedir+"/../..")
38 else:
39 jobname = os.path.relpath(self.basedir+"/"+self.name+".log", self.basedir+"/..")
40 cmd += " -J "+jobname+" "+self.basedir+"/"+self.name+".sh >> qsub.log \n"
41
42 if dryRun:
43 print (cmd+"\n")
44 self.id = "-1"
45 else:
46 print(cmd+"\n")
47 p = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
48 retcode = p.communicate()
49 if len(retcode[0]):
50 print (retcode[0])
51 if len(retcode[1]):
52 print (retcode[1])
53 if p.returncode:
54 print ("ERROR: error while submitting job")
55 print ("return code: " + str(p.returncode))
56 sys.exit(11)
57
58 p.wait()
59
60 self.id = getJobIDfromlastJob()
61
62 print("Submitted "+str(self.id)+" ("+self.name+")")
63
64def finalizeJobs(dryRun):
65 return True
66
void print(char *figname, TCanvas *c1)
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177