ATLAS Offline Software
Loading...
Searching...
No Matches
pbs_lcrc_improv.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
5from . import batchJobBase
6
8 last = None
9 with open("qsub.log") as f:
10 for line in f:
11 if line.strip():
12 last = line
13 if last is None:
14 raise ValueError("log is empty or only blank lines")
15 return last
16
18
19 def submit(self, dryRun=False):
20
21 cmd = "qsub -j oe -o "+self.basedir+"/"+self.name+".log -l walltime="+str(self.hours)+":00:00,select=1:ncpus="+str(self.nCores)+" -A "+self.account+" -q "+self.queue
22
23 if len(self.dependsOnOk)>0 or len(self.dependsOnAny)>0:
24 cmd += " -W depend="
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].rstrip()
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 jobname = jobname.replace('.','_').replace('/', '_')
38 cmd += " -N "+jobname+" "+self.basedir+"/"+self.name+".sh >> qsub.log \n"
39
40 if dryRun:
41 print (cmd)
42 self.id = "-1"
43 else:
44 print(cmd)
45 p = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
46 retcode = p.communicate()
47 if len(retcode[0]):
48 print (retcode[0])
49 if len(retcode[1]):
50 print (retcode[1])
51 if p.returncode:
52 print ("ERROR: error while submitting job")
53 print ("return code: " + str(p.returncode))
54 sys.exit(11)
55
56 p.wait()
57
58 self.id = getJobIDfromlastJob()
59
60 print("Submitted "+self.name+" with id: "+self.id+"\n\n")
61
62def finalizeJobs(dryRun):
63 return True
64
void print(char *figname, TCanvas *c1)
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:310