ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
DataQuality
GoodRunsLists
python
GoodRunsLists/python/grl.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2020 CERN for the benefit of the ATLAS collaboration
2
3
4
import
cherrypy
5
import
threading
6
import
sys, os
7
import
multiprocessing
8
import
xml.etree.ElementTree
as
ET
9
import
urllib
10
import
tempfile
11
import
shutil
12
13
def
_do_import_and_get_obj
(grlconfmod, grlobj = None):
14
__import__(grlconfmod)
15
m = sys.modules[grlconfmod]
16
if
grlobj
is
None
:
17
grlobj = grlconfmod.rsplit(
'.'
)[-1]
18
return
m.__dict__[grlobj]()
19
20
def
_deep_get_grl_info
(grlconf, cooltag, folder):
21
from
CoolRunQuery.AtlRunQueryLib
import
AtlRunQuery, AtlRunQueryOptions
22
from
CoolRunQuery.AtlRunQueryParser
import
ArgumentParser
23
24
25
config =
_do_import_and_get_obj
(grlconf)
26
config.setdqfolder(folder)
27
config.setdqctag(cooltag)
28
#config.setPrefix('')
29
30
query = config.getsearchquery()
31
print
(
">> Calling cmd equivalent of: "
)
32
print
(
"%s \"%s\""
% (config.querytool,query))
33
34
35
ap = ArgumentParser()
36
atlqueryarg = config.querytool +
" "
+ ap.ParseArgument( query )
37
(options, args) = AtlRunQueryOptions().
parse
(atlqueryarg)
38
39
#print (atlqueryarg)
40
#print (options)
41
42
43
proc = multiprocessing.Process(target=AtlRunQuery, args=(options,),
44
kwargs={
'html'
:
"NO"
,
'origQuery'
:query,
'loglevel'
:0})
# html can be "YES", "NO", "AUTO"
45
proc.start()
46
proc.join()
47
xmlfile =
'data/'
+config.listname
48
#print (">> Good-run list stored as: \'%s\'" % xmlfile)
49
return
xmlfile
50
51
52
def
_get_grl_info
(grlconf, cooltag, folder, queue = None):
53
sys.path.append(os.path.dirname(grlconf))
54
# grlconf is the input file
55
tmpdir = tempfile.mkdtemp()
56
os.chdir(tmpdir)
57
rfile =
_deep_get_grl_info
(os.path.basename(grlconf).rstrip(
'.py'
), cooltag, folder)
58
rv = open(rfile,
'r'
).
read
()
59
os.chdir(os.environ[
'TMPDIR'
])
60
shutil.rmtree(tmpdir)
61
#print (rv)
62
queue.put((rv, rfile))
63
return
64
65
def
_get_cool_tags_for_folder
(folder):
66
tagxml = urllib.urlopen(
'http://voatlas11.cern.ch:8080/cooldb/ATLAS_COOLPROD/ATLAS_COOLOFL_GLOBAL/COMP200/GLOBAL/DETSTATUS/%s/tags'
67
% folder)
68
xml = ET.parse(tagxml)
69
rv = []
70
for
t
in
xml.findall(
'tag'
):
71
text = t.text
72
lock = t.attrib.get(
'lock'
,
'unlocked'
)
73
description = t.attrib.get(
'description'
)
74
rv.append((text, description, lock))
75
return
rv
76
77
GRL_DIRECTORY=
'/afs/cern.ch/user/a/atlasdqm/grl'
78
79
80
TAGS_TO_SUPPRESS = [
'DetStatusLBSumm_m4initial'
,
81
'DetStatusLBSumm-cos08-01'
,
82
'DetStatusLBSumm-cos09-01'
,
83
'DetStatusLBSumm-cos08-02'
,
84
'COMP200_OFL'
,
85
'DetStatusLBSumm_RECP'
]
86
87
def
_get_list_of_grl_classes
():
88
rl = []
89
def
walker(rl, d, children):
90
for
child
in
children:
91
if
child[-3:] ==
'.py'
and
child !=
'__init__.py'
:
92
fullpath = os.path.join(d, child)
93
classname = fullpath.replace(GRL_DIRECTORY,
''
)[:-3].lstrip(
'/'
).
replace
(
'/'
,
'.'
)
94
rl.append((fullpath, classname))
95
os.path.walk(GRL_DIRECTORY, walker, rl)
96
return
rl
97
98
class
GRLGen
(object):
99
def
__init__
(self):
100
self.
genlock
= threading.Lock()
101
pass
102
103
@cherrypy.expose
104
def
index
(self):
105
rv = [
'<html><head>'
106
'<title>GRL generator</title>'
107
'<script type="text/javascript" src="/static/js/grl.js"><!-- -->'
108
'</script>'
109
'</head><body onload="onLoad()">'
110
'<h1>Good Run List Generator</h1>'
111
'<p>This generator allows you to create good run list XML files from '
112
'configurations that are currently kept on AFS, in <tt>~atlasdqm/grl</tt>.'
113
'<p>Using tags:'
114
'<p>CoolRunQuery-00-01-92'
115
'<p>GoodRunsLists-00-00-71'
116
]
117
rv.append(
'<div><form method="get" action="generate" style="border-width: 2px; border-style:solid">'
)
118
rv.append(
'Configuration file: <select name="configuration" id="confselect">'
)
119
for
f, cn
in
_get_list_of_grl_classes
():
120
rv.append(
'<option value="%(config)s">%(config)s</option>'
121
% {
'config'
: cn})
122
rv.append(
'</select> <a href="javascript:downloadPython()">(Click to download)</a> <br/>\n'
)
123
rv.append(
'DQ folder: <select name="folder" id="folderselect" onchange="adjustTagList(this)">\n'
124
'<option value="LBSUMM" selected>LBSUMM: Full DQ summary (default, recommended)</option>\n'
125
'<option value="SHIFTOFL">SHIFTOFL: Offline shifters (experts)</option>\n'
126
'<option value="DQCALCOFL">DQCALCOFL: Automatic checks + online shifters (experts)</option>\n'
127
'</select> If in doubt, leave as LBSUMM<br/>'
128
)
129
rv.append(
'COOL tag: <select name="cooltag" id ="cooltagselect">'
)
130
for
folder
in
(
'LBSUMM'
,
'SHIFTOFL'
,
'DQCALCOFL'
):
131
for
t, descr, lock
in
_get_cool_tags_for_folder
(folder):
132
if
t
in
TAGS_TO_SUPPRESS:
continue
133
apptext = []
134
if
descr:
135
apptext.append(
'(%s)'
% descr)
136
if
lock ==
'unlocked'
:
137
apptext.append(
'Tag unlocked, all runs may change'
)
138
elif
lock ==
'partial'
:
139
apptext.append(
'Tag partially locked, recent runs may change'
)
140
else
:
141
apptext.append(
'Tag locked'
)
142
if
apptext != []:
143
apptext.insert(0,
'—'
)
144
rv.append(
'<option value="%(tag)s">%(tag)s %(apptext)s</option>'
145
% {
'tag'
: t,
'apptext'
:
' '
.join(apptext)})
146
147
rv.append(
148
'<option value="">HEAD</option>'
149
'</select><br/>'
)
150
rv.append(
151
'<input type="submit" value="Submit"/>\n'
152
'</form></div>'
)
153
154
rv.append(
'</body></html>'
)
155
156
157
return
'\n'
.join(rv)
158
159
@cherrypy.expose
160
def
generate
(self, configuration=None, folder='LBSUMM', cooltag='HEAD'):
161
if
configuration
is
None
:
162
return
''
163
with
self.
genlock
as
lock:
# noqa: F841
164
q = multiprocessing.Queue()
165
proc = multiprocessing.Process(target=_get_grl_info,
166
args = [os.path.join(GRL_DIRECTORY, configuration),
167
cooltag],
168
kwargs = {
'queue'
: q,
'folder'
: folder})
169
proc.start()
170
rv = q.get()
171
proc.join()
172
cherrypy.response.headers[
'content-type'
] =
'text/xml'
173
cherrypy.response.headers[
'content-disposition'
] =
'attachment; filename=%s'
% rv[1]
174
return
rv[0]
python.grl.GRLGen
Definition
GoodRunsLists/python/grl.py:98
python.grl.GRLGen.__init__
__init__(self)
Definition
GoodRunsLists/python/grl.py:99
python.grl.GRLGen.genlock
genlock
Definition
GoodRunsLists/python/grl.py:100
parse
std::map< std::string, std::string, std::less<> > parse(const std::string &list)
Definition
egammaLayerRecalibTool.cxx:1180
replace
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition
hcg.cxx:312
generate
Definition
generate.cxx:28
index
Definition
index.py:1
python.grl._deep_get_grl_info
_deep_get_grl_info(grlconf, cooltag, folder)
Definition
GoodRunsLists/python/grl.py:20
python.grl._do_import_and_get_obj
_do_import_and_get_obj(grlconfmod, grlobj=None)
Definition
GoodRunsLists/python/grl.py:13
python.grl._get_cool_tags_for_folder
_get_cool_tags_for_folder(folder)
Definition
GoodRunsLists/python/grl.py:65
python.grl._get_list_of_grl_classes
_get_list_of_grl_classes()
Definition
GoodRunsLists/python/grl.py:87
python.grl._get_grl_info
_get_grl_info(grlconf, cooltag, folder, queue=None)
Definition
GoodRunsLists/python/grl.py:52
read
IovVectorMap_t read(const Folder &theFolder, const SelectionCriterion &choice, const unsigned int limit=10)
Definition
openCoraCool.cxx:569
Generated on
for ATLAS Offline Software by
1.17.0