ATLAS Offline Software
slurm_taurus.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  #ram = 5250
21  self.memMB = 2583
22  cpt = 2
23  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 haswell,romeo --cpus-per-task="+str(cpt)+" -N 1 --ntasks "+str(self.nCores)
24  if os.environ.get('SLURM_MAIL_USER'):
25  cmd += " --mail-type='END,FAIL,TIME_LIMIT' --mail-user='"+os.environ.get('SLURM_MAIL_USER')+"'"
26 
27  if len(self.dependsOnOk)>0 or len(self.dependsOnAny)>0:
28  cmd += " -d "
29  if len(self.dependsOnOk)>0:
30  okdeps = "afterok:"+",afterok:".join(self.dependsOnOk)
31  cmd += okdeps+","
32  if len(self.dependsOnAny)>0:
33  anydeps = "afterany:"+",afterany:".join(self.dependsOnAny)
34  cmd += anydeps+","
35  cmd = cmd[:-1]
36 
37  if "ecm" in self.basedir:
38  jobname = os.path.relpath(self.basedir+"/"+self.name+".log", self.basedir+"/../..")
39  else:
40  jobname = os.path.relpath(self.basedir+"/"+self.name+".log", self.basedir+"/..")
41  cmd += " -J "+jobname+" "+self.basedir+"/"+self.name+".sh >> qsub.log \n"
42 
43  if dryRun:
44  print (cmd)
45  self.id = "-1"
46  else:
47  print(cmd)
48  p = subprocess.Popen(cmd,shell=True,stdout=subprocess.PIPE,stderr=subprocess.PIPE)
49  retcode = p.communicate()
50  if len(retcode[0]):
51  print (retcode[0])
52  if len(retcode[1]):
53  print (retcode[1])
54  if p.returncode:
55  print ("ERROR: error while submitting job")
56  print ("return code: " + str(p.returncode))
57  sys.exit(11)
58 
59  p.wait()
60 
61  self.id = getJobIDfromlastJob()
62 
63  print("Submitted "+str(self.id)+" ("+self.name+")\n\n")
64 
65 def finalizeJobs(dryRun):
66  return True
67 
sherpaTarCreator.batchJobBase.batchJobBase.name
name
Definition: batchJobBase.py:9
sherpaTarCreator.batchJobBase.batchJobBase.memMB
memMB
Definition: batchJobBase.py:13
sherpaTarCreator.batchJobBase.batchJobBase.basedir
basedir
Definition: batchJobBase.py:19
sherpaTarCreator.slurm_taurus.batchJob.submit
def submit(self, dryRun=False)
Definition: slurm_taurus.py:15
sherpaTarCreator.batchJobBase.batchJobBase.id
id
Definition: batchJobBase.py:20
sherpaTarCreator.batchJobBase.batchJobBase
Definition: batchJobBase.py:5
sherpaTarCreator.slurm_taurus.getJobIDfromlastJob
def getJobIDfromlastJob()
Definition: slurm_taurus.py:5
sherpaTarCreator.batchJobBase.batchJobBase.hours
hours
Definition: batchJobBase.py:11
sherpaTarCreator.batchJobBase.batchJobBase.nCores
nCores
Definition: batchJobBase.py:12
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_taurus.finalizeJobs
def finalizeJobs(dryRun)
Definition: slurm_taurus.py:65
Trk::open
@ open
Definition: BinningType.h:40
sherpaTarCreator.slurm_taurus.batchJob
Definition: slurm_taurus.py:13
sherpaTarCreator.batchJobBase.batchJobBase.dependsOnAny
dependsOnAny
Definition: batchJobBase.py:22
str
Definition: BTagTrackIpAccessor.cxx:11
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70
Trk::split
@ split
Definition: LayerMaterialProperties.h:38