ATLAS Offline Software
Loading...
Searching...
No Matches
sge_grace.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 jobid = parts[2].split('.')[0] if 'array' in line else parts[2]
10 return jobid
11
12from . import batchJobBase
13
15
16 def submit(self, dryRun=False):
17
18 cmd = "qsub -e "+self.basedir+"/"+self.name+".log -o "+self.basedir+"/"+self.name+".log"
19
20 if len(self.dependsOnOk)>0 or len(self.dependsOnAny)>0:
21 cmd += " -hold_jid "
22 if len(self.dependsOnOk)>0:
23 #okdeps = "afterok:"+",afterok:".join(self.dependsOnOk)
24 #cmd += okdeps+","
25 cmd += str(self.dependsOnOk[-1])
26 if len(self.dependsOnAny)>0:
27 #anydeps = "afterany:"+",afterany:".join(self.dependsOnAny)
28 #cmd += anydeps+","
29 cmd += str(self.dependsOnAny[-1])
30
31 if "ecm" in self.basedir:
32 jobname = os.path.basename(os.path.normpath(self.basedir+"/../"))+"_"+self.name
33 else:
34 jobname = os.path.basename(os.path.normpath(self.basedir))+"_"+self.name
35 #cmd += " -J "+jobname+" "+self.basedir+"/"+self.name+".sh" # >> qsub.log \n"
36
37 user = os.environ.get('USER')
38 cmd += " >> qsub.log <<EOF \n"
39 cmd += "#!/bin/bash -l\n"
40 cmd += "set -e;\n"
41 cmd += "#$ -S /bin/bash\n"
42 cmd += "#$ -l h_rt=%i:0:0\n" % self.hours
43 cmd += "#$ -l mem=%iG\n" % int(round(0.001*self.memMB))
44 cmd += "#$ -N j%s\n" % jobname
45 cmd += "#$ -pe mpi %i\n" % self.nCores
46 cmd += "#$ -wd %s\n" % self.basedir
47 cmd += "cd %s;\n" % self.basedir
48 cmd += "ulimit -f 3000000;\n"
49 cmd += "export PARROT_CVMFS_ALIEN_CACHE=/lustre/scratch/scratch/%s/cvmfs_cache/\n" % user
50 cmd += 'export PARROT_CVMFS_REPO="<default-repositories> url=http://cvmfs-atlas-nightlies.cern.ch/cvmfs/atlas-nightlies.cern.ch"\n'
51 cmd += "module unload compilers mpi\n"
52 cmd += "module load compilers/gnu/4.9.2\n"
53 cmd += "module load cctools/7.0.11/gnu-4.9.2\n"
54 cmd += "module load mpi/openmpi/1.8.4/gnu-4.9.2\n"
55 cmd += "module load python/2.7.12\n"
56 cmd += "module load python2/recommended\n"
57 cmd += "module load scons/2.3.4\n"
58 cmd += "module load texinfo/6.6\n"
59 mpiwrap = 'gerun ' if self.nCores > 4 else ''
60 cmd += "(parrot_run bash -c \'"+mpiwrap+self.basedir+"/"+self.name+".sh\') >> "+self.basedir+"/"+self.name+".log;\n"
61 cmd += "exit 0;\n"
62 cmd += "EOF\n"
63
64 if dryRun:
65 print (cmd+"\n")
66 self.id = -1
67 else:
68 print (cmd)
69 p = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
70 retcode = p.communicate()
71 if len(retcode[0]):
72 print (retcode[0])
73 if len(retcode[1]):
74 print (retcode[1])
75 if p.returncode:
76 print ("ERROR: error while submitting job")
77 print ("return code: " + str(p.returncode))
78 sys.exit(11)
79
80 p.wait()
81 self.id = getJobIDfromlastJob()
82
83 print("Submitted "+str(self.id)+" ("+self.name+")")
84
85
86def finalizeJobs(dryRun):
87 return True
void print(char *figname, TCanvas *c1)
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177