ATLAS Offline Software
Public Member Functions | Public Attributes | List of all members
sherpaTarCreator.slurm_taurus.batchJob Class Reference
Inheritance diagram for sherpaTarCreator.slurm_taurus.batchJob:
Collaboration diagram for sherpaTarCreator.slurm_taurus.batchJob:

Public Member Functions

def submit (self, dryRun=False)
 
def write (self, useSingularity=True, extraDirs=[])
 

Public Attributes

 memMB
 
 id
 
 name
 
 cmds
 
 hours
 
 nCores
 
 env
 
 basedir
 
 dependsOnOk
 
 dependsOnAny
 

Detailed Description

Definition at line 13 of file slurm_taurus.py.

Member Function Documentation

◆ submit()

def sherpaTarCreator.slurm_taurus.batchJob.submit (   self,
  dryRun = False 
)

Definition at line 15 of file slurm_taurus.py.

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 

◆ write()

def sherpaTarCreator.batchJobBase.batchJobBase.write (   self,
  useSingularity = True,
  extraDirs = [] 
)
inherited

Definition at line 24 of file batchJobBase.py.

24  def write(self, useSingularity=True, extraDirs=[]):
25  executable = "#!/bin/sh -\n"
26 
27  # COMPILER_PATH
28  if useSingularity:
29  platform = str(os.environ['COMPILER_PATH']).split('/')[-1].replace('el9', 'almalinux9')
30  executable += 'if [ "$1" != "--really" ]; then \n'
31  executable += ' exec singularity exec -e --no-home'
32  for dir in ["/cvmfs", "/var", self.basedir, "$(pwd | cut -d '/' -f 1-2)"] + extraDirs:
33  executable += ' -B '+dir
34  executable += ' /cvmfs/atlas.cern.ch/repo/containers/fs/singularity/'
35  executable += platform + ' /bin/bash -- "$0" --really "$@";\n'
36  executable += 'fi\n'
37  executable += "shift;\n\n"
38  executable += "export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase\n"
39  executable += "source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh\n"
40 
41  executable += "ulimit -f 1000000;\n"
42  executable += "cd "+self.basedir+"\n\n"
43  executable += "echo 'ncores="+str(self.nCores)+" nhours="+str(self.hours)+" "+self.basedir+"/"+self.name+".sh';\n"
44  for cmd in self.cmds:
45  executable += cmd+"\n"
46  executable += "exit 0\n"
47 
48 
49  filename = self.basedir+"/"+self.name+".sh"
50  with open(filename, 'w') as f:
51  f.write(executable)
52 
53  #make shell-files executable
54  st = os.stat(filename)
55  os.chmod(filename, st.st_mode | stat.S_IEXEC)
56 
57 

Member Data Documentation

◆ basedir

sherpaTarCreator.batchJobBase.batchJobBase.basedir
inherited

Definition at line 19 of file batchJobBase.py.

◆ cmds

sherpaTarCreator.batchJobBase.batchJobBase.cmds
inherited

Definition at line 10 of file batchJobBase.py.

◆ dependsOnAny

sherpaTarCreator.batchJobBase.batchJobBase.dependsOnAny
inherited

Definition at line 22 of file batchJobBase.py.

◆ dependsOnOk

sherpaTarCreator.batchJobBase.batchJobBase.dependsOnOk
inherited

Definition at line 21 of file batchJobBase.py.

◆ env

sherpaTarCreator.batchJobBase.batchJobBase.env
inherited

Definition at line 18 of file batchJobBase.py.

◆ hours

sherpaTarCreator.batchJobBase.batchJobBase.hours
inherited

Definition at line 11 of file batchJobBase.py.

◆ id

sherpaTarCreator.slurm_taurus.batchJob.id

Definition at line 45 of file slurm_taurus.py.

◆ memMB

sherpaTarCreator.slurm_taurus.batchJob.memMB

Definition at line 17 of file slurm_taurus.py.

◆ name

sherpaTarCreator.batchJobBase.batchJobBase.name
inherited

Definition at line 9 of file batchJobBase.py.

◆ nCores

sherpaTarCreator.batchJobBase.batchJobBase.nCores
inherited

Definition at line 12 of file batchJobBase.py.


The documentation for this class was generated from the following file:
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition: hcg.cxx:307
submit
Definition: submit.py:1
python.ByteStreamConfig.write
def write
Definition: Event/ByteStreamCnvSvc/python/ByteStreamConfig.py:248
sherpaTarCreator.slurm_taurus.getJobIDfromlastJob
def getJobIDfromlastJob()
Definition: slurm_taurus.py:5
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
Trk::open
@ open
Definition: BinningType.h:40
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