The Gaudi Framework  v37r1 (a7f61348)
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 37 of file Configuration.py.

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

◆ 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 81 of file Configuration.py.

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

◆ 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 114 of file Configuration.py.

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

◆ importConfiguration()

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

Definition at line 77 of file Configuration.py.

77 def importConfiguration(conf, local=locals()):
78  local[conf] = confDbGetConfigurable(conf)
79 
80 

Variable Documentation

◆ allConfigurables

Gaudi.Configuration.allConfigurables = Configurable.allConfigurables

Definition at line 34 of file Configuration.py.

◆ log

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

Definition at line 30 of file Configuration.py.

Gaudi.Configuration.configurationDict
def configurationDict(all=False)
Definition: Configuration.py:81
GaudiKernel.Proxy.getNeededConfigurables
getNeededConfigurables
Definition: Proxy.py:30
GaudiKernel.ConfigurableDb.loadConfigurableDb
def loadConfigurableDb()
Definition: ConfigurableDb.py:119
Gaudi.Configuration.importConfiguration
def importConfiguration(conf, local=locals())
Definition: Configuration.py:77
Gaudi.Configuration.getConfigurable
def getConfigurable(name, defaultType=None)
Definition: Configuration.py:114
gaudirun.type
type
Definition: gaudirun.py:162
Gaudi.Configuration._fillConfDict
def _fillConfDict()
Definition: Configuration.py:37
GaudiPython.Pythonizations.items
items
Definition: Pythonizations.py:546