ATLAS Offline Software
Functions
ELG_prun Namespace Reference

Functions

def ELG_prun (sample)
 

Function Documentation

◆ ELG_prun()

def ELG_prun.ELG_prun (   sample)

Definition at line 10 of file ELG_prun.py.

10 def ELG_prun(sample) :
11 
12  try:
13  from pandatools import PandaToolsPkgInfo # noqa: F401
14  except ImportError:
15  print ("prun needs additional setup, try:")
16  print (" lsetup panda")
17  return 99
18 
19  cmd = ["prun"]
20 
21  #These are options that can be set by the user
22  opts = ['destSE',
23  'site',
24  'rootVer',
25  'cmtConfig',
26  'excludedSite',
27  'nGBPerJob',
28  'memory',
29  'maxCpuCount',
30  'nFiles',
31  'nFilesPerJob',
32  'nEventsPerJob',
33  'nJobs',
34  'maxFileSize',
35  'maxNFilesPerJob',
36  'addNthFieldOfInDSToLFN',
37  'cpuTimePerEvent',
38  'maxWalltime',
39  'voms',
40  'workingGroup',
41  'tmpDir']
42 
43  #These are options that can be set by the user
44  switches = ['express',
45  'noSubmit',
46  'skipScout',
47  'disableAutoRetry',
48  'useNewCode',
49  'official',
50  'mergeOutput',
51  'useRootCore',
52  'useAthenaPackages',
53  'avoidVP']
54 
55  using_nEventsPerJob = False
56  from ROOT import SH
57  for opt in opts :
58  arg = sample.meta().castDouble('nc_' + opt, -1, SH.MetaObject.CAST_NOCAST_DEFAULT)
59  if abs(arg + 1) > 1e-6 :
60  cmd += ["--" + opt + "=" + str(int(round(arg)))]
61  if opt=="nEventsPerJob":
62  using_nEventsPerJob=True
63  else :
64  arg = sample.meta().castString('nc_' + opt)
65  if len(arg) :
66  cmd += ["--" + opt + "=" + arg]
67 
68  # nGBPerJob and nEventsPerJob are incompatible to prun
69  if using_nEventsPerJob:
70  cmd = [ x for x in cmd if "nGBPerJob" not in x ]
71  print(cmd)
72 
73  for switch in switches :
74  arg = sample.meta().castDouble('nc_' + switch, 0, SH.MetaObject.CAST_NOCAST_DEFAULT)
75  if arg != 0 :
76  cmd += ["--" + switch]
77  else :
78  arg = sample.meta().castString('nc_' + switch)
79  if len(arg) :
80  if arg != "False" and arg != "false" and arg != "FALSE" :
81  cmd += ["--" + switch]
82 
83  #These options should normally not be touched by the user
84  internalOpts = ['exec',
85  'inDS',
86  'outDS',
87  'outputs',
88  'writeInputToTxt',
89  'match']
90 
91  for opt in internalOpts :
92  value = sample.meta().castString('nc_' + opt)
93  if opt == "exec" and using_nEventsPerJob:
94  value += " %SKIPEVENTS %MAXEVENTS"
95  cmd += ["--" + opt + "=" + value]
96 
97  if sample.meta().castDouble('nc_mergeOutput', 1, SH.MetaObject.CAST_NOCAST_DEFAULT) == 0 or sample.meta().castString('nc_mergeOutput').upper() == 'FALSE' :
98  #don't set merge script
99  pass
100  else :
101  cmd += ["--mergeScript=" + sample.meta().castString('nc_mergeScript')]
102 
103  if len(sample.meta().castString('nc_EventLoop_SubmitFlags')) :
104  cmd += shlex.split (sample.meta().castString('nc_EventLoop_SubmitFlags'))
105 
106  if sample.meta().castDouble('nc_showCmd', 0, SH.MetaObject.CAST_NOCAST_DEFAULT) != 0 :
107  print (cmd)
108 
109  if not os.path.isfile('jobcontents.tgz') :
110  import copy
111  dummycmd = copy.deepcopy(cmd)
112  dummycmd += ["--outTarBall=jobcontents.tgz"]
113  if len(sample.meta().castString('nc_EventLoop_UserFiles')) :
114  dummycmd += ["--extFile=jobdef.root,runjob.sh," + sample.meta().castString('nc_EventLoop_UserFiles').replace(" ",",")]
115  pass
116  else :
117  dummycmd += ["--extFile=jobdef.root,runjob.sh"]
118  pass
119  dummycmd += ["--noSubmit"]
120 
121  try:
122  out = subprocess.check_output(dummycmd, stderr=subprocess.STDOUT)
123  except subprocess.CalledProcessError as e:
124  print ("Command:")
125  print (e.cmd)
126  print ("failed with return code " , e.returncode)
127  print ("output was:")
128  print (e.output)
129  return 1
130 
131  cmd += ["--inTarBall=jobcontents.tgz"]
132 
133  out = ""
134  try:
135  out = subprocess.check_output(cmd, stderr=subprocess.STDOUT)
136  except subprocess.CalledProcessError as e:
137  print ("Command:")
138  print (e.cmd)
139  print ("failed with return code ", e.returncode)
140  print ("output was:")
141  print (e.output)
142  return 2
143 
144  jediTaskID = 0
145  try:
146  line = re.findall(r'TaskID=\d+', str(out))[0]
147  jediTaskID = int(re.findall(r'\d+', line)[0])
148  except IndexError:
149  print (out)
150  return 3
151 
152  return jediTaskID
ELG_prun.ELG_prun
def ELG_prun(sample)
Definition: ELG_prun.py:10
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
upper
int upper(int c)
Definition: LArBadChannelParser.cxx:49
str
Definition: BTagTrackIpAccessor.cxx:11
dbg::print
void print(std::FILE *stream, std::format_string< Args... > fmt, Args &&... args)
Definition: SGImplSvc.cxx:70