|
ATLAS Offline Software
|
◆ _parseExecDict()
def python.trfAMI._parseExecDict |
( |
|
substep, |
|
|
|
value |
|
) |
| |
|
private |
Back convert a pre/postExec dictionary into a set of command line compatible strings.
Definition at line 117 of file trfAMI.py.
120 string +=
" '" + substep +
":" +
str(bit).
replace(
"'",
"\\'")+
"'"
◆ _parseIncludeDict()
def python.trfAMI._parseIncludeDict |
( |
|
substep, |
|
|
|
value, |
|
|
|
joinWithChar = "," |
|
) |
| |
|
private |
Back convert a pre/postInclude dictionary into a set of command line compatible strings By default use a comma for joining up the list values.
Definition at line 126 of file trfAMI.py.
128 string += substep +
":" + joinWithChar.join(value).
replace(
"'",
"\\'")+
"'"
◆ deserialiseFromAMIString()
def python.trfAMI.deserialiseFromAMIString |
( |
|
amistring | ) |
|
Convert from a string to a python object.
As we don't know how the string is encoded we try JSON then a safe eval. This is a bit ugly :-(
Definition at line 534 of file trfAMI.py.
536 result = json.loads(amistring)
537 except ValueError
as e_json:
538 msg.debug(
"Failed to decode {0} as JSON: {1}".
format(amistring, e_json))
540 result = ast.literal_eval(amistring)
542 errMsg =
"Failed to deserialise AMI string '{0}' using JSON or eval".
format(amistring)
544 raise TransformAMIException(AMIerrorCode, errMsg)
◆ get_ami_tag()
def python.trfAMI.get_ami_tag |
( |
|
client, |
|
|
|
tag, |
|
|
|
suppressNonJobOptions = True |
|
) |
| |
Get AMI-tag information.
Args:
:client: the pyAMI client [ pyAMI.client.Client ]
:tag: the AMI-tag [ str ]
Returns:
an array of python dictionnaries.
Definition at line 381 of file trfAMI.py.
381 def get_ami_tag(client, tag, suppressNonJobOptions = True):
382 '''Get AMI-tag information.
385 :client: the pyAMI client [ pyAMI.client.Client ]
386 :tag: the AMI-tag [ str ]
389 an array of python dictionnaries.
394 '-amiTag="%s"' % tag,
398 if suppressNonJobOptions:
399 command += [
'-suppressNonJobOptions']
403 return client.execute(command, format =
'dict_object').get_rows(
'amiTagInfo')
◆ getAMIClient()
def python.trfAMI.getAMIClient |
( |
|
endpoints = ['atlas-replica','atlas'] | ) |
|
Get an AMI client.
- Note
- Always return a client to the primary replica. The caller is allowed to update the replica via the config.endpoints value.
- Returns
- pyAMI.client.Client instance
Definition at line 222 of file trfAMI.py.
222 def getAMIClient(endpoints = ['atlas-replica','atlas']):
223 msg.debug(
'Getting AMI client...')
226 from pyAMI.client
import Client
228 raise TransformAMIException(AMIerrorCode,
'Import of pyAMI modules failed.')
230 msg.debug(
"Attempting to get AMI client for endpoints {0}".
format(endpoints))
231 amiclient =
Client(endpoints, ignore_proxy =
True)
◆ getPANDAClient()
def python.trfAMI.getPANDAClient |
( |
| ) |
|
Get PANDA client.
- Returns
- cx_Oracle cursor instance
Definition at line 248 of file trfAMI.py.
249 msg.debug(
'Getting PANDA client...')
253 raise TransformAMIException(AMIerrorCode,
'Import of cx_Oracle failed (is Oracle setup on this machine?).')
256 cur = cx_Oracle.connect(
'atlas_grisli_r/panda_c10@adcr_panda').
cursor()
258 msg.debug(
'An exception occurred while connecting to PANDA database: %s', traceback.format_exc())
259 raise TransformAMIException(AMIerrorCode,
'Failed to get PANDA client connection (N.B. this does not work from outside CERN).')
◆ getProdSysTagsCharacters()
def python.trfAMI.getProdSysTagsCharacters |
( |
| ) |
|
Get list of characters of ProdSys tags.
- Returns
- list of characters
Definition at line 236 of file trfAMI.py.
239 msg.debug(
'Getting list of ProdSys tag characters...')
241 defaultList=[
'z',
'p',
'e',
's',
'd',
'r',
't',
'a',
'b',
'w']
◆ getTrfConfigFromAMI()
def python.trfAMI.getTrfConfigFromAMI |
( |
|
tag, |
|
|
|
suppressNonJobOptions = True |
|
) |
| |
Get information about a T0 tag from AMI.
- Parameters
-
tag | Tag for which information is requested |
- Returns
- list of PyJoCbTransforms.trfAMI.TRFConfig instances
Definition at line 416 of file trfAMI.py.
417 msg.debug(
'Using AMI to get info about tag %s', tag)
421 import pyAMI.exception
422 except ImportError
as e:
423 raise TransformAMIException(AMIerrorCode,
'Import of pyAMI modules failed ({0})'.
format(e))
428 result =
get_ami_tag(amiclient, tag, suppressNonJobOptions)
429 except pyAMI.exception.Error
as e:
430 msg.warning(
'An exception occured when connecting to primary AMI: {0}'.
format(e))
431 msg.debug(
'Exception: {0}'.
format(e))
432 if 'please login' in e.message
or 'certificate expired' in e.message:
433 raise TransformAMIException(AMIerrorCode,
'Getting tag info from AMI failed with credential problem. '
434 'Please check your AMI account status.')
435 if 'Invalid amiTag' in e.message:
436 raise TransformAMIException(AMIerrorCode,
'Invalid AMI tag ({0}).'.
format(tag))
438 msg.debug(
"Error may not be fatal - will try AMI replica catalog")
442 trf.name = result[0][
'transformation']
443 trf.inputs=result[0].
get(
'inputs', {})
444 trf.outputs=result[0].
get(
'outputs', {})
445 trf.release = result[0][
'SWReleaseCache'].
replace(
'_',
',')
447 if 'phconfig' in result[0]:
451 for k, v
in result[0].
items():
456 msg.info(
'found a quoted space (" ") in parameter value for %s, converting to list', k)
462 msg.debug(
'Result from AMI after string cleaning:')
463 msg.debug(
'%s', dumps(physics, indent = 4))
465 if suppressNonJobOptions:
466 for k
in list(physics):
467 if k
in [
'inputs',
'outputs',
'productionStep',
'transformation',
'SWReleaseCache']:
470 for k, v
in physics.items():
471 if 'triggerConfig' in k
or 'triggerConfigByRun' in k:
473 physics[k] = v.replace(
' ',
',')
474 msg.warning(
'Attempted to correct illegal trigger configuration string: {0} -> {1}'.
format(v, physics[k]))
476 msg.debug(
"Checking for pseudo-argument internal to ProdSys...")
477 if 'extraParameter' in physics:
478 val = physics.pop(
'extraParameter')
479 msg.debug(
"Removed extraParamater=%s from arguments.", val)
481 msg.debug(
"Checking for input/output file arguments...")
482 for arg
in list(physics):
483 if arg.lstrip(
'-').startswith(
'input')
and arg.endswith(
'File'):
484 value = physics.pop(arg)
485 msg.debug(
"Found input file argument %s=%s.", arg, value)
486 trf.inFiles[arg] = value
487 elif arg.lstrip(
'-').startswith(
'output')
and arg.endswith(
'File'):
488 value = physics.pop(arg)
489 msg.debug(
"Found output file argument %s=%s.", arg, value)
490 trf.outFiles[arg] = value
492 msg.debug(
"Checking for not set arguments...")
493 for arg, value
in physics.items():
494 if value ==
"NONE" or value ==
"none" or value == [
"NONE"]:
495 val = physics.pop(arg)
496 msg.debug(
"Removed %s=%s from arguments.", arg, val)
498 trf.physics = physics
500 if not isinstance(trf.physics, dict):
501 raise TransformAMIException(AMIerrorCode,
"Bad result for tag's phconfig: {0}".
format(trf.physics))
503 if trf.inFiles == {}:
504 if 'inputs' in result[0]:
506 for inFileType, inFileName
in trf.inFiles.items():
509 if inFileName ==
'' or inFileName =={}
or inFileName == []
or inFileName ==
'{}':
512 if 'outputs' in result[0]:
514 trf.outFiles=dict( (k,
getOutputFileName(k.removeprefix(
'output').removesuffix(
'File')) )
for k
in outputs )
515 trf.outfmts=[ outputs[k][
'dstype']
for k
in outputs ]
516 except KeyError
as e:
517 raise TransformAMIException(AMIerrorCode,
"Missing key in AMI data: {0}".
format(e))
518 except Exception
as e:
519 raise TransformAMIException(AMIerrorCode,
"Got a very unexpected exception while parsing AMI outputs!"
520 " Please report.\nParsing:\n{0}\nRaised:\n{1}".
format(result, e))
523 if '_tf.py' in trf.name:
524 trf.newTransform=
True
526 trf.newTransform=
False
◆ getTrfConfigFromPANDA()
def python.trfAMI.getTrfConfigFromPANDA |
( |
|
tag | ) |
|
Get information about a ProdSys tag from PANDA.
- Parameters
-
tag | Tag for which information is requested |
- Returns
- list of PyJoCbTransforms.trfAMI.TRFConfig instances
Definition at line 272 of file trfAMI.py.
274 msg.debug(
'Using PANDA to get info about tag %s', tag)
278 pandaclient.execute(
"select trf,trfv,lparams,vparams,formats,cache from t_trf_config where tag='%s' and cid=%d" %(tag[:1],
int(tag[1:]) ) )
279 result=pandaclient.fetchone()
281 msg.info(
'An exception occurred: %s', traceback.format_exc())
282 raise TransformAMIException(AMIerrorCode,
'Getting tag info from PANDA failed.')
285 raise TransformAMIException(AMIerrorCode,
'Tag %s not found in PANDA database' % tag)
287 msg.debug(
'Raw data returned from panda DB is:' + os.linesep +
str(result))
289 trfn=result[0].
split(
',')
290 msg.debug(
'List of transforms: %s', trfn)
291 trfv=result[1].
split(
',')
292 msg.debug(
'List of releases: %s', trfv)
293 lparams=result[2].
split(
';')
294 msg.debug(
'List of arguments: %s', lparams)
295 vparams=result[3].
split(
';')
296 msg.debug(
'List of argument values: %s', vparams)
297 formats=result[4].
split(
'.')
298 msg.debug(
'List of formats: %s', formats)
299 cache=result[5].
split(
',')
300 msg.debug(
'List of caches: %s', formats)
303 if not ( len(trfn) == len(trfv) == len(lparams) == len(vparams) ):
304 raise TransformAMIException(AMIerrorCode,
'Inconsistency in number of trfs.')
308 if len(cache) != len(trfv):
310 cache = cache * len(trfv)
312 raise TransformAMIException(AMIerrorCode,
'Inconsistency in number of caches entries vs. release numbers ({0}; {1}).'.
format(cache, trfv))
316 for iTrf
in range(len(trfn)):
320 if '_tf.py' in trf.name:
321 trf.newTransform=
True
323 trf.newTransform=
False
324 trf.release=trfv[iTrf] +
"," + cache[iTrf]
326 keys=lparams[iTrf].
split(
',')
327 values=vparams[iTrf].
split(
',')
329 if ( len(keys) != len(values) ):
330 raise TransformAMIException(AMIerrorCode,
'Inconsistency in number of arguments.')
332 physics = dict( (k,
ReadablePANDA(v) )
for (k,v)
in zip(keys, values))
334 for k, v
in physics.items():
335 if 'triggerConfig' in k
or 'triggerConfigByRun' in k:
337 physics[k] = v.replace(
' ',
',')
338 msg.warning(
'Attempted to correct illegal trigger configuration string: {0} -> {1}'.
format(v, physics[k]))
341 physics[k] = [ execElement.replace(
"%8C",
"")
for execElement
in v.split(
"%8C %8C") ]
343 msg.debug(
"Checking for pseudo-argument internal to ProdSys...")
344 if 'extraParameter' in physics:
345 val=physics.pop(
'extraParameter')
346 msg.debug(
"Removed extraParamater=%s from arguments.", val)
348 msg.debug(
"Checking for input/output file arguments...")
349 for arg
in list(physics):
350 if arg.lstrip(
'-').startswith(
'input')
and arg.endswith(
'File'):
351 value=physics.pop(arg)
352 msg.debug(
"Found input file argument %s=%s.", arg, value )
353 trf.inFiles[arg]=value
354 elif arg.lstrip(
'-').startswith(
'output')
and arg.endswith(
'File'):
355 value=physics.pop(arg)
356 msg.debug(
"Found output file argument %s=%s.", arg, value )
357 trf.outFiles[arg]=value
359 msg.debug(
"Checking for not set arguments...")
360 for arg,value
in physics.items():
361 if value==
"NONE" or value==
"none" or value==[
"NONE"]:
363 msg.debug(
"Removed %s=%s from arguments.", arg, val )
367 listOfTrfs.append(trf)
371 listOfTrfs[0].inDS=
None
372 listOfTrfs[-1].outfmts=formats
378 directly copied from pyAMI.atlas 5 API
379 should be removed once suppressNonJobOptions is in official release
◆ isNewAMITag()
def python.trfAMI.isNewAMITag |
( |
|
tag | ) |
|
Definition at line 131 of file trfAMI.py.
156 if tag[0]
in newTagDict:
157 if int(tag[1:]) > newTagDict[tag[0]]:
158 msg.debug(
'it is a new tag')
161 msg.debug(
'it is NOT a new tag')
◆ ReadablePANDA()
def python.trfAMI.ReadablePANDA |
( |
|
s | ) |
|
Un-escape information from PANDA.
Provided by Pavel.
Definition at line 265 of file trfAMI.py.
◆ remove_enclosing_quotes()
def python.trfAMI.remove_enclosing_quotes |
( |
|
s | ) |
|
Definition at line 405 of file trfAMI.py.
407 if s[0] == s[-1]
and s[0]
in (
'"',
"'"):
◆ AMIerrorCode
python.trfAMI.AMIerrorCode |
◆ msg
std::string replace(std::string s, const std::string &s2, const std::string &s3)
def _parseExecDict(substep, value)
Back convert a pre/postExec dictionary into a set of command line compatible strings.
def getInputFileName(arg, tag=None)
def getTrfConfigFromPANDA(tag)
Get information about a ProdSys tag from PANDA.
def getAMIClient(endpoints=['atlas-replica', 'atlas'])
Get an AMI client.
def getPANDAClient()
Get PANDA client.
def getTrfConfigFromAMI(tag, suppressNonJobOptions=True)
Get information about a T0 tag from AMI.
def ReadablePANDA(s)
Un-escape information from PANDA.
def getOutputFileName(fmt)
def get_ami_tag(client, tag, suppressNonJobOptions=True)
def convertToStr(in_string)
Recursively convert unicode to str, useful when we have just loaded something from json (TODO: make t...
def getProdSysTagsCharacters()
Get list of characters of ProdSys tags.
def remove_enclosing_quotes(s)
T * get(TKey *tobj)
get a TObject* from a TKey* (why can't a TObject be a TKey?)
def _parseIncludeDict(substep, value, joinWithChar=",")
Back convert a pre/postInclude dictionary into a set of command line compatible strings By default us...
def deserialiseFromAMIString(amistring)
Convert from a string to a python object.