10 from inspect
import isclass
13 VERBOSE, DEBUG, INFO, WARNING, ERROR, FATAL
19 InvertNode, ControlFlowLeaf,
20 ControlFlowNode, CFTrue, CFFalse)
24 'Configurable',
'ConfigurableAlgorithm',
'ConfigurableAlgTool',
25 'ConfigurableAuditor',
'ConfigurableService',
'ConfigurableUser',
26 'VERBOSE',
'DEBUG',
'INFO',
'WARNING',
'ERROR',
'FATAL',
27 'appendPostConfigAction',
'removePostConfigAction' 32 log = logging.getLogger(
'Configurable')
37 Expand environment variables "data". 38 Data can be string, list, tuple and dictionary. For collection, all the 39 contained strings will be manipulated (recursively). 44 return os.path.expandvars(data)
45 elif typ
in [list, tuple]:
60 Error occurred in the configuration process. 68 class PropertyReference(object):
73 return "@%s" % self.
name 78 refname, refprop = self.
name.rsplit(
'.', 1)
79 if refname
in Configurable.allConfigurables:
80 conf = Configurable.allConfigurables[refname]
81 retval = getattr(conf, refprop)
82 if hasattr(retval,
"getFullName"):
83 retval = retval.getFullName()
86 "name '%s' not found resolving '%s'" % (refname, self))
90 """This function allow transparent integration with 91 Configurable.getValuedProperties. 98 except AttributeError:
107 """Base class for Gaudi components that implement the IProperty interface. 108 Provides most of the boilerplate code, but the actual useful classes 109 are its derived ConfigurableAlgorithm, ConfigurableService, and 110 ConfigurableAlgTool.""" 116 propertyNoValue =
'<no value>' 118 printHeaderWidth = 100
135 configurableServices = {
139 _configurationLocked =
False 142 """To Gaudi, any object with the same type/name is the same object. Hence, 143 this is mimicked in the configuration: instantiating a new Configurable 144 of a type with the same name will return the same instance.""" 150 name = kwargs[
'name']
151 elif 'name' in cls.
__init__.func_code.co_varnames:
153 index = list(cls.
__init__.func_code.co_varnames).index(
'name')
156 name = args[index - 1]
159 name = cls.
__init__.func_defaults[index - (len(args) + 1)]
164 except (IndexError, TypeError):
165 raise TypeError(
'no "name" argument while instantiating "%s"' %
170 if hasattr(cls,
'DefaultedName'):
171 name = cls.DefaultedName
174 elif not name
or type(name) != str:
177 'could not retrieve name from %s.__init__ arguments' %
182 if issubclass(cls, ConfigurableAlgTool)
and '.' not in name:
183 name =
'ToolSvc.' + name
193 if name
in cls.configurables:
194 conf = cls.configurables[name]
196 cls.configurables[conf.getType()] = conf
198 for n, v
in kwargs.items():
202 conf, ConfigurableUser):
205 setattr(conf,
"_enabled",
True)
209 spos = name.find(
'/')
212 ti_name =
"%s/%s" % (name, name)
213 if ti_name
in cls.configurables:
215 return cls.configurables[ti_name]
220 if i_name == name[spos + 1:]
and i_name
in cls.configurables:
222 return cls.configurables[i_name]
227 (spos > 0
and i_name == name[spos + 1:]
230 if conf.__class__
is ConfigurableGeneric:
234 newconf = object.__new__(cls)
235 cls.
__init__(newconf, *args, **kwargs)
240 for n
in newconf.__slots__:
242 for n
in conf._properties:
243 if names[n.lower()] != n:
245 "Option '%s' was used for %s, but the correct spelling is '%s'" 246 % (n, name, names[n.lower()]))
247 setattr(newconf, names[n.lower()], getattr(conf, n))
248 for n, v
in kwargs.items():
249 setattr(newconf, n, v)
250 cls.configurables[name] = newconf
256 'attempt to redefine type of "%s" (was: %s, new: %s)%s',
257 name, conf.__class__.__name__, cls.__name__,
263 for n, v
in kwargs.items():
268 conf = object.__new__(cls)
272 cls.configurables[name] = conf
274 for base
in cls.__bases__:
275 if base.__name__ ==
'ConfigurableService':
287 klass = self.__class__
290 if klass == Configurable:
292 "%s is an ABC and can not be instantiated" % str(Configurable))
303 for meth, nArgs
in meths.items():
305 f = getattr(klass, meth).im_func
306 except AttributeError:
307 raise NotImplementedError(
308 "%s is missing in class %s" % (meth, str(klass)))
311 nargcount = f.func_code.co_argcount
312 ndefaults = f.func_defaults
and len(f.func_defaults)
or 0
313 if not nargcount - ndefaults <= nArgs <= nargcount:
314 raise TypeError(
"%s.%s requires exactly %d arguments" %
315 (klass, meth, nArgs))
323 if hasattr(self.__class__,
'DefaultedName'):
324 self.
_name = self.__class__.DefaultedName
345 for name, proxy
in self._properties.items():
347 dict[name] = proxy.__get__(self)
348 except AttributeError:
351 dict[
'_Configurable__children'] = self.
__children 352 dict[
'_Configurable__tools'] = self.
__tools 353 dict[
'_name'] = self.
_name 357 return (self.
_name, )
361 from contextlib
import contextmanager
372 for n, v
in dict.items():
384 newconf = object.__new__(self.__class__)
387 for proxy
in self._properties.values():
389 proxy.__set__(newconf, proxy.__get__(self))
390 except AttributeError:
400 if not type(configs)
in (list, tuple):
401 configs = (configs, )
407 if not isinstance(cfg, Configurable):
408 raise TypeError(
"'%s' is not a Configurable" % str(cfg))
413 ccjo = cc.getJobOptName()
415 if c.getJobOptName() == ccjo:
416 log.error(
'attempt to add a duplicate ... dupe ignored%s',
424 descr.__set__(self, cc)
426 setattr(self, cc.getName(), cc)
427 except AttributeError:
437 if attr
in self._properties:
438 if isinstance(self._properties[attr].__get__(self),
439 DataObjectHandleBase):
440 return self._properties[attr].__get__(self)
443 if c.getName() == attr:
446 raise AttributeError(
447 "'%s' object has no attribute '%s'" % (self.__class__, attr))
452 "%s: Configuration cannot be modified after the ApplicationMgr has been started." 456 except AttributeError:
457 raise AttributeError(
458 "Configurable '%s' does not have property '%s'." %
459 (self.__class__.__name__, name))
465 prop = self._properties[attr]
466 prop.__delete__(self)
467 prop.__set__(self, prop.default)
477 if c.getName() == attr:
482 del self.__dict__[attr]
483 except (AttributeError, KeyError):
490 if type(items) != list
and type(items) != tuple:
500 return copy.deepcopy(child)
514 if hasattr(cc,
'setParent')
and parent:
517 except RuntimeError
as e:
519 log.error(str(e) +
'%s', error_explanation)
520 ccbd = cc.configurables[cc.getJobOptName()]
523 for proxy
in self._properties.values():
524 if proxy.history.has_key(cc):
525 proxy.__set__(ccbd, proxy.__get__(cc))
539 "children() is deprecated, use getChildren() instead for consistency" 542 "getChildren() returns a copy; to add a child, use 'parent += child'%s",
547 """Get all (private) configurable children, both explicit ones (added with +=) 548 and the ones in the private GaudiHandle properties""" 551 for proxy
in self._properties.values():
553 c = proxy.__get__(self)
554 except AttributeError:
557 if isinstance(c, Configurable)
and not c.isPublic():
559 elif isinstance(c, GaudiHandle):
561 conf = c.configurable
562 except AttributeError:
565 if not conf.isPublic():
567 elif isinstance(c, GaudiHandleArray):
571 if isinstance(ci, Configurable):
575 conf = ci.configurable
576 except AttributeError:
588 elems.append(c.getFullName())
593 if not hasattr(self,
'_initok')
or not self.
_initok:
595 raise TypeError(
"Configurable.__init__ not called in %s override" %
596 self.__class__.__name__)
610 handle = self.getHandle()
612 log.debug(
'no handle for %s: not transporting properties',
617 for name
in self._properties.keys():
620 setattr(handle, name, getattr(self, name))
627 for name, proxy
in self._properties.items():
629 props[name] = proxy.__get__(self)
630 except AttributeError:
631 props[name] = Configurable.propertyNoValue
636 """Get all properties with their description string as { name : (value, desc) }.""" 638 for name, proxy
in self._properties.items():
640 props[name] = (proxy.__get__(self), proxy.__doc__)
641 except AttributeError:
642 props[name] = (Configurable.propertyNoValue, proxy.__doc__)
647 for name, proxy
in self._properties.items():
649 value = proxy.__get__(self)
650 if hasattr(value,
'getFullName'):
651 value = value.getFullName()
652 elif type(value)
in [list, tuple]:
655 if hasattr(i,
'getFullName'):
656 new_value.append(i.getFullName())
659 value =
type(value)(new_value)
660 elif type(value)
is dict:
663 if hasattr(value[i],
'getFullName'):
666 new_value[i] = value[i]
685 for k, v
in cls._properties.items():
686 if not k
in c.__dict__
and hasattr(v,
'default'):
687 c.__dict__[k] = v.default
700 if name
in c.__dict__:
701 return c.__dict__[name]
705 v = cls._properties[name]
706 if hasattr(v,
'default'):
714 """Returns the value of the given property. 716 if hasattr(self, name):
717 return getattr(self, name)
722 """Set the value of a given property 724 return setattr(self, name, value)
727 """Tell if the property 'name' has been set or not. 729 Because of a problem with list and dictionary properties, in those cases 730 if the value is equal to the default, the property is considered as not 733 if not hasattr(self, name):
736 if isinstance(default, (list, dict, DataObjectHandleBase)):
737 value = getattr(self, name)
738 return value != default
759 "jobOptName() is deprecated, use getJobOptName() instead for consistency%s",
774 if log.isEnabledFor(logging.DEBUG):
782 def clone(self, name=None, **kwargs):
784 if hasattr(self,
'DefaultedName'):
785 name = self.DefaultedName
787 name = self.getType()
789 newconf = Configurable.__new__(self.__class__, name)
790 self.__class__.
__init__(newconf, name)
792 for proxy
in self._properties.values():
794 value = proxy.__get__(self)
795 if type(value)
in [str, list, dict, tuple]:
797 value =
type(value)(value)
798 proxy.__set__(newconf, value)
799 except AttributeError:
802 for c
in self.__children:
805 for n, t
in self.__tools.items():
806 newconf.addTool(t, n)
808 for name, value
in kwargs.items():
809 setattr(newconf, name, value)
815 dot = fullname.find(
'.')
817 parentname = fullname[:dot]
818 longname = fullname[dot + 1:]
822 dot = longname.find(
'.')
824 name = longname[:dot]
827 return parentname, name, longname
830 if isclass(tool)
and issubclass(tool, ConfigurableAlgTool):
833 priv_tool = tool(self.
getName() +
'.' + name)
834 elif isinstance(tool, ConfigurableAlgTool):
836 name = tool.splitName()[1]
837 priv_tool = tool.clone(self.
getName() +
'.' + name)
840 classname = tool.__name__
842 classname =
type(tool).__name__
844 "addTool requires AlgTool configurable. Got %s type" %
849 setattr(self, name, self.
__tools[name])
864 handle = __main__.Service(svc)
869 if hasattr(self,
'configure' + svc):
870 eval(
'self.configure' + svc +
'( handle )')
873 dlls = self.getDlls()
876 elif type(dlls) == types.StringType:
879 from __main__
import theApp
880 dlls = filter(
lambda d: d
not in theApp.Dlls, dlls)
893 preLen = Configurable.printHeaderPre
894 postLen = Configurable.printHeaderWidth - \
895 preLen - 3 - len(title)
896 postLen =
max(preLen, postLen)
897 return indentStr +
'/%s %s %s' % (preLen *
'*', title, postLen *
'*')
901 preLen = Configurable.printHeaderPre
902 postLen = Configurable.printHeaderWidth - \
903 preLen - 12 - len(title)
904 postLen =
max(preLen, postLen)
905 return indentStr +
'\\%s (End of %s) %s' % (preLen *
'-', title,
909 return '{0}({1!r})'.
format(self.__class__.__name__, self.
name())
911 def __str__(self, indent=0, headerLastIndentUnit=indentUnit):
913 indentStr = indent * Configurable.indentUnit
918 headerIndent = (indent - 1) * \
919 Configurable.indentUnit + headerLastIndentUnit
922 rep = Configurable._printHeader(headerIndent, title)
928 rep += indentStr +
'|-<no properties>' + os.linesep
932 for p
in props.keys():
933 nameWidth =
max(nameWidth, len(p))
934 for p, v
in props.items():
936 prefix = indentStr +
'|-%-*s' % (nameWidth, p)
938 if log.isEnabledFor(logging.DEBUG):
939 if v != Configurable.propertyNoValue:
940 address =
' @%11s' %
hex(id(v))
945 default = defs.get(p)
946 if v == Configurable.propertyNoValue:
948 strVal = repr(default)
952 if hasattr(v,
"getGaudiHandle"):
953 vv = v.getGaudiHandle()
956 if isinstance(vv, GaudiHandle)
or isinstance(
957 vv, GaudiHandleArray):
960 if hasattr(default,
"toStringProperty"):
961 strDef = repr(default.toStringProperty())
963 strDef = repr(default)
964 if strDef == repr(vv.toStringProperty()):
968 strDef = repr(default)
970 line = prefix +
' = ' + strVal
972 if strDef
is not None:
974 if len(line) + len(strDef) > Configurable.printHeaderWidth:
975 line += os.linesep + indentStr +
'| ' + \
976 (len(prefix) - len(indentStr) - 3) *
' ' 977 line +=
' (default: %s)' % (strDef, )
979 rep += line + os.linesep
991 rep += cfg.__str__(indent + 1,
'|=') + os.linesep
994 rep += Configurable._printFooter(indentStr, title)
999 Return True is the instance can be "applied". 1000 Always False for plain Configurable instances 1001 (i.e. not ConfigurableUser). 1017 object.__setattr__(obj, self.
__name__, value)
1024 Configurable.__init__(self, name)
1033 return 'GenericComponent' 1044 super(ConfigurableGeneric, self).
__setattr__(name, value)
1048 if isinstance(value, Configurable):
1049 self.__dict__[name] = value
1053 if not name
in self._properties:
1055 self._properties[name].__set__(self, value)
1069 'AuditAlgorithms': 0,
1070 'AuditInitialize': 0,
1071 'AuditReinitialize': 0,
1079 super(ConfigurableAlgorithm, self).
__init__(name)
1100 elif rhs
is CFFalse:
1102 return AndNode(self, rhs)
1109 return OrNode(self, rhs)
1112 return InvertNode(self)
1115 return OrderedNode(self, rhs)
1126 return (repr(self) == repr(other))
1133 'AuditInitialize': 0,
1144 return iService(self.
_name)
1163 'AuditInitialize': 0,
1168 super(ConfigurableAlgTool, self).
__init__(name)
1169 if '.' not in self.
_name:
1173 name = name[name.find(
'/') + 1:]
1195 return pop + Configurable.getPrintTitle(self)
1204 if isinstance(c, ConfigurableAlgTool):
1205 c.setParent(parentName)
1209 name = name[name.rfind(
'.') + 1:]
1240 name = name[name.rfind(
'.') + 1:]
1241 return str(self.
getType() +
'/' + name)
1248 __slots__ = {
'_jobOptName': 0,
'OutputLevel': 0,
'Enable': 1}
1251 super(ConfigurableAuditor, self).
__init__(name)
1253 name = name[name.find(
'/') + 1:]
1275 "__used_instances__": [],
1287 __used_configurables__ = []
1290 __queried_configurables__ = []
1292 def __init__(self, name=Configurable.DefaultName, _enabled=True, **kwargs):
1293 super(ConfigurableUser, self).
__init__(name)
1294 for n, v
in kwargs.items():
1312 if type(used)
is tuple:
1313 used, used_name = used
1317 if type(used)
is str:
1318 used_class = confDbGetConfigurable(used)
1323 inst = used_class(name=used_name, _enabled=
False)
1324 except AttributeError:
1328 inst = used_class(name=used_name)
1332 if type(queried)
is str:
1333 queried = confDbGetConfigurable(used)
1334 inst = queried(_enabled=
False)
1335 except AttributeError:
1341 Declare that we are going to modify the Configurable 'other' in our 1342 __apply_configuration__. 1345 if hasattr(other,
"__users__"):
1346 other.__users__.append(self)
1350 Declare that we are going to retrieve property values from the 1351 ConfigurableUser 'other' in our __apply_configuration__. 1353 if not isinstance(other, ConfigurableUser):
1355 "'%s': Cannot make passive use of '%s', it is not a ConfigurableUser" 1356 % (self.
name(), other.name()))
1357 other.__addActiveUseOf(self)
1371 Remove this ConfigurableUser instance from the users list of the used 1377 used.__users__.remove(self)
1381 Propagate the property 'name' (if set) to other configurables (if possible). 1384 propagate to all the entries in __used_configurables__ 1385 a configurable instance: 1386 propagate only to it 1387 list of configurable instances: 1388 propagate to all of them. 1392 - if the local property is set, the other property will be overwritten 1393 - local property not set and other set => keep other 1394 - local property not set and other not set => overwrite the default for 1395 ConfigurableUser instances and set the property for Configurables 1400 elif type(others)
not in [list, tuple]:
1406 for other
in [o
for o
in others
if name
in o.__slots__]:
1409 if other.isPropertySet(name):
1411 "Property '%(prop)s' is set in both '%(self)s' and '%(other)s', using '%(self)s.%(prop)s'" 1413 "self": self.
name(),
1414 "other": other.name(),
1417 other.setProp(name, value)
1419 elif not other.isPropertySet(name):
1420 if isinstance(other, ConfigurableUser):
1421 otherType =
type(other._properties[name].getDefault())
1422 other._properties[name].setDefault(value)
1423 if otherType
in [list, dict]:
1426 other.setProp(name, otherType(value))
1428 other.setProp(name, value)
1433 Call propagateProperty for each property listed in 'names'. 1434 If 'names' is None, all the properties are propagated. 1438 names = [p
for p
in self.
__slots__ if not p.startswith(
"_")]
1444 Function to be overridden to convert the high level configuration into a 1446 The default implementation calls applyConf, which is the method defined 1447 in some ConfigurableUser implementations. 1453 Function to be overridden to convert the high level configuration into a 1460 Function used to define the name of the private instance of a given class 1462 This method is used when the __used_configurables_property__ declares the 1463 need of a private used configurable without specifying the name. 1465 if type(cls)
is str:
1468 clName = cls.__name__
1469 return "%s_%s" % (self.name(), clName)
1473 Return the used instance with a given name. 1476 if i.name() == name:
1477 if hasattr(i,
"_enabled"):
1482 raise KeyError(name)
1486 Return True is the instance can be "applied". 1492 postConfigActions = []
1497 Add a new callable ('function') to the list of post-configuration actions. 1498 If the callable is already in the list, it is moved to the end of the list. 1499 The list is directly accessible as 'GaudiKernel.Configurable.postConfigActions'. 1502 postConfigActions.remove(function)
1505 postConfigActions.append(function)
1510 Remove a callable from the list of post-config actions. 1511 The list is directly accessible as 'GaudiKernel.Configurable.postConfigActions'. 1513 postConfigActions.remove(function)
1516 _appliedConfigurableUsers_ =
False 1521 Call the apply method of all the ConfigurableUser instances respecting the 1522 dependencies. First the C.U.s that are not used by anybody, then the used 1523 ones, when they are not used anymore. 1526 global _appliedConfigurableUsers_, postConfigActions
1527 if _appliedConfigurableUsers_:
1529 _appliedConfigurableUsers_ =
True 1531 def applicableConfUsers():
1533 Generator returning all the configurables that can be applied in the 1534 order in which they can be applied. 1546 yield (c
for c
in Configurable.allConfigurables.values()
1547 if c.isApplicable()).next()
1549 debugApplyOrder =
'GAUDI_DUBUG_CONF_USER' in os.environ
1550 for c
in applicableConfUsers():
1552 log.info(
"applying configuration of %s", c.name())
1554 sys.stderr.write(
'applying %r' % c)
1555 c.__apply_configuration__()
1558 log.info(
"skipping configuration of %s", c.name())
1560 if hasattr(c,
"__detach_used__"):
1566 c
for c
in Configurable.allConfigurables.values()
if 1567 hasattr(c,
'__apply_configuration__')
and c._enabled
and not c._applied
1571 raise Error(
"Detected loop in the ConfigurableUser" 1572 " dependencies: %r" % [c.name()
for c
in leftConfUsers])
1575 unknown = set(Configurable.allConfigurables)
1579 log.debug(
'new configurable created automatically: %s', k)
1581 Configurable.allConfigurables[k].
properties()
1585 for action
in postConfigActions:
1591 Obsolete (buggy) implementation of applyConfigurableUsers(), kept to provide 1592 backward compatibility for configurations that where relying (implicitly) on 1593 bug #103803, or on a specific (non guaranteed) order of execution. 1595 @see applyConfigurableUsers() 1598 global _appliedConfigurableUsers_, postConfigActions
1599 if _appliedConfigurableUsers_:
1601 _appliedConfigurableUsers_ =
True 1603 debugApplyOrder =
'GAUDI_DUBUG_CONF_USER' in os.environ
1605 c
for c
in Configurable.allConfigurables.values()
1606 if hasattr(c,
"__apply_configuration__")
1609 while applied
and confUsers:
1613 if hasattr(c,
"__users__")
and c.__users__:
1614 newConfUsers.append(c)
1619 enabled = (
not hasattr(c,
"_enabled"))
or c._enabled
1621 log.info(
"applying configuration of %s", c.name())
1623 sys.stderr.write(
'applying %r' % c)
1624 c.__apply_configuration__()
1627 log.info(
"skipping configuration of %s", c.name())
1628 if hasattr(c,
"__detach_used__"):
1631 confUsers = newConfUsers
1634 raise Error(
"Detected loop in the ConfigurableUser " 1635 " dependencies: %r" % [c.name()
for c
in confUsers])
1638 unknown = set(Configurable.allConfigurables)
1642 log.debug(
'new configurable created automatically: %s', k)
1644 Configurable.allConfigurables[k].
properties()
1648 for action
in postConfigActions:
1654 Function to select all and only the configurables that have to be used in 1655 GaudiPython.AppMgr constructor. 1656 This is needed because in Athena the implementation have to be different (the 1657 configuration is used in a different moment). 1660 k
for k, v
in Configurable.allConfigurables.items()
1661 if v.getGaudiType() !=
"User" 1667 Clean up all configurations and configurables. 1669 for c
in Configurable.allConfigurables.values():
1670 c.__class__.configurables.clear()
1671 Configurable.allConfigurables.clear()
1674 ConfigurableGeneric.configurables.clear()
1675 from ProcessJobOptions
import _included_files
1678 for file
in _included_files:
1679 dirname, basname = os.path.split(file)
1680 basname, ext = os.path.splitext(basname)
1681 if basname
in sys.modules:
1682 del sys.modules[basname]
1683 _included_files.clear()
1692 return self.
stack[-1]
1700 name = prefix + str(cnt)
1701 while name
in allConfigurables:
1703 name = prefix + str(cnt)
1707 from Configurables
import GaudiSequencer
1712 if visitee
in (CFTrue, CFFalse):
1713 stack.append(self.
_newSeq(Invert=visitee
is CFFalse))
1714 elif isinstance(visitee, (ControlFlowLeaf, ConfigurableAlgorithm)):
1715 stack.append(visitee)
1716 elif isinstance(visitee, (OrNode, AndNode, OrderedNode)):
1721 ModeOR=isinstance(visitee, OrNode),
1722 ShortCircuit=
not isinstance(visitee, OrderedNode),
1725 elif isinstance(visitee, ignore):
1726 if hasattr(stack[-1],
'IgnoreFilterPassed'):
1727 stack[-1].IgnoreFilterPassed =
True 1731 Members=[stack.pop()], IgnoreFilterPassed=
True))
1732 elif isinstance(visitee, InvertNode):
1733 if hasattr(stack[-1],
'Invert'):
1734 stack[-1].Invert =
True 1736 stack.append(self.
_newSeq(Members=[stack.pop()], Invert=
True))
1741 Convert a control flow expression to nested GaudiSequencers. 1743 if not isinstance(expression, ControlFlowNode):
1744 raise ValueError(
'ControlFlowNode instance expected, got %s' %
1745 type(expression).__name__)
1747 expression.visitNode(visitor)
1748 return visitor.sequence
1753 Helper class to use a ControlFlowNode as an algorithm configurable 1760 if name
in Configurable.allConfigurables:
1761 instance = Configurable.allConfigurables[name]
1762 assert type(instance)
is cls, \
1763 (
'trying to reuse {0!r} as name of a {1} instance while it''s ' 1764 'already used for an instance of {2}').
format(
1767 type(instance).__name__)
1770 instance = super(SuperAlgorithm, cls).
__new__(cls, name, **kwargs)
1771 Configurable.allConfigurables[name] = instance
1778 setattr(self, key, kwargs[key])
1803 Instantiate and algorithm of type 'typ' with a name suitable for use 1804 inside a SuperAlgorithm. 1806 name =
'{0}_{1}'.
format(self.
name, kwargs.pop(
'name', typ.getType()))
1807 return typ(name, **kwargs)
1810 raise NotImplementedError()
1817 self.
graph.visitNode(visitor)
1820 super(SuperAlgorithm, self).
__setattr__(name, value)
1821 if name
in (
'_name',
'graph'):
1825 class PropSetter(object):
1826 def enter(self, node):
1828 setattr(node, name, value)
1829 except (ValueError, AttributeError):
1833 def leave(self, node):
1836 self._visitSubNodes(PropSetter())
def __init__(self, name=None, **kwargs)
def getNeededConfigurables()
def __deepcopy__(self, memo)
def propagateProperty(self, name, others=None, force=True)
def setParent(self, parentName)
def __apply_configuration__(self)
dictionary allConfigurables
def __deepcopy__(self, memo)
def __detach_used__(self)
def __setstate__(self, dict)
GAUDI_API std::string format(const char *,...)
MsgStream format utility "a la sprintf(...)".
list __queried_configurables__
def _printHeader(indentStr, title)
def _getUniqueName(self, prefix)
def __new__(cls, name=None, **kwargs)
dictionary configurableServices
def __addPassiveUseOf(self, other)
def clone(self, name=None, **kwargs)
def hasParent(self, parent)
def appendPostConfigAction(function)
def __new__(cls, *args, **kwargs)
Sequencer for executing several algorithms, stopping when one is faulty.
def __init__(self, name=DefaultName)
def getPropertiesWithDescription(self)
def addTool(self, tool, name=None)
def __setupDefaults(self)
def makeSequences(expression)
def _printFooter(indentStr, title)
def _visitSubNodes(self, visitor)
def applyConfigurableUsers()
def _instanceName(self, cls)
def setProp(self, name, value)
list __used_configurables__
def __deepcopy__(self, memo)
MsgStream & hex(MsgStream &log)
EventIDBase max(const EventIDBase &lhs, const EventIDBase &rhs)
def __init__(self, name=Configurable.DefaultName, _enabled=True, **kwargs)
def __init__(self, name=Configurable.DefaultName)
def __getattr__(self, attr)
def __init__(self, name=Configurable.DefaultName)
def __init__(self, propname)
def __deepcopy__(self, memo)
def copyChildAndSetParent(self, cfg, parent)
def __setattr__(self, name, value)
def __addActiveUseOf(self, other)
def setDefaults(cls, handle)
def __iadd__(self, configs, descr=None)
def isPropertySet(self, name)
def toStringProperty(self)
def getDefaultProperties(cls)
def __rshift__(self, rhs)
def __delattr__(self, attr)
def getUsedInstance(self, name)
def _makeAlg(self, typ, **kwargs)
def copyChild(self, child)
def applyConfigurableUsers_old()
def __setattr__(self, name, value)
def getFullJobOptName(self)
auto get(const Handle &handle, const Algo &, const EventContext &) -> decltype(details::deref(handle.get()))
def __set__(self, obj, value)
def removePostConfigAction(function)
def __str__(self, indent=0, headerLastIndentUnit=indentUnit)
bool _configurationLocked
def __setupServices(self)
def _isInSetDefaults(self)
def __init__(self, name=Configurable.DefaultName)
def _newSeq(self, prefix='seq_', **kwargs)
def getDefaultProperty(cls, name)
def toStringProperty(self)
def propagateProperties(self, names=None, others=None, force=True)
def __get__(self, obj, type=None)
def _visitSubNodes(self, visitor)
def copyChild(self, child)
def getValuedProperties(self)
def __setattr__(self, name, value)
def isApplicable(self)
rep += v.__str__( indent + 1 ) + os.linesep elif isinstance(v,GaudiHandleArray): for vi in v: if isin...
def visitNode(self, visitor)