93 def configure( self, inputName, outputName,
94 hiddenLayerPrefix = "" ):
95 """Perform a post-configuration on the analysis algorithm sequence
97 This function needs to be called once the sequence is configured to
98 hold the right algorithms, in the right order, with the right settings.
99 It sets the I/O properties of the algorithms to make sure that they
100 receive the input object(s) specified, and produce the output object(s)
103 The arguments can either be simple string names, or dictionaries in the
104 form of { "type" : "key", ... }. The latter is used to describe multiple
105 inputs/outputs to/from a sequence. See the descriptions of the various
106 analysis algorithm sequence setup functions on how their created
107 sequences should be configured by this function.
110 inputName -- The name(s) of the input object(s)/container(s) to
112 outputName -- The name(s) of the output object(s)/container(s) to
114 hiddenLayerPrefix -- Possible unique string prefix for
115 object(s)/container(s) in "hidden layers" of the
116 algorithm sequence. To avoid name clashes when
117 scheduling multiple instances of the sequence.
124 if self._isGaudiConfig2:
125 listOfAlgs = self._gaudiConfig2Algorithms
127 for alg
in self: listOfAlgs.append(alg)
131 nAlgs = len(listOfAlgs)
132 if len( self._algorithmMeta ) != nAlgs:
133 raise RuntimeError(
'Analysis algorithm sequence is in an ' \
134 'inconsistent state' )
138 for name, value
in self._metaConfigDefault.
items() :
139 metaConfig[name] = value[:]
141 for alg, meta
in zip( listOfAlgs, self._algorithmMeta ):
142 for var, func
in meta.dynConfig.items() :
146 obj = getattr (alg, var[:var.find(
'.')])
147 var = var[var.find(
'.')+1:]
150 setattr (obj, var, func (metaConfig))
152 for name, value
in meta.metaConfig.items() :
153 if name
not in metaConfig :
154 raise RuntimeError (
"metaConfig value " + name +
" for algorithm " + alg.name() +
" not registered, did you forget to call addMetaConfigDefault?")
155 metaConfig[name] += value[:]
161 if isinstance( inputName, dict ):
162 inputNameDict = inputName
164 inputNameDict = {
"default" : inputName }
166 if isinstance( outputName, dict ):
167 outputNameDict = outputName
169 outputNameDict = {
"default" : outputName }
173 currentInputs = copy.deepcopy( inputNameDict )
175 for alg, meta
in zip( listOfAlgs, self._algorithmMeta ):
179 if not meta.inputPropName:
183 for inputLabel, inputPropName
in meta.inputPropName.items():
184 if inputLabel
not in currentInputs:
186 setattr( alg, inputPropName, currentInputs[ inputLabel ] )
189 tool, inputPropName, outputPropName = self._algToDecorToolMap[
getFullName(alg)]
191 setattr( tool, inputPropName, currentInputs[ inputLabel ].
replace(
'%SYS%',
'NOSYS') )
195 if meta.outputPropName:
198 for outputLabel, outputPropName
in meta.outputPropName.items():
199 if outputLabel
not in tmpIndex:
200 tmpIndex[ outputLabel ] = 1
202 if outputLabel
in outputNameDict:
203 currentInputs[ outputLabel ] = \
204 '%s_tmp%i' % ( outputNameDict[ outputLabel ],
205 tmpIndex[ outputLabel ] )
207 currentInputs[ outputLabel ] = \
208 '%s%s_tmp%i' % ( hiddenLayerPrefix, outputLabel,
209 tmpIndex[ outputLabel ] )
212 tmpIndex[ outputLabel ] += 1
213 setattr( alg, outputPropName, currentInputs[ outputLabel ] )
216 tool, inputPropName, outputPropName = self._algToDecorToolMap[
getFullName(alg)]
218 setattr( tool, outputPropName, currentInputs[ outputLabel ].
replace(
'%SYS%',
'NOSYS') )
227 currentOutputs = copy.deepcopy( outputNameDict )
228 for alg, meta
in reversed(
list( zip( listOfAlgs, self._algorithmMeta ) ) ):
231 if len( currentOutputs ) == 0:
236 if meta.outputPropName:
237 for outputLabel, outputKey
in meta.outputPropName.items():
238 if outputLabel
in currentOutputs:
239 setattr( alg, outputKey, currentOutputs[ outputLabel ] )
242 tool, inputPropName, outputPropName = self._algToDecorToolMap[
getFullName(alg)]
244 setattr( tool, outputPropName, currentInputs[ outputLabel ].
replace(
'%SYS%',
'NOSYS') )
246 del currentOutputs[ outputLabel ]
253 if meta.inputPropName :
254 for inputLabel, inputKey
in meta.inputPropName.items():
255 if inputLabel
in currentOutputs:
256 setattr( alg, inputKey, currentOutputs[ inputLabel ] )
259 tool, inputPropName, outputPropName = self._algToDecorToolMap[
getFullName(alg)]
261 setattr( tool, inputPropName, currentInputs[ inputLabel ].
replace(
'%SYS%',
'NOSYS') )