The Gaudi Framework  master (37c0b60a)
Gaudi.Configuration Namespace Reference

Functions

def _fillConfDict ()
 
def importConfiguration (conf, local=locals())
 
def configurationDict (all=False)
 
def getConfigurable (name, defaultType=None)
 

Variables

 log = logging.getLogger(__name__)
 
 allConfigurables = Configurable.allConfigurables
 

Function Documentation

◆ _fillConfDict()

def Gaudi.Configuration._fillConfDict ( )
private

Definition at line 35 of file Configuration.py.

35 def _fillConfDict():
36  nFiles = loadConfigurableDb()
37  log = logging.getLogger("PropertyProxy")
38  log.debug(
39  "Read module info for %d configurables from %d genConfDb files",
40  len(cfgDb),
41  nFiles,
42  )
43  if len(cfgDb.duplicates()) > 0:
44  log.warning(
45  "Found %d duplicates among the %d genConfDb files :",
46  len(cfgDb.duplicates()),
47  nFiles,
48  )
49  log.warning("--------------------------------------------------")
50  log.warning(
51  " -%s: %s - %s", "<component name>", "<module>", "[ <duplicates> ]"
52  )
53  log.warning("--------------------------------------------------")
54  dups = cfgDb.duplicates()
55  for cfgName in dups.keys():
56  log.warning(
57  " -%s: %s - %s",
58  cfgName,
59  cfgDb[cfgName]["module"],
60  str([d["module"] for d in dups[cfgName]]),
61  )
62  pass
63  del dups
64  pass
65  else:
66  log.debug("No duplicates have been found: that's good !")
67  pass
68  return
69 
70 
71 # fill the configurable dictionary at module load
73 
74 

◆ configurationDict()

def Gaudi.Configuration.configurationDict (   all = False)
Return a dictionary representing the configuration.
The dictionary contains one entry per configurable which is a dictionary
with one entry per property.
The optional argument "all" is used to decide if to include only values
different from the default or all of them.

Definition at line 79 of file Configuration.py.

79 def configurationDict(all=False):
80  """Return a dictionary representing the configuration.
81  The dictionary contains one entry per configurable which is a dictionary
82  with one entry per property.
83  The optional argument "all" is used to decide if to include only values
84  different from the default or all of them.
85  """
86  from GaudiKernel.Proxy.Configurable import getNeededConfigurables
87 
88  catalog = allConfigurables
89  keys = getNeededConfigurables() # use only interesting configurables
90  conf_dict = {}
91  if all:
92  for n in keys:
93  if n not in conf_dict:
94  conf_dict[n] = {}
95  for p, v in catalog[n].getDefaultProperties().items():
96  conf_dict[n][p] = v
97 
98  for n in keys:
99  if n not in conf_dict:
100  conf_dict[n] = {}
101  for p, v in catalog[n].getValuedProperties().items():
102  conf_dict[n][p] = v
103  # purge empty configurables
104  keys = conf_dict.keys()
105  ret_dict = {}
106  for n in keys:
107  if conf_dict[n]:
108  ret_dict[n] = conf_dict[n]
109  return ret_dict
110 
111 

◆ getConfigurable()

def Gaudi.Configuration.getConfigurable (   name,
  defaultType = None 
)
Helper function to get a configurable with the given name regardless
for the type.
If defaultType can be a class derived from configurable or a string. If not
specified, the tool name is used as type.

Definition at line 112 of file Configuration.py.

112 def getConfigurable(name, defaultType=None):
113  """Helper function to get a configurable with the given name regardless
114  for the type.
115  If defaultType can be a class derived from configurable or a string. If not
116  specified, the tool name is used as type."""
117  if name in allConfigurables:
118  return allConfigurables[name]
119  else:
120  # if the configurable is not found, we need to instantiate it
121  if defaultType is None:
122  # try to use the name of the configurable as default type
123  defaultType = name
124  if isinstance(defaultType, str):
125  # we need to convert from string to actual class
126  if defaultType in globals():
127  # We the type is defined in the global namespace
128  defaultType = globals()[defaultType]
129  else:
130  # otherwise we try to get it from the Configurables database
131  import Configurables
132 
133  defaultType = getattr(Configurables, defaultType)
134  return defaultType(name)

◆ importConfiguration()

def Gaudi.Configuration.importConfiguration (   conf,
  local = locals() 
)

Definition at line 75 of file Configuration.py.

75 def importConfiguration(conf, local=locals()):
76  local[conf] = confDbGetConfigurable(conf)
77 
78 

Variable Documentation

◆ allConfigurables

Gaudi.Configuration.allConfigurables = Configurable.allConfigurables

Definition at line 32 of file Configuration.py.

◆ log

Gaudi.Configuration.log = logging.getLogger(__name__)

Definition at line 28 of file Configuration.py.

Gaudi.Configuration.configurationDict
def configurationDict(all=False)
Definition: Configuration.py:79
GaudiKernel.Proxy.getNeededConfigurables
getNeededConfigurables
Definition: Proxy.py:30
GaudiKernel.ConfigurableDb.loadConfigurableDb
def loadConfigurableDb()
Definition: ConfigurableDb.py:113
Gaudi.Configuration.importConfiguration
def importConfiguration(conf, local=locals())
Definition: Configuration.py:75
Gaudi.Configuration.getConfigurable
def getConfigurable(name, defaultType=None)
Definition: Configuration.py:112
Gaudi.Configuration._fillConfDict
def _fillConfDict()
Definition: Configuration.py:35