ATLAS Offline Software
Loading...
Searching...
No Matches
sherpaTarCreator.slurm_sdf.batchJob Class Reference
Inheritance diagram for sherpaTarCreator.slurm_sdf.batchJob:
Collaboration diagram for sherpaTarCreator.slurm_sdf.batchJob:

Public Member Functions

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

Public Attributes

 name = name
list cmds = []
 hours = hours
 nCores = nCores
 account = account
 queue = queue
int memMB = memMB
 mounts = mounts
dict env = {}
 basedir = basedir
 id = None
list dependsOnOk = []
list dependsOnAny = []

Detailed Description

Definition at line 13 of file slurm_sdf.py.

Member Function Documentation

◆ submit()

sherpaTarCreator.slurm_sdf.batchJob.submit ( self,
dryRun = False )

Definition at line 15 of file slurm_sdf.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 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
void print(char *figname, TCanvas *c1)

◆ write()

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

Definition at line 27 of file batchJobBase.py.

27 def write(self, useSingularity=True, useApptainer=False, extraDirs=[]):
28 executable = "#!/bin/sh -\n"
29
30 # COMPILER_PATH
31 if useSingularity:
32 platform = str(os.environ['COMPILER_PATH']).split('/')[-1].replace('el9', 'almalinux9')
33 executable += 'if [ "$1" != "--really" ]; then \n'
34 executable += ' exec singularity exec -e --no-home'
35 for dir in ["/cvmfs", "/var", self.basedir, "$(pwd | cut -d '/' -f 1-2)"] + extraDirs:
36 executable += ' -B '+dir
37 executable += ' /cvmfs/atlas.cern.ch/repo/containers/fs/singularity/'
38 executable += platform + ' /bin/bash -- "$0" --really "$@";\n'
39 executable += 'fi\n'
40 executable += "shift;\n\n"
41 executable += "export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase\n"
42 executable += "source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh\n"
43
44 if useApptainer:
45 wrapper = ''
46 wrapperfilename = self.basedir+"/"+self.name+"_wrapper.sh"
47 platform = str(os.environ['COMPILER_PATH']).split('/')[-1].replace('el9', 'almalinux9')
48 executable += 'export ALRB_CONT_SWTYPE="apptainer"\n'
49 executable += 'export ALRB_CONT_PRESETUP="hostname -f; date; id -a"\n'
50 executable += 'export ALRB_testPath=",,,,,,,,,,,,,,,,,,,,,,,,"\n'
51 executable += 'export ALRB_CONT_RUNPAYLOAD="'+wrapperfilename+'"\n'
52 wrapper += "ulimit -f 1000000;\n"
53 wrapper += "cd "+self.basedir+";\n\n"
54 wrapper += "echo 'ncores="+str(self.nCores)+" nhours="+str(self.hours)+" "+self.basedir+"/"+self.name+".sh';\n"
55 for cmd in self.cmds:
56 wrapper += cmd+'\n'
57 with open(wrapperfilename, 'w') as f:
58 f.write(wrapper)
59 st = os.stat(wrapperfilename)
60 os.chmod(wrapperfilename, st.st_mode | stat.S_IEXEC)
61 executable += "export ATLAS_LOCAL_ROOT_BASE=/cvmfs/atlas.cern.ch/repo/ATLASLocalRootBase\n"
62 executable += "source ${ATLAS_LOCAL_ROOT_BASE}/user/atlasLocalSetup.sh -c "+platform+" -b -q"
63 if self.mounts != []:
64 executable += "-m"+" ".join(self.mounts)
65 else:
66 executable += "\n"
67 executable += "exit $?\n"
68
69 else:
70 executable += "ulimit -f 1000000;\n"
71 executable += "cd "+self.basedir+"\n\n"
72 executable += "echo 'ncores="+str(self.nCores)+" nhours="+str(self.hours)+" "+self.basedir+"/"+self.name+".sh';\n"
73 for cmd in self.cmds:
74 executable += cmd+"\n"
75 executable += "exit 0\n"
76
77 filename = self.basedir+"/"+self.name+".sh"
78 with open(filename, 'w') as f:
79 f.write(executable)
80
81 #make shell-files executable
82 st = os.stat(filename)
83 os.chmod(filename, st.st_mode | stat.S_IEXEC)
84
85
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:310
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177

Member Data Documentation

◆ account

sherpaTarCreator.batchJobBase.batchJobBase.account = account
inherited

Definition at line 13 of file batchJobBase.py.

◆ basedir

sherpaTarCreator.batchJobBase.batchJobBase.basedir = basedir
inherited

Definition at line 22 of file batchJobBase.py.

◆ cmds

list sherpaTarCreator.batchJobBase.batchJobBase.cmds = []
inherited

Definition at line 10 of file batchJobBase.py.

◆ dependsOnAny

list sherpaTarCreator.batchJobBase.batchJobBase.dependsOnAny = []
inherited

Definition at line 25 of file batchJobBase.py.

◆ dependsOnOk

list sherpaTarCreator.batchJobBase.batchJobBase.dependsOnOk = []
inherited

Definition at line 24 of file batchJobBase.py.

◆ env

dict sherpaTarCreator.batchJobBase.batchJobBase.env = {}
inherited

Definition at line 21 of file batchJobBase.py.

◆ hours

sherpaTarCreator.batchJobBase.batchJobBase.hours = hours
inherited

Definition at line 11 of file batchJobBase.py.

◆ id

sherpaTarCreator.batchJobBase.batchJobBase.id = None
inherited

Definition at line 23 of file batchJobBase.py.

◆ memMB

int sherpaTarCreator.batchJobBase.batchJobBase.memMB = memMB
inherited

Definition at line 15 of file batchJobBase.py.

◆ mounts

sherpaTarCreator.batchJobBase.batchJobBase.mounts = mounts
inherited

Definition at line 16 of file batchJobBase.py.

◆ name

sherpaTarCreator.batchJobBase.batchJobBase.name = name
inherited

Definition at line 9 of file batchJobBase.py.

◆ nCores

sherpaTarCreator.batchJobBase.batchJobBase.nCores = nCores
inherited

Definition at line 12 of file batchJobBase.py.

◆ queue

sherpaTarCreator.batchJobBase.batchJobBase.queue = queue
inherited

Definition at line 14 of file batchJobBase.py.


The documentation for this class was generated from the following file: