ATLAS Offline Software
Generators
Sherpa_i
python
sherpaTarCreator
sge_grace.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
5
def
getJobIDfromlastJob
():
6
for
line
in
open
(
"qsub.log"
):
7
pass
8
parts = line.split(
" "
)
9
jobid = parts[2].
split
(
'.'
)[0]
if
'array'
in
line
else
parts[2]
10
return
jobid
11
12
from
.
import
batchJobBase
13
14
class
batchJob
(
batchJobBase.batchJobBase
):
15
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
86
def
finalizeJobs
(dryRun):
87
return
True
sherpaTarCreator.batchJobBase.batchJobBase.name
name
Definition:
batchJobBase.py:9
CaloCellPos2Ntuple.int
int
Definition:
CaloCellPos2Ntuple.py:24
sherpaTarCreator.batchJobBase.batchJobBase.memMB
memMB
Definition:
batchJobBase.py:13
sherpaTarCreator.batchJobBase.batchJobBase.basedir
basedir
Definition:
batchJobBase.py:19
MuonGM::round
float round(const float toRound, const unsigned int decimals)
Definition:
Mdt.cxx:27
sherpaTarCreator.batchJobBase.batchJobBase.id
id
Definition:
batchJobBase.py:20
sherpaTarCreator.sge_grace.batchJob.submit
def submit(self, dryRun=False)
Definition:
sge_grace.py:16
sherpaTarCreator.sge_grace.getJobIDfromlastJob
def getJobIDfromlastJob()
Definition:
sge_grace.py:5
sherpaTarCreator.sge_grace.batchJob
Definition:
sge_grace.py:14
sherpaTarCreator.batchJobBase.batchJobBase
Definition:
batchJobBase.py:5
sherpaTarCreator.batchJobBase.batchJobBase.hours
hours
Definition:
batchJobBase.py:11
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
Trk::open
@ open
Definition:
BinningType.h:40
sherpaTarCreator.sge_grace.finalizeJobs
def finalizeJobs(dryRun)
Definition:
sge_grace.py:86
sherpaTarCreator.batchJobBase.batchJobBase.dependsOnAny
dependsOnAny
Definition:
batchJobBase.py:22
str
Definition:
BTagTrackIpAccessor.cxx:11
Trk::split
@ split
Definition:
LayerMaterialProperties.h:38
Generated on Wed Jan 8 2025 21:17:02 for ATLAS Offline Software by
1.8.18