| The Gaudi Framework v29r0 (ff2e7097)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Namespace List
- Namespace Members

Classes | Functions | Variables
Gaudi.Configuration Namespace Reference

## Classes
class | GaudiPersistency

## Functions
def | _fillConfDict ()
def | importConfiguration (conf, local=locals())
def | configurationDict (all=False)
def | getConfigurable (name, defaultType=None)
def | setCustomMainLoop (runner)

## Variables
| log = logging.getLogger(__name__)
| allConfigurables = Configurable.allConfigurables

## Function Documentation

def Gaudi.Configuration._fillConfDict | ( |  | ) |
| private

Definition at line 20 of file Configuration.py.

20 def _fillConfDict():
21 nFiles = loadConfigurableDb()
22 log = logging.getLogger('PropertyProxy')
23 log.debug("Read module info for %d configurables from %d genConfDb files",
24 len(cfgDb), nFiles)
25 if len(cfgDb.duplicates()) > 0:
26 log.warning("Found %d duplicates among the %d genConfDb files :",
27 len(cfgDb.duplicates()), nFiles)
28 log.warning("--------------------------------------------------")
29 log.warning(" -%s: %s - %s",
30 "<component name>", "<module>", "[ <duplicates> ]")
31 log.warning("--------------------------------------------------")
32 dups = cfgDb.duplicates()
33 for cfgName in dups.keys():
34 log.warning(" -%s: %s - %s",
35 cfgName,
36 cfgDb[cfgName]['module'],
37 str([d['module'] for d in dups[cfgName]]))
38 pass
39 del dups
40 log.warning("Fix your cmt/requirements file !!")
41 pass
42 else:
43 log.debug("No duplicates have been found: that's good !")
44 pass
45 return
46
47
48 # fill the configurable dictionary at module load
49 _fillConfDict()
50
GaudiKernel.ConfigurableDb.loadConfigurableDb
def loadConfigurableDb()
Definition: ConfigurableDb.py:110
Gaudi.Configuration._fillConfDict
def _fillConfDict()
Definition: Configuration.py:20

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

59 def configurationDict(all=False):
60 """Return a dictionary representing the configuration.
61 The dictionary contains one entry per configurable which is a dictionary
62 with one entry per property.
63 The optional argument "all" is used to decide if to include only values
64 different from the default or all of them.
65 """
66 from GaudiKernel.Proxy.Configurable import getNeededConfigurables
67
68 catalog = allConfigurables
69 keys = getNeededConfigurables() # use only interesting configurables
70 conf_dict = {}
71 if all:
72 for n in keys:
73 if n not in conf_dict:
74 conf_dict[n] = {}
75 for p, v in catalog[n].getDefaultProperties().items():
76 conf_dict[n][p] = v
77
78 for n in keys:
79 if n not in conf_dict:
80 conf_dict[n] = {}
81 for p, v in catalog[n].getValuedProperties().items():
82 conf_dict[n][p] = v
83 # purge empty configurables
84 keys = conf_dict.keys()
85 for n in keys:
86 if not conf_dict[n]:
87 del conf_dict[n]
88 return conf_dict
89
90
GaudiKernel.Proxy.getNeededConfigurables
getNeededConfigurables
Definition: Proxy.py:20
Gaudi.Configuration.configurationDict
def configurationDict(all=False)
Definition: Configuration.py:59

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

91 def getConfigurable(name, defaultType=None):
92 """Helper function to get a configurable with the given name regardless
93 for the type.
94 If defaultType can be a class derived from configurable or a string. If not
95 specified, the tool name is used as type."""
96 if name in allConfigurables:
97 return allConfigurables[name]
98 else:
99 # if the configurable is not found, we need to instantiate it
100 if defaultType is None:
101 # try to use the name of the configurable as default type
102 defaultType = name
103 if type(defaultType) is str:
104 # we need to convert from string to actual class
105 if defaultType in globals():
106 # We the type is defined in the global namespace
107 defaultType = globals()[defaultType]
108 else:
109 # otherwise we try to get it from the Configurables database
110 import Configurables
111 defaultType = getattr(Configurables, defaultType)
112 return defaultType(name)
113
114
Gaudi.Configuration.getConfigurable
def getConfigurable(name, defaultType=None)
Definition: Configuration.py:91
gaudirun.type
type
Definition: gaudirun.py:133

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

Definition at line 55 of file Configuration.py.

55 def importConfiguration(conf, local=locals()):
56 local[conf] = confDbGetConfigurable(conf)
57
58
Gaudi.Configuration.importConfiguration
def importConfiguration(conf, local=locals())
Definition: Configuration.py:55

def Gaudi.Configuration.setCustomMainLoop | ( |  | runner | ) |

    Replace the default main execution loop with the specified callable object.

    @param runner: a callable that accepts an initialized instance of GaudiPython.AppMgr
                   and the number of events to process and returns a StatusCode or a boolean
                   (True means success)

Definition at line 115 of file Configuration.py.

115 def setCustomMainLoop(runner):
116 '''
117 Replace the default main execution loop with the specified callable object.
118
119 @param runner: a callable that accepts an initialized instance of GaudiPython.AppMgr
120 and the number of events to process and returns a StatusCode or a boolean
121 (True means success)
122 '''
123 # change the mainLoop function
124 from Gaudi.Main import gaudimain
125 gaudimain.mainLoop = lambda _self, app, nevt: runner(app, nevt)
126
127
Gaudi.Main
Definition: Main.py:1
Gaudi.Configuration.setCustomMainLoop
def setCustomMainLoop(runner)
Definition: Configuration.py:115

## Variable Documentation

Gaudi.Configuration.allConfigurables = Configurable.allConfigurables

Definition at line 17 of file Configuration.py.

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

Definition at line 13 of file Configuration.py.