Definition at line 342 of file TriggerConfigAccessBase.py.
◆ __init__()
def python.TriggerConfigAccessBase.ConfigCrestLoader.__init__ |
( |
|
self, |
|
|
* |
configType, |
|
|
|
dbalias, |
|
|
|
dbkey, |
|
|
|
crestServer |
|
) |
| |
Definition at line 343 of file TriggerConfigAccessBase.py.
343 def __init__(self, *, configType, dbalias, dbkey, crestServer):
345 self.crestServer = crestServer
346 self.dbalias = dbalias
◆ _get_payload()
dict python.TriggerConfigAccessBase.ConfigCrestLoader._get_payload |
( |
|
self, |
|
|
str |
hash |
|
) |
| |
|
private |
get payload from crest server using request library
Args:
hash (str): the query part of the url as required by the REST api
Raises:
RuntimeError: when connection or query failed
Returns:
dict: the json content
Definition at line 356 of file TriggerConfigAccessBase.py.
356 def _get_payload(self, hash: str) -> dict:
357 """get payload from crest server using request library
360 hash (str): the query part of the url as required by the REST api
363 RuntimeError: when connection or query failed
366 dict: the json content
370 url = f
"{self.crestServer}/payloads/data"
375 preq = requests.Request(method=
'GET', url=url, params=params).prepare()
376 with requests.Session()
as session:
378 resp = session.send(preq)
379 except requests.ConnectionError
as exc:
380 log.error(f
"Could not connect to crest server {self.crestServer} ({exc})")
381 raise RuntimeError(f
"Could not connect to CREST server {self.crestServer}")
383 if resp.status_code != 200:
384 log.error(f
"Error: HTTP GET request '{preq.url}' failed")
385 raise RuntimeError(f
"Query {hash} to crest failed with status code {resp.status_code}")
387 config = json.loads(resp.content, object_pairs_hook = odict)
388 self.confirmConfigType(config)
◆ _getDBSchemaName()
str python.TriggerConfigAccessBase.ConfigCrestLoader._getDBSchemaName |
( |
|
dbalias | ) |
|
|
staticprivate |
Definition at line 392 of file TriggerConfigAccessBase.py.
392 def _getDBSchemaName(dbalias) -> str:
393 dblookupFile = ConfigDBLoader.getResolvedFileName(
"dblookup.xml",
"CORAL_DBLOOKUP_PATH")
394 dbp = ET.parse(dblookupFile)
395 for logSvc
in dbp.iter(
"logicalservice"):
396 if logSvc.attrib[
"name"] != dbalias:
399 for serv
in logSvc.iter(
"service"):
400 if serv.attrib[
"name"].startswith(
"oracle://"):
401 oracleService = serv.attrib[
"name"]
402 oracleServer = oracleService.split(
'/')[3]
404 raise RuntimeError(f
"DB {dbalias} has no oracle services listed in {dblookupFile}")
405 raise RuntimeError(f
"DB {dbalias} is not listed in {dblookupFile}")
◆ confirmConfigType()
def python.TriggerConfigAccessBase.ConfigLoader.confirmConfigType |
( |
|
self, |
|
|
|
config |
|
) |
| |
|
inherited |
checks that the in-file specification of the configuration type matches the expected type
Definition at line 51 of file TriggerConfigAccessBase.py.
51 def confirmConfigType(self,config):
53 checks that the in-file specification of the configuration type matches the expected type
55 if config[
'filetype'] != self.configType:
56 raise RuntimeError(
"Can not load file with filetype '%s' when expecting '%s'" % (config[
'filetype'], self.configType.filetype))
◆ getWriteFilename()
def python.TriggerConfigAccessBase.ConfigCrestLoader.getWriteFilename |
( |
|
self | ) |
|
Definition at line 422 of file TriggerConfigAccessBase.py.
422 def getWriteFilename(self):
423 return "{basename}_{schema}_{dbkey}.json".
format(basename = self.configType.basename, schema = self.schema, dbkey = self.dbkey)
◆ load()
dict python.TriggerConfigAccessBase.ConfigCrestLoader.load |
( |
|
self | ) |
|
Definition at line 407 of file TriggerConfigAccessBase.py.
407 def load(self) -> dict:
409 self.schema = ConfigCrestLoader._getDBSchemaName(self.dbalias)
411 "ATLAS_CONF_TRIGGER_RUN3":
"CONF_DATA_RUN3",
412 "ATLAS_CONF_TRIGGER_MC_RUN3":
"CONF_MC_RUN3",
413 "ATLAS_CONF_TRIGGER_REPR_RUN3":
"CONF_REPR_RUN3",
415 if url_schema
is None:
416 raise RuntimeError(f
"Oracle server {self.schema} is not implemented in the crest server {self.crestServer}")
417 hash = f
"triggerdb://{url_schema}/{self.configType.crestkey}/{self.dbkey}"
418 config = self._get_payload(hash=hash)
◆ setQuery()
def python.TriggerConfigAccessBase.ConfigCrestLoader.setQuery |
( |
|
self, |
|
|
|
query |
|
) |
| |
With CREST all queries are defined in the CREST server
Definition at line 350 of file TriggerConfigAccessBase.py.
350 def setQuery(self, query):
352 With CREST all queries are defined in the CREST server
◆ configType
python.TriggerConfigAccessBase.ConfigLoader.configType |
|
inherited |
◆ crestServer
python.TriggerConfigAccessBase.ConfigCrestLoader.crestServer |
◆ dbalias
python.TriggerConfigAccessBase.ConfigCrestLoader.dbalias |
◆ dbkey
python.TriggerConfigAccessBase.ConfigCrestLoader.dbkey |
◆ schema
python.TriggerConfigAccessBase.ConfigCrestLoader.schema |
The documentation for this class was generated from the following file: