1 from __future__
import print_function
3 from RecoLuminosity.LumiDB
import csvSelectionParser,selectionParser,CommonUtil
7 if comps
and comps[0].lower()==
'run':
14 filelist=inputfilename.split(
'+')
26 inputfilecontent=selectf.read() 35 csvReader=csv.reader(ifile,delimiter=
',')
38 if hasHeader
and irow==0:
41 self.__inputResult.append(row)
54 csvReader=csv.reader(open(f),delimiter=
',')
60 if runnumber
not in result:
61 result[runnumber]=
None 72 selectedruns=self.
runs()
73 for r
in selectedruns:
74 if r
in runswithresult:
86 selectedruns=self.
runs()
87 for r
in selectedruns:
88 if r
not in runswithresult:
92 '''return the input selection file name 96 '''if empty input selection filename give, I assume you only need to merge pieces of output result files into one 103 output [headerfields] 113 given the input result field name and typem return the list of values 118 fieldidx=self.__inputResultHeader.index(fieldname)
120 print(
'field ',fieldname,
' not found')
121 raise RuntimeError(
'field')
123 stringvalue=r[fieldidx]
124 if fieldtype
in [
'int',
'unsigned int']:
126 print(
'field ',fieldname,
' is not integer type')
127 raise RuntimeError(
'field')
129 result.append(
int(stringvalue))
131 elif fieldtype
in [
'float']:
133 print(
'field ',fieldname,
' is not float type')
134 raise RuntimeError(
'field')
136 result.append(
float(stringvalue))
138 elif fieldtype
in [
'string',
'str']:
139 result.append(stringvalue)
141 raise RuntimeError(
'unsupported type '+fieldtype)
145 given the input result field name and type, return the total 150 fieldidx=self.__inputResultHeader.index(fieldname)
152 print(
'field ',fieldname,
' not found')
155 stringvalue=r[fieldidx]
156 if fieldtype
in [
'int',
'unsigned int']:
158 print(
'field ',fieldname,
' is not integer type')
161 result=
int(result)+
int(stringvalue)
163 elif fieldtype
in [
'float'] :
165 print(
'field ',fieldname,
' is not float type')
171 raise RunTimeError(
'cannot sum types other than int ,float')
176 return self.__inputSelectionFileparsingResult.runs()
180 return self.__inputSelectionFileparsingResult.runsandls()
184 return self.__inputSelectionFileparsingResult.runsandlsStr()
186 if __name__ ==
'__main__':
188 filename=
'163664-v2-overview.csv+163665-v2-overview.csv+163668-v2-overview.csv+../json_DCSONLY.txt' 190 print(
'selection file ',p.selectionfilename())
191 print(
'old result files ',p.resultfiles())
194 print(
'do I only need to merge the results? ',p.mergeResultOnly())
195 resultheader=p.resultHeader()
197 print(p.runsWithresult())
198 print(
'selected runs with result ',p.selectedRunsWithresult())
199 print(
'selected runs without result ',p.selectedRunsWithoutresult())
201 alreadyprocessedRuns=p.fieldvalues(
'Run',
'int')
202 print(
'runs already have results ', alreadyprocessedRuns)
203 print(
'total delivered ',p.fieldtotal(
'Delivered(/ub)',
'float'))
204 print(
'total recorded ',p.fieldtotal(
'Recorded(/ub)',
'float'))
205 print(
'result header ',p.resultheader())
206 print(
'result lines ',p.resultlines())
S & print(S &os, JobReport::InputFile const &f)