ATLAS Offline Software
slurm_sdf.py
Go to the documentation of this file.
1 # Copyright (C) 2002-2024 CERN for the benefit of the ATLAS collaboration
2 
3 import 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 
11 from . 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 
64 def finalizeJobs(dryRun):
65  return True
66 
sherpaTarCreator.batchJobBase.batchJobBase.name
name
Definition: batchJobBase.py:9
sherpaTarCreator.batchJobBase.batchJobBase.memMB
memMB
Definition: batchJobBase.py:13
sherpaTarCreator.slurm_sdf.getJobIDfromlastJob
def getJobIDfromlastJob()
Definition: slurm_sdf.py:5
sherpaTarCreator.slurm_sdf.batchJob.submit
def submit(self, dryRun=False)
Definition: slurm_sdf.py:15
sherpaTarCreator.batchJobBase.batchJobBase.basedir
basedir
Definition: batchJobBase.py:19
sherpaTarCreator.batchJobBase.batchJobBase.id
id
Definition: batchJobBase.py:20
sherpaTarCreator.slurm_sdf.finalizeJobs
def finalizeJobs(dryRun)
Definition: slurm_sdf.py:64
sherpaTarCreator.batchJobBase.batchJobBase
Definition: batchJobBase.py:5
sherpaTarCreator.batchJobBase.batchJobBase.nCores
nCores
Definition: batchJobBase.py:12
print
void print(char *figname, TCanvas *c1)
Definition: TRTCalib_StrawStatusPlots.cxx:25
sherpaTarCreator.batchJobBase.batchJobBase.dependsOnOk
dependsOnOk
Definition: batchJobBase.py:21
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
sherpaTarCreator.slurm_sdf.batchJob
Definition: slurm_sdf.py:13
Trk::open
@ open
Definition: BinningType.h:40
sherpaTarCreator.batchJobBase.batchJobBase.dependsOnAny
dependsOnAny
Definition: batchJobBase.py:22
str
Definition: BTagTrackIpAccessor.cxx:11
Trk::split
@ split
Definition: LayerMaterialProperties.h:38