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

Public Member Functions

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

Public Attributes

 id
 
 name
 
 cmds
 
 hours
 
 nCores
 
 memMB
 
 env
 
 basedir
 
 dependsOnOk
 
 dependsOnAny
 

Detailed Description

Definition at line 14 of file sge_grace.py.

Member Function Documentation

◆ submit()

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

Definition at line 16 of file sge_grace.py.

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 

◆ 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.sge_grace.batchJob.id

Definition at line 66 of file sge_grace.py.

◆ memMB

sherpaTarCreator.batchJobBase.batchJobBase.memMB
inherited

Definition at line 13 of file batchJobBase.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
CaloCellPos2Ntuple.int
int
Definition: CaloCellPos2Ntuple.py:24
MuonGM::round
float round(const float toRound, const unsigned int decimals)
Definition: Mdt.cxx:27
submit
Definition: submit.py:1
sherpaTarCreator.sge_grace.getJobIDfromlastJob
def getJobIDfromlastJob()
Definition: sge_grace.py:5
python.ByteStreamConfig.write
def write
Definition: Event/ByteStreamCnvSvc/python/ByteStreamConfig.py:248
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