ATLAS Offline Software
Loading...
Searching...
No Matches
python.grl Namespace Reference

Classes

class  GRLGen

Functions

 GRL_IOV ()
 grl_from_dir (xmldir)
 load_grl_iovs_any (*files)
 load_grl (xml_file, IOVSet_class=IOVSet)
 load_grl_string (data, IOVSet_class=IOVSet)
 make_grl (iovset, name="unknown", version="unknown")
 grl_contains_run_lb (grl, runlb)
 grl_iovs_from_xml (*args, **kwargs)
 test ()
 _do_import_and_get_obj (grlconfmod, grlobj=None)
 _deep_get_grl_info (grlconf, cooltag, folder)
 _get_grl_info (grlconf, cooltag, folder, queue=None)
 _get_cool_tags_for_folder (folder)
 _get_list_of_grl_classes ()

Variables

str GRL_DIRECTORY = '/afs/cern.ch/user/a/atlasdqm/grl'
list TAGS_TO_SUPPRESS

Function Documentation

◆ _deep_get_grl_info()

python.grl._deep_get_grl_info ( grlconf,
cooltag,
folder )
protected

Definition at line 20 of file GoodRunsLists/python/grl.py.

20def _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
std::map< std::string, std::string > parse(const std::string &list)

◆ _do_import_and_get_obj()

python.grl._do_import_and_get_obj ( grlconfmod,
grlobj = None )
protected

Definition at line 13 of file GoodRunsLists/python/grl.py.

13def _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

◆ _get_cool_tags_for_folder()

python.grl._get_cool_tags_for_folder ( folder)
protected

Definition at line 65 of file GoodRunsLists/python/grl.py.

65def _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

◆ _get_grl_info()

python.grl._get_grl_info ( grlconf,
cooltag,
folder,
queue = None )
protected

Definition at line 52 of file GoodRunsLists/python/grl.py.

52def _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
IovVectorMap_t read(const Folder &theFolder, const SelectionCriterion &choice, const unsigned int limit=10)

◆ _get_list_of_grl_classes()

python.grl._get_list_of_grl_classes ( )
protected

Definition at line 87 of file GoodRunsLists/python/grl.py.

87def _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
std::string replace(std::string s, const std::string &s2, const std::string &s3)
Definition hcg.cxx:310

◆ grl_contains_run_lb()

python.grl.grl_contains_run_lb ( grl,
runlb )

Definition at line 84 of file DQUtils/python/grl.py.

84def grl_contains_run_lb(grl, runlb):
85 # takes IOVSet of GRL_IOV, says whether runlb is in it
86 # runlb can be RunLumi type or tuple pair
87 if isinstance(runlb, RunLumiType):
88 runlb_ = runlb
89 else:
90 runlb_ = RunLumi(*runlb)
91 return any(_.contains_point(runlb_) for _ in grl)
92
93# Deprecated alias

◆ grl_from_dir()

python.grl.grl_from_dir ( xmldir)
Loads valid IOV ranges if they appear in any grl file whose name ends with ".xml"

Definition at line 16 of file DQUtils/python/grl.py.

16def grl_from_dir(xmldir):
17 """
18 Loads valid IOV ranges if they appear in any grl file whose name ends with ".xml"
19 """
20 return load_grl_iovs_any(*(pjoin(xmldir, f)
21 for f in listdir(xmldir) if f.endswith(".xml")))
22

◆ GRL_IOV()

python.grl.GRL_IOV ( )

Definition at line 13 of file DQUtils/python/grl.py.

13def GRL_IOV():
14 "Represent a good run region"
15

◆ grl_iovs_from_xml()

python.grl.grl_iovs_from_xml ( * args,
** kwargs )

Definition at line 94 of file DQUtils/python/grl.py.

94def grl_iovs_from_xml(*args, **kwargs):
95 from warnings import warn
96 warn("grl_iovs_from_xml was renamed to load_grl", DeprecationWarning)
97 return load_grl(*args, **kwargs)
98

◆ load_grl()

python.grl.load_grl ( xml_file,
IOVSet_class = IOVSet )

Definition at line 38 of file DQUtils/python/grl.py.

38def load_grl(xml_file, IOVSet_class=IOVSet):
39 with open(xml_file, "rb") as fd:
40 return load_grl_string(fd.read(), IOVSet_class)
41

◆ load_grl_iovs_any()

python.grl.load_grl_iovs_any ( * files)
Use IOV ranges from the input `files` xmls if the lumirange is set in any file

Definition at line 23 of file DQUtils/python/grl.py.

23def load_grl_iovs_any(*files):
24 """
25 Use IOV ranges from the input `files` xmls if the lumirange is set in any file
26 """
27 grl_iovsets = [grl_iovs_from_xml(f) for f in files]
28
29 assert all(i.ordered for i in grl_iovsets)
30
31 result = IOVSet()
32 for since, until, grl_states in process_iovs(*grl_iovsets):
33 if any(grl_states):
34 result.add(since, until)
35
36 return result.solidify(GRL_IOV)
37

◆ load_grl_string()

python.grl.load_grl_string ( data,
IOVSet_class = IOVSet )

Definition at line 42 of file DQUtils/python/grl.py.

42def load_grl_string(data, IOVSet_class=IOVSet):
43 xml = ET.fromstring(data)
44 result = []
45
46 for lbc in xml.iter('LumiBlockCollection'):
47 run = int(lbc.find('Run').text)
48 for lbr in lbc.findall('LBRange'):
49 since, until = int(lbr.get('Start')), int(lbr.get('End')) + 1
50
51 result.append((RunLumi(run, since), RunLumi(run, until)))
52
53 return IOVSet_class(map(GRL_IOV._make, sorted(result)))
54
STL class.

◆ make_grl()

python.grl.make_grl ( iovset,
name = "unknown",
version = "unknown" )

Definition at line 55 of file DQUtils/python/grl.py.

55def make_grl(iovset, name="unknown", version="unknown"):
56 assert len(iovset.channels) <= 1
57
58 from datetime import datetime
59 from textwrap import dedent
60
61 result = [dedent("""
62 <?xml version="1.0" ?>
63 <!DOCTYPE LumiRangeCollection
64 SYSTEM 'http://atlas-runquery.cern.ch/LumiRangeCollection.dtd'>
65 <!-- Good-runs-list created by DQUtils on {time} -->
66 <LumiRangeCollection>
67 <NamedLumiRange>
68 <Name>{name}</Name>
69 <Version>{version}</Version>""".format(
70 name=name, version=version,
71 time=datetime.now().strftime("%Y-%m-%d %H:%M:%S.%f"))).strip()]
72
73 for run, iovs in sorted(iovset.by_run.items()):
74 result.append(" <LumiBlockCollection>")
75 result.append(" <Run>%i</Run>" % run)
76 for iov in iovs:
77 arg = iov.since.lumi, iov.until.lumi-1
78 result.append(' <LBRange Start="%i" End="%i"/>' % arg)
79 result.append(" </LumiBlockCollection>")
80 result.append(" </NamedLumiRange>")
81 result.append("</LumiRangeCollection>")
82 return "\n".join(result)
83

◆ test()

python.grl.test ( )

Definition at line 99 of file DQUtils/python/grl.py.

99def test():
100 path = "/afs/cern.ch/user/b/beate/public/DQAna/StableBeams-periodC1.xml"
101 iovs = grl_iovs_from_xml(path)
102
103 from pprint import pprint
104 pprint(iovs)
105

Variable Documentation

◆ GRL_DIRECTORY

str python.grl.GRL_DIRECTORY = '/afs/cern.ch/user/a/atlasdqm/grl'

Definition at line 77 of file GoodRunsLists/python/grl.py.

◆ TAGS_TO_SUPPRESS

list python.grl.TAGS_TO_SUPPRESS
Initial value:
1= ['DetStatusLBSumm_m4initial',
2 'DetStatusLBSumm-cos08-01',
3 'DetStatusLBSumm-cos09-01',
4 'DetStatusLBSumm-cos08-02',
5 'COMP200_OFL',
6 'DetStatusLBSumm_RECP']

Definition at line 80 of file GoodRunsLists/python/grl.py.