55import glob
66import subprocess
77import tabulate
8+ from fnmatch import fnmatch
89
910#: condorDir is the path to use for condor submission, user might want to change it -> edit ``mkPostProc.py``
1011condorDir = (
1112 "/" .join (os .path .abspath (os .path .dirname (__file__ )).split ("/" )[:- 1 ]) + "/condor"
1213)
1314
1415#: eosDir is the path to use for eos submission, user might want to change it -> edit ``mkPostProc.py``
15- eosDir = "/eos/cms/store/group/phys_smp/Latinos/vbfz/mkShapesRDF_nanoAOD"
16+ # eosDir = "/eos/cms/store/group/phys_smp/Latinos/vbfz/mkShapesRDF_nanoAOD" # just for tests
17+ eosDir = "/eos/cms/store/group/phys_higgs/cmshww/amassiro/HWWNano"
1618
1719#: defaultRedirector is the redirector used to access files if the option ``--useRedirector 1`` is used, user might want to change it -> edit ``mkPostProc.py``
1820defaultRedirector = "root://cms-xrd-global.cern.ch/"
@@ -133,6 +135,24 @@ def operationMode1Parser(parser=None):
133135 parser = argparse .ArgumentParser (add_help = False )
134136 parser1 = argparse .ArgumentParser (parents = [parser ])
135137
138+ parser1 .add_argument (
139+ "-T" ,
140+ "--selTree" ,
141+ type = str ,
142+ help = "List of samples to select, comma separated" ,
143+ required = False ,
144+ default = "" ,
145+ )
146+
147+ parser1 .add_argument (
148+ "-E" ,
149+ "--excTree" ,
150+ type = str ,
151+ help = "List of samples to exclude, comma separated" ,
152+ required = False ,
153+ default = "" ,
154+ )
155+
136156 parser1 .add_argument (
137157 "-r" ,
138158 "--resubmit" ,
@@ -162,7 +182,6 @@ def main():
162182 if opMode == 0 :
163183 parser0 = operationMode0Parser (parser )
164184 args = parser0 .parse_args ()
165-
166185 selTree = args .selTree
167186 excTree = args .excTree
168187
@@ -207,20 +226,53 @@ def main():
207226 parser1 = operationMode1Parser (parser )
208227 args = parser1 .parse_args ()
209228 resubmit = args .resubmit
229+
230+ selTree = args .selTree
231+ excTree = args .excTree
232+
233+ if selTree == "" :
234+ selTree = []
235+ else :
236+ selTree = [s .strip () for s in selTree .split ("," )]
237+
238+ if excTree == "" :
239+ excTree = []
240+ else :
241+ excTree = [s .strip () for s in excTree .split ("," )]
242+
210243 print ("Should check for errors" )
211244
212245 folder = condorDir + "/" + prodName + "/" + step + "/"
213246
214247 folder = os .path .abspath (folder )
248+ errs = []
249+ files = []
250+
251+ if len (selTree ) == 0 :
252+ errs .extend (glob .glob (f"{ folder } /*/err.txt" ))
253+ files .extend (glob .glob (f"{ folder } /*/script.py" ))
254+
255+ for tree in selTree :
256+ errs .extend (glob .glob (f"{ folder } /{ tree } __part*/err.txt" ))
257+ files .extend (glob .glob (f"{ folder } /{ tree } __part*/script.py" ))
215258
216- errs = glob .glob (f"{ folder } /*/err.txt" )
217- files = glob .glob (f"{ folder } /*/script.py" )
259+ for tree in excTree :
260+ errs = list (
261+ filter (
262+ lambda k : not fnmatch (k , f"{ folder } /{ tree } __part*/err.txt" ), errs
263+ )
264+ )
265+ files = list (
266+ filter (
267+ lambda k : not fnmatch (k , f"{ folder } /{ tree } __part*/script.py" ), files
268+ )
269+ )
218270
219271 errsD = list (map (lambda k : "/" .join (k .split ("/" )[:- 1 ]), errs ))
220272 filesD = list (map (lambda k : "/" .join (k .split ("/" )[:- 1 ]), files ))
221273 # print(files)
222274 notFinished = list (set (filesD ).difference (set (errsD )))
223- print (notFinished )
275+ print ("Waiting for \n " , " \n " . join ( notFinished ), sep = "" )
224276 tabulated = []
225277 tabulated .append (["Total jobs" , "Finished jobs" , "Running jobs" ])
226278 tabulated .append ([len (files ), len (errs ), len (notFinished )])
@@ -233,6 +285,11 @@ def main():
233285 Warning in <TClass::Init>: no dictionary for class edm::Hash<1> is available
234286 Warning in <TClass::Init>: no dictionary for class pair<edm::Hash<1>,edm::ParameterSetBlob> is available
235287 Warning in <TInterpreter::ReadRootmapFile>: class podio::
288+ TClass::Init:0: RuntimeWarning: no dictionary for class edm::Hash<1> is available
289+ TClass::Init:0: RuntimeWarning: no dictionary for class edm::ProcessHistory is available
290+ TClass::Init:0: RuntimeWarning: no dictionary for class edm::ProcessConfiguration is available
291+ TClass::Init:0: RuntimeWarning: no dictionary for class edm::ParameterSetBlob is available
292+ TClass::Init:0: RuntimeWarning: no dictionary for class pair<edm::Hash<1>,edm::ParameterSetBlob> is available
236293 real
237294 user
238295 sys
@@ -260,14 +317,15 @@ def normalErrsF(k):
260317 txt = lines .split ("\n " )
261318 # txt = list(filter(lambda k: k not in normalErrs, txt))
262319 txt = list (filter (lambda k : not normalErrsF (k ), txt ))
263- txt = list (filter (lambda k : k . strip () != "" , txt ))
320+ txt = list (filter (lambda k : k != "" , txt ))
264321 if len (txt ) > 0 :
265322 print ("Found unusual error in" )
266323 print (err )
267- print ("\n " )
268- # print("\n".join(txt))
324+ print ("\n First 5 lines of error file: " )
325+ print ("\n " .join (txt [: 5 ] ))
269326 print ("\n \n " )
270327 toResubmit .append (err )
328+
271329 toResubmit = list (map (lambda k : "" .join (k .split ("/" )[- 2 ]), toResubmit ))
272330 print (toResubmit )
273331 if len (toResubmit ) > 0 :
0 commit comments