2 from __future__
import print_function
4 import shutil, re, sys, os
5 from typing
import List, Tuple, Callable
7 from .dqu_subprocess
import apply
as _local_apply
11 rf = ROOT.TFile.Open(fname,
'READ')
12 if not rf
or not rf.IsOpen():
13 print(
' %s is empty or not accessible' % fname)
16 cleancache = ROOT.gROOT.MustClean(); ROOT.gROOT.SetMustClean(
False)
19 ROOT.gROOT.SetMustClean(cleancache)
24 resultdir = dir.Get(
'Results'); statusobj =
None
27 statusobj = resultdir.Get(
'Status')
30 l = statusobj.GetListOfKeys()
33 keys = dir.GetListOfKeys()
36 if ROOT.TClass.GetClass(key.GetClassName()).InheritsFrom(
'TDirectory'):
37 dirobj = key.ReadObj()
38 resultdir = dirobj.Get(
'Results'); statusobj =
None
40 statusobj = resultdir.Get(
'Status')
43 if name[-1] ==
'_' and resultdir:
45 subkeys = resultdir.GetListOfKeys()
46 for subkey
in subkeys:
47 ressub = subkey.GetName()
48 if ressub
not in (
'Status',
'Reference',
'ResultObject')
and ROOT.TClass.GetClass(subkey.GetClassName()).InheritsFrom(
'TDirectory'):
49 l = subkey.ReadObj().GetListOfKeys()
53 l = statusobj.GetListOfKeys()
60 isProduction =
bool(os.environ.get(
'DQPRODUCTION',
False))
61 func, mail_to = funcinfo
62 tmpfilename = outFileName +
"-safe-" +
str(os.getpid())
63 shutil.copy2(outFileName, tmpfilename)
67 currDir=
" pwd failed!"
69 currDir=os.environ[
"PWD"]
71 for files
in os.listdir(currDir):
72 if re.match(
r'^[0-9]*_.*.log$',files):
73 logFilesList.append(
"%s"%files)
74 logFiles=
'\r\n'.
join(logFilesList)
78 _local_apply(func, (tmpfilename, isIncremental))
79 _local_apply(_dolsrwrapper, (tmpfilename,))
81 except Exception
as e:
82 print(
'WARNING!!!: POSTPROCESSING FAILED FOR', func.__name__)
84 print(
'Relevant results will not be in output')
87 server = smtplib.SMTP(
'localhost')
88 mail_cc = [
'ponyisi@utexas.edu',
'rnarayan@utexas.edu']
89 msg = [
'From: atlasdqm@cern.ch',
90 'To: %s' %
', '.
join(mail_to),
91 'Cc: %s' %
', '.
join(mail_cc),
92 'Reply-to: atlasdqm-no-reply@cern.ch',
93 'Subject: WARNING: Postprocessing failure in production job',
95 'There has been a failure in Tier-0 postprocessing monitoring.',
97 'Function: %s' % func.__name__,
98 'File: %s' % outFileName,
99 'isIncremental? %s' % isIncremental,
102 'Current directory (contains LSF job ID): %s' % currDir,
103 'Log file name (contains ATLAS T0 job ID): %s' % logFiles
106 server.sendmail(
'atlasdqm@cern.ch', mail_to + mail_cc,
'\r\n'.
join(msg))
111 shutil.move(tmpfilename, outFileName)
113 os.unlink(tmpfilename)
118 f = ROOT.TFile.Open(fname)
119 lk = f.GetListOfKeys()
123 if not kn.startswith(
'run_'):
129 from ROOT
import gSystem
130 gSystem.Load(
'libDataQualityUtils')
131 from ROOT
import dqutils
136 from DataQualityUtils.createRpcFolders
import (createRPCDQMFDB,
137 createRPCConditionDB)
143 if not isIncremental:
144 from DataQualityUtils.createMdtFolders
import (createMDTConditionDBDead,
145 createMDTConditionDBNoisy)
149 def zlumi(fname, isIncremental):
150 if not isIncremental:
151 from DataQualityUtils.doZLumi
import go
154 def newstyle(yamlfile: str) -> Callable[[str, bool],
None]:
156 def newstyle_core(fname, isIncremental):
157 if not isIncremental:
159 print(f
'New style postprocessing running for: {yamlfile}')
160 cmdline = [
'histgrinder',
'--prefix', f
'/{rundir(fname)}/', fname, fname,
'-c', yamlfile]
161 subprocess.run(cmdline, check=
True)
162 newstyle_core.__name__ = os.path.splitext(os.path.basename(yamlfile))[0]
165 def make_newstyle_funcs() -> List[Tuple[Callable[[str, bool], None], List[str]]]:
168 from ._resolve_data_path
import resolve_data_path
171 print(
"Unable to resolve DataQualityUtils data path, not running new-style postprocessing")
174 inputs = glob.glob(os.path.join(dpath,
'postprocessing/*.yaml'))
176 rv.append((newstyle(input), [
'ponyisi@utexas.edu']))
180 (mf.fitMergedFile_IDPerfMonManager,
181 [
'weina.ji@cern.ch',
'ana.ovcharova@cern.ch']),
182 (mf.fitMergedFile_DiMuMonManager,
183 [
'ana.ovcharova@cern.ch']),
184 (mf.fitMergedFile_IDAlignMonManager,
185 [
'John.Alison@cern.ch',
'anthony.morley@cern.ch']),
186 (mf.pv_PrimaryVertexMonitoring_calcResoAndEfficiency,
187 [
'Andreas.Wildauer@cern.ch']),
189 [
'federico.meloni@cern.ch']),
191 [
'michele.bianco@le.infn.it',
'monica.verducci@cern.ch']),
193 [
'michele.bianco@le.infn.it',
'monica.verducci@cern.ch']),
195 [
'john.stakely.keller@cern.ch',
'monica.verducci@cern.ch']),
197 [
'lyuan@ihep.ac.cn',
'kingmgl@stu.kobe-u.ac.jp']),
198 (mf.MDTvsTGCPostProcess,
199 [
'lyuan@ihep.ac.cn',
'kingmgl@stu.kobe-u.ac.jp']),
200 (mf.HLTMuonPostProcess,
201 [
'lyuan@ihep.ac.cn',
'kingmgl@stu.kobe-u.ac.jp',
'yamazaki@phys.sci.kobe-u.ac.jp']),
202 (mf.HLTEgammaPostProcess,
203 [
'yan.jie.schnellbach@cern.ch',
'alessandro.tricoli@cern.ch']),
204 (mf.HLTTauPostProcess,
205 [
'Cristobal.Cuenca@cern.ch',
'Geng-Yuan.Jeng@cern.ch',
'Giovanna.Cottin@cern.ch']),
206 (mf.HLTMETPostProcess,
207 [
'venkat.kaushik@cern.ch']),
208 (mf.HLTCaloPostProcess,
209 [
'gareth.brown@cern.ch']),
210 (mf.HLTJetPostProcess,
211 [
'venkat.kaushik@cern.ch']),
212 (mf.BJetTaggingPostProcess,
213 [
'm.neumann@cern.ch']),
214 (mf.L1CaloPostProcess,
215 [
'ivana.hristova@cern.ch',
'pjwf@hep.ph.bham.ac.uk']),
216 (mf.PixelPostProcess,
217 [
'daiki.yamaguchi@cern.ch']),
218 (mf.MuonTrackPostProcess,
219 [
'baojia.tong@cern.ch',
'alexander.tuna@cern.ch']),
221 [
'ponyisi@utexas.edu']),
224 funclist += make_newstyle_funcs()
227 isTesting =
bool(os.environ.get(
'DQ_POSTPROCESS_ERROR_ON_FAILURE',
False))
230 def go_all(fname, isIncremental):
231 for funcinfo
in funclist:
232 funcinfo[0](fname, isIncremental)
240 for funcinfo
in funclist: