ATLAS Offline Software
Functions | Variables
python.Versioning Namespace Reference

Functions

def legacyReleaseData ()
 
def generatorsGetInitialVersionedDictionary (generators)
 
def generatorsGetFromMetadata (metadataString)
 
def generatorsVersionedStringList (generatorsDictionary)
 
def generatorsVersionedString (generatorsVersionedList)
 
def GeneratorVersioningFixCfg (flags)
 

Variables

 versionRegex = re.compile(r'\‍(v\.(.*)\‍)$')
 
list ignoredGenerators = ["Pythia8B", "Powheg"]
 

Function Documentation

◆ generatorsGetFromMetadata()

def python.Versioning.generatorsGetFromMetadata (   metadataString)

Definition at line 32 of file Versioning.py.

32 def generatorsGetFromMetadata(metadataString):
33  output = {}
34  metadataStringSplit = metadataString.split("+")
35  for s in metadataStringSplit:
36  match = versionRegex.search(s)
37  if match:
38  s = s.replace(match.group(0), "")
39  output[s] = match.group(1)
40  else:
41  output[s] = None
42  return output
43 

◆ generatorsGetInitialVersionedDictionary()

def python.Versioning.generatorsGetInitialVersionedDictionary (   generators)

Definition at line 25 of file Versioning.py.

26  output = {}
27  for generator in generators:
28  env_variable = f"{generator.upper()}VER"
29  output[generator] = getenv(env_variable, None)
30  return output
31 

◆ generatorsVersionedString()

def python.Versioning.generatorsVersionedString (   generatorsVersionedList)

Definition at line 53 of file Versioning.py.

53 def generatorsVersionedString(generatorsVersionedList):
54  return "+".join(generatorsVersionedList)
55 
56 

◆ generatorsVersionedStringList()

def python.Versioning.generatorsVersionedStringList (   generatorsDictionary)

Definition at line 44 of file Versioning.py.

44 def generatorsVersionedStringList(generatorsDictionary):
45  list = []
46  for generator, version in generatorsDictionary.items():
47  if version is not None:
48  list.append(f"{generator}(v.{version})")
49  else:
50  list.append(generator)
51  return list
52 

◆ GeneratorVersioningFixCfg()

def python.Versioning.GeneratorVersioningFixCfg (   flags)

Definition at line 57 of file Versioning.py.

57 def GeneratorVersioningFixCfg(flags):
58  from AthenaCommon.Logging import logging
59  log = logging.getLogger("GeneratorsInfo")
60  from AthenaConfiguration.ComponentAccumulator import ComponentAccumulator
61 
62  generatorsData = flags.Input.GeneratorsInfo
63  log.info(f"Generators data: {generatorsData}")
64 
65  missingVersion = False
66  for k, v in generatorsData.items():
67  if v is None and k not in ignoredGenerators:
68  missingVersion = True
69 
70  if not missingVersion:
71  return ComponentAccumulator()
72 
73  log.info("At least one MC generator is missing version information. Attempting to fix...")
74 
75  from PyUtils.AMITagHelperConfig import inputAMITags
76  tags = inputAMITags(flags, fixBroken=True, silent=True)
77  tag = None
78  if tags and tags[0].startswith("e"):
79  tag = tags[0]
80 
81  releaseDataDict = legacyReleaseData()
82  if tag not in releaseDataDict:
83  log.warning(f"Could not find release data for tag {tag}.")
84  return ComponentAccumulator()
85 
86  releaseData = releaseDataDict[tag]
87  for k, v in generatorsData.items():
88  if v is None and k not in ignoredGenerators and k in releaseData:
89  log.info(f"Setting version for {k} to {releaseData[k]}.")
90  generatorsData[k] = releaseData[k]
91 
92  outputStringList = generatorsVersionedStringList(generatorsData)
93 
94  from EventInfoMgt.TagInfoMgrConfig import TagInfoMgrCfg
95  return TagInfoMgrCfg(flags, tagValuePairs={"generators": generatorsVersionedString(outputStringList)})

◆ legacyReleaseData()

def python.Versioning.legacyReleaseData ( )

Definition at line 10 of file Versioning.py.

10 def legacyReleaseData():
11  from pathlib import Path
12  from PathResolver import PathResolver
13  filePath = Path(PathResolver.FindCalibFile("GeneratorConfig/Legacy_AthGeneration_versions.txt"))
14  data = {}
15  with filePath.open() as f:
16  header = f.readline().strip().split(",")
17  generators = header[2:]
18  for line in f:
19  line = line.strip().split(",")
20  item = {generator: version for generator, version in zip(generators, line[2:])}
21  item['version'] = line[0]
22  data[line[1]] = item
23  return data
24 

Variable Documentation

◆ ignoredGenerators

list python.Versioning.ignoredGenerators = ["Pythia8B", "Powheg"]

Definition at line 7 of file Versioning.py.

◆ versionRegex

python.Versioning.versionRegex = re.compile(r'\‍(v\.(.*)\‍)$')

Definition at line 5 of file Versioning.py.

PathResolver::FindCalibFile
static std::string FindCalibFile(const std::string &logical_file_name)
Definition: PathResolver.h:108
python.JetAnalysisCommon.ComponentAccumulator
ComponentAccumulator
Definition: JetAnalysisCommon.py:302
python.TagInfoMgrConfig.TagInfoMgrCfg
def TagInfoMgrCfg(flags, tagValuePairs={})
Definition: TagInfoMgrConfig.py:6
python.Versioning.generatorsVersionedString
def generatorsVersionedString(generatorsVersionedList)
Definition: Versioning.py:53
python.Versioning.generatorsGetInitialVersionedDictionary
def generatorsGetInitialVersionedDictionary(generators)
Definition: Versioning.py:25
python.Versioning.GeneratorVersioningFixCfg
def GeneratorVersioningFixCfg(flags)
Definition: Versioning.py:57
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition: Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.Versioning.generatorsVersionedStringList
def generatorsVersionedStringList(generatorsDictionary)
Definition: Versioning.py:44
python.Versioning.legacyReleaseData
def legacyReleaseData()
Definition: Versioning.py:10
SCT_ConditionsAlgorithms::CoveritySafe::getenv
std::string getenv(const std::string &variableName)
get an environment variable
Definition: SCT_ConditionsUtilities.cxx:17
python.AMITagHelperConfig.inputAMITags
def inputAMITags(flags, fixBroken=False, silent=False)
Definition: AMITagHelperConfig.py:38
python.Versioning.generatorsGetFromMetadata
def generatorsGetFromMetadata(metadataString)
Definition: Versioning.py:32
Trk::split
@ split
Definition: LayerMaterialProperties.h:38