3 import shutil, re, sys, os
4 from typing
import List, Tuple, Callable
6 from .dqu_subprocess
import apply
as _local_apply
10 rf = ROOT.TFile.Open(fname,
'READ')
11 if not rf
or not rf.IsOpen():
12 print(
' %s is empty or not accessible' % fname)
15 cleancache = ROOT.gROOT.MustClean(); ROOT.gROOT.SetMustClean(
False)
18 ROOT.gROOT.SetMustClean(cleancache)
23 resultdir = dir.Get(
'Results'); statusobj =
None
26 statusobj = resultdir.Get(
'Status')
29 l = statusobj.GetListOfKeys()
32 keys = dir.GetListOfKeys()
35 if ROOT.TClass.GetClass(key.GetClassName()).InheritsFrom(
'TDirectory'):
36 dirobj = key.ReadObj()
37 resultdir = dirobj.Get(
'Results'); statusobj =
None
39 statusobj = resultdir.Get(
'Status')
42 if name[-1] ==
'_' and resultdir:
44 subkeys = resultdir.GetListOfKeys()
45 for subkey
in subkeys:
46 ressub = subkey.GetName()
47 if ressub
not in (
'Status',
'Reference',
'ResultObject')
and ROOT.TClass.GetClass(subkey.GetClassName()).InheritsFrom(
'TDirectory'):
48 l = subkey.ReadObj().GetListOfKeys()
52 l = statusobj.GetListOfKeys()
59 isProduction =
bool(os.environ.get(
'DQPRODUCTION',
False))
60 func, mail_to = funcinfo
61 tmpfilename = outFileName +
"-safe-" +
str(os.getpid())
62 shutil.copy2(outFileName, tmpfilename)
66 currDir=
" pwd failed!"
68 currDir=os.environ[
"PWD"]
70 for files
in os.listdir(currDir):
71 if re.match(
r'^[0-9]*_.*.log$',files):
72 logFilesList.append(
"%s"%files)
73 logFiles=
'\r\n'.
join(logFilesList)
77 _local_apply(func, (tmpfilename, isIncremental))
78 _local_apply(_dolsrwrapper, (tmpfilename,))
80 except Exception
as e:
81 print(
'WARNING!!!: POSTPROCESSING FAILED FOR', func.__name__)
83 print(
'Relevant results will not be in output')
86 server = smtplib.SMTP(
'localhost')
87 mail_cc = [
'ponyisi@utexas.edu',
'rnarayan@utexas.edu']
88 msg = [
'From: atlasdqm@cern.ch',
89 'To: %s' %
', '.
join(mail_to),
90 'Cc: %s' %
', '.
join(mail_cc),
91 'Reply-to: atlasdqm-no-reply@cern.ch',
92 'Subject: WARNING: Postprocessing failure in production job',
94 'There has been a failure in Tier-0 postprocessing monitoring.',
96 'Function: %s' % func.__name__,
97 'File: %s' % outFileName,
98 'isIncremental? %s' % isIncremental,
101 'Current directory (contains LSF job ID): %s' % currDir,
102 'Log file name (contains ATLAS T0 job ID): %s' % logFiles
105 server.sendmail(
'atlasdqm@cern.ch', mail_to + mail_cc,
'\r\n'.
join(msg))
110 shutil.move(tmpfilename, outFileName)
112 os.unlink(tmpfilename)
117 f = ROOT.TFile.Open(fname)
118 lk = f.GetListOfKeys()
122 if not kn.startswith(
'run_'):
128 from ROOT
import gSystem
129 gSystem.Load(
'libDataQualityUtils')
130 from ROOT
import dqutils
135 from DataQualityUtils.createRpcFolders
import (createRPCDQMFDB,
136 createRPCConditionDB)
142 if not isIncremental:
143 from DataQualityUtils.createMdtFolders
import (createMDTConditionDBDead,
144 createMDTConditionDBNoisy)
148 def zlumi(fname, isIncremental):
149 if not isIncremental:
150 from DataQualityUtils.doZLumi
import go
153 def newstyle(yamlfile: str) -> Callable[[str, bool],
None]:
155 def newstyle_core(fname, isIncremental):
156 if not isIncremental:
158 print(f
'New style postprocessing running for: {yamlfile}')
159 cmdline = [
'histgrinder',
'--prefix', f
'/{rundir(fname)}/', fname, fname,
'-c', yamlfile]
160 subprocess.run(cmdline, check=
True)
161 newstyle_core.__name__ = os.path.splitext(os.path.basename(yamlfile))[0]
164 def make_newstyle_funcs() -> List[Tuple[Callable[[str, bool], None], List[str]]]:
167 from ._resolve_data_path
import resolve_data_path
170 print(
"Unable to resolve DataQualityUtils data path, not running new-style postprocessing")
173 inputs = glob.glob(os.path.join(dpath,
'postprocessing/*.yaml'))
175 rv.append((newstyle(input), [
'ponyisi@utexas.edu']))
179 (mf.fitMergedFile_IDPerfMonManager,
180 [
'weina.ji@cern.ch',
'ana.ovcharova@cern.ch']),
181 (mf.fitMergedFile_DiMuMonManager,
182 [
'ana.ovcharova@cern.ch']),
183 (mf.fitMergedFile_IDAlignMonManager,
184 [
'John.Alison@cern.ch',
'anthony.morley@cern.ch']),
185 (mf.pv_PrimaryVertexMonitoring_calcResoAndEfficiency,
186 [
'Andreas.Wildauer@cern.ch']),
188 [
'federico.meloni@cern.ch']),
190 [
'michele.bianco@le.infn.it',
'monica.verducci@cern.ch']),
192 [
'michele.bianco@le.infn.it',
'monica.verducci@cern.ch']),
194 [
'john.stakely.keller@cern.ch',
'monica.verducci@cern.ch']),
196 [
'lyuan@ihep.ac.cn',
'kingmgl@stu.kobe-u.ac.jp']),
197 (mf.MDTvsTGCPostProcess,
198 [
'lyuan@ihep.ac.cn',
'kingmgl@stu.kobe-u.ac.jp']),
199 (mf.HLTMuonPostProcess,
200 [
'lyuan@ihep.ac.cn',
'kingmgl@stu.kobe-u.ac.jp',
'yamazaki@phys.sci.kobe-u.ac.jp']),
201 (mf.HLTEgammaPostProcess,
202 [
'yan.jie.schnellbach@cern.ch',
'alessandro.tricoli@cern.ch']),
203 (mf.HLTTauPostProcess,
204 [
'Cristobal.Cuenca@cern.ch',
'Geng-Yuan.Jeng@cern.ch',
'Giovanna.Cottin@cern.ch']),
205 (mf.HLTMETPostProcess,
206 [
'venkat.kaushik@cern.ch']),
207 (mf.HLTCaloPostProcess,
208 [
'gareth.brown@cern.ch']),
209 (mf.HLTJetPostProcess,
210 [
'venkat.kaushik@cern.ch']),
211 (mf.BJetTaggingPostProcess,
212 [
'm.neumann@cern.ch']),
213 (mf.L1CaloPostProcess,
214 [
'ivana.hristova@cern.ch',
'pjwf@hep.ph.bham.ac.uk']),
215 (mf.PixelPostProcess,
216 [
'daiki.yamaguchi@cern.ch']),
217 (mf.MuonTrackPostProcess,
218 [
'baojia.tong@cern.ch',
'alexander.tuna@cern.ch']),
220 [
'ponyisi@utexas.edu']),
223 funclist += make_newstyle_funcs()
226 isTesting =
bool(os.environ.get(
'DQ_POSTPROCESS_ERROR_ON_FAILURE',
False))
229 def go_all(fname, isIncremental):
230 for funcinfo
in funclist:
231 funcinfo[0](fname, isIncremental)
239 for funcinfo
in funclist: