The Gaudi Framework  v36r13 (995e4364)
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  log.warning("Fix your cmt/requirements file !!")
67  pass
68  else:
69  log.debug("No duplicates have been found: that's good !")
70  pass
71  return
72 
73 
74 # fill the configurable dictionary at module load
76 
77 

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

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

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

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

◆ importConfiguration()

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

Definition at line 78 of file Configuration.py.

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

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:82
GaudiKernel.Proxy.getNeededConfigurables
getNeededConfigurables
Definition: Proxy.py:30
GaudiKernel.ConfigurableDb.loadConfigurableDb
def loadConfigurableDb()
Definition: ConfigurableDb.py:120
Gaudi.Configuration.importConfiguration
def importConfiguration(conf, local=locals())
Definition: Configuration.py:78
Gaudi.Configuration.getConfigurable
def getConfigurable(name, defaultType=None)
Definition: Configuration.py:115
gaudirun.type
type
Definition: gaudirun.py:162
Gaudi.Configuration._fillConfDict
def _fillConfDict()
Definition: Configuration.py:37
GaudiPython.Pythonizations.items
items
Definition: Pythonizations.py:546