Definition at line 340 of file TriggerConfigAccessBase.py.
◆ __init__()
def python.TriggerConfigAccessBase.ConfigCrestLoader.__init__ |
( |
|
self, |
|
|
* |
configType, |
|
|
|
dbalias, |
|
|
|
dbkey, |
|
|
|
crestServer |
|
) |
| |
Definition at line 341 of file TriggerConfigAccessBase.py.
341 def __init__(self, *, configType, dbalias, dbkey, crestServer):
343 self.crestServer = crestServer
344 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 354 of file TriggerConfigAccessBase.py.
354 def _get_payload(self, hash: str) -> dict:
355 """get payload from crest server using request library
358 hash (str): the query part of the url as required by the REST api
361 RuntimeError: when connection or query failed
364 dict: the json content
368 url = f
"{self.crestServer}/payloads/data"
373 preq = requests.Request(method=
'GET', url=url, params=params).prepare()
374 with requests.Session()
as session:
376 resp = session.send(preq)
377 except requests.ConnectionError
as exc:
378 log.error(f
"Could not connect to crest server {self.crestServer} ({exc})")
379 raise RuntimeError(f
"Could not connect to CREST server {self.crestServer}")
381 if resp.status_code != 200:
382 log.error(f
"Error: HTTP GET request '{preq.url}' failed")
383 raise RuntimeError(f
"Query {hash} to crest failed with status code {resp.status_code}")
385 config = json.loads(resp.content)
386 self.confirmConfigType(config)
◆ _getDBSchemaName()
str python.TriggerConfigAccessBase.ConfigCrestLoader._getDBSchemaName |
( |
|
dbalias | ) |
|
|
staticprivate |
Definition at line 390 of file TriggerConfigAccessBase.py.
390 def _getDBSchemaName(dbalias) -> str:
391 dblookupFile = ConfigDBLoader.getResolvedFileName(
"dblookup.xml",
"CORAL_DBLOOKUP_PATH")
392 dbp = ET.parse(dblookupFile)
393 for logSvc
in dbp.iter(
"logicalservice"):
394 if logSvc.attrib[
"name"] != dbalias:
397 for serv
in logSvc.iter(
"service"):
398 if serv.attrib[
"name"].startswith(
"oracle://"):
399 oracleService = serv.attrib[
"name"]
400 oracleServer = oracleService.split(
'/')[3]
402 raise RuntimeError(f
"DB {dbalias} has no oracle services listed in {dblookupFile}")
403 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 49 of file TriggerConfigAccessBase.py.
49 def confirmConfigType(self,config):
51 checks that the in-file specification of the configuration type matches the expected type
53 if config[
'filetype'] != self.configType:
54 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 420 of file TriggerConfigAccessBase.py.
420 def getWriteFilename(self):
421 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 405 of file TriggerConfigAccessBase.py.
405 def load(self) -> dict:
407 self.schema = ConfigCrestLoader._getDBSchemaName(self.dbalias)
409 "ATLAS_CONF_TRIGGER_RUN3":
"CONF_DATA_RUN3",
410 "ATLAS_CONF_TRIGGER_MC_RUN3":
"CONF_MC_RUN3",
411 "ATLAS_CONF_TRIGGER_REPR_RUN3":
"CONF_REPR_RUN3",
413 if url_schema
is None:
414 raise RuntimeError(f
"Oracle server {self.schema} is not implemented in the crest server {self.crestServer}")
415 hash = f
"triggerdb://{url_schema}/{self.configType.crestkey}/{self.dbkey}"
416 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 348 of file TriggerConfigAccessBase.py.
348 def setQuery(self, query):
350 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: