ATLAS Offline Software
Functions | Variables
python.AMITagHelper Namespace Reference

Functions

def InputAMITags ()
 
def OutputAMITag (runArgs=None)
 
def SetAMITag (outputTag=None, inputTags=None, runArgs=None)
 

Variables

 log
 
 amitagRegex
 

Function Documentation

◆ InputAMITags()

def python.AMITagHelper.InputAMITags ( )
Returns AMITag of input, e.g. e6337_s3681_r13145

Looks up AMITag of input from INDS environmental variable and in-file
metadta. If nothing can be retrieved from the in-file metadata return value
from INDS, otherwise return value from metadata. Inform about differences.

Definition at line 38 of file AMITagHelper.py.

38 def InputAMITags():
39  """Returns AMITag of input, e.g. e6337_s3681_r13145
40 
41  Looks up AMITag of input from INDS environmental variable and in-file
42  metadta. If nothing can be retrieved from the in-file metadata return value
43  from INDS, otherwise return value from metadata. Inform about differences.
44  """
45  tags = []
46  tagsFromINDS = []
47  # from INDS environmental variable
48  inputDataSetName = os.environ.get('INDS')
49  if inputDataSetName:
50  # try extracting the AMITag of the input dataset from its name
51  tagsFromINDS = inputDataSetName.split('.')[-1].split('_')
52  tagsFromINDS = [tag for tag in tagsFromINDS if amitagRegex.match(tag)]
53  log.debug('AMITag from input dataset name: {}'.format(tagsFromINDS))
54 
55  # from in-file metadata
56  try:
57  tags = metadata['AMITag']
58  if isinstance(tags, str):
59  tags = tags.split('_')
60  except KeyError:
61  log.info("Cannot access /TagInfo/AMITag from in-file metadata")
62  return tagsFromINDS
63  except NameError:
64  log.info("Cannot access in-file metadata")
65  return tagsFromINDS
66 
67  if tagsFromINDS and tags != tagsFromINDS:
68  log.warning("AMITag mismatch, check metadata of input dataset")
69 
70  # Well that is weird, evgen?
71  return tags
72 
73 

◆ OutputAMITag()

def python.AMITagHelper.OutputAMITag (   runArgs = None)
Return value of new AMITag for this step in the workflow

Look up AMITag for this processing step from the command line arugments and
the reconstruction flags. Return the value from the CLI arguments if it is
set, otherwise try the value from the confi flags. Inform about differences.

Definition at line 74 of file AMITagHelper.py.

74 def OutputAMITag(runArgs=None):
75  """Return value of new AMITag for this step in the workflow
76 
77  Look up AMITag for this processing step from the command line arugments and
78  the reconstruction flags. Return the value from the CLI arguments if it is
79  set, otherwise try the value from the confi flags. Inform about differences.
80  """
81  if not runArgs:
82  runArgs = RunArguments()
83 
84  flagTag = ''
85  try:
86  flagTag = rec.AMITag()
87  except (NameError, AttributeError,):
88  pass
89 
90  cliTag = ''
91  try:
92  cliTag = runArgs.AMITag
93  except AttributeError:
94  pass
95 
96  if flagTag and flagTag != cliTag:
97  log.info('AMITag from recFlags does not match value form command line')
98 
99  if cliTag:
100  return cliTag
101  else:
102  return flagTag
103 
104 

◆ SetAMITag()

def python.AMITagHelper.SetAMITag (   outputTag = None,
  inputTags = None,
  runArgs = None 
)
Add input and output AMITag values and set result in in-file metadata

If no values are provided for the input and output AMITags we look the up.
The AMITags will be combined with '_' as delimiters. The result is set in
the in-file metadata.

Definition at line 105 of file AMITagHelper.py.

105 def SetAMITag(outputTag=None, inputTags=None, runArgs=None):
106  """Add input and output AMITag values and set result in in-file metadata
107 
108  If no values are provided for the input and output AMITags we look the up.
109  The AMITags will be combined with '_' as delimiters. The result is set in
110  the in-file metadata.
111  """
112  if not outputTag:
113  outputTag = OutputAMITag(runArgs)
114  if not inputTags:
115  inputTags = InputAMITags()
116 
117  tags = inputTags
118  if outputTag and outputTag not in inputTags:
119  tags += [outputTag]
120  tags = [tag for tag in tags if amitagRegex.match(tag)]
121  amitag = '_'.join(tags)
122  try:
123  if amitag:
124  ServiceMgr.TagInfoMgr.ExtraTagValuePairs.update( {'AMITag': amitag})
125  log.info("Output AMITag in in-file metadata set to {}".format(amitag))
126  else:
127  log.debug("Not adding empty AMITag to /TagInfo")
128  except NameError:
129  log.warning("TagInfoMgr not available to set output AMITag")
130  except TypeError:
131  log.info("AMITags could not be converted to well-known format")

Variable Documentation

◆ amitagRegex

python.AMITagHelper.amitagRegex

Definition at line 35 of file AMITagHelper.py.

◆ log

python.AMITagHelper.log

Definition at line 34 of file AMITagHelper.py.

vtune_athena.format
format
Definition: vtune_athena.py:14
python.AMITagHelper.SetAMITag
def SetAMITag(outputTag=None, inputTags=None, runArgs=None)
Definition: AMITagHelper.py:105
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.AMITagHelper.InputAMITags
def InputAMITags()
Definition: AMITagHelper.py:38
python.AMITagHelper.OutputAMITag
def OutputAMITag(runArgs=None)
Definition: AMITagHelper.py:74
Trk::split
@ split
Definition: LayerMaterialProperties.h:38