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]
225 conf = cls.allConfigurables.get(name,
None)
or\
226 (spos < 0
and cls.allConfigurables.get(ti_name,
None))
or\
227 (spos > 0
and i_name == name[spos + 1:]
228 and cls.allConfigurables.get(i_name,
None))
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__)
385 self.__class__.__init__(newconf, self.
getName())
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',
420 self.__children.append(cc)
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:
478 self.__children.remove(c)
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))
535 return self.__tools.values()
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)
1032 return 'GenericComponent' 1043 super(ConfigurableGeneric, self).
__setattr__(name, value)
1047 if isinstance(value, Configurable):
1048 self.__dict__[name] = value
1052 if not name
in self._properties:
1054 self._properties[name].__set__(self, value)
1068 'AuditAlgorithms': 0,
1069 'AuditInitialize': 0,
1070 'AuditReinitialize': 0,
1078 super(ConfigurableAlgorithm, self).
__init__(name)
1098 elif rhs
is CFFalse:
1100 return AndNode(self, rhs)
1107 return OrNode(self, rhs)
1110 return InvertNode(self)
1113 return OrderedNode(self, rhs)
1124 return (repr(self) == repr(other))
1131 'AuditInitialize': 0,
1142 return iService(self.
_name)
1160 'AuditInitialize': 0,
1165 super(ConfigurableAlgTool, self).
__init__(name)
1166 if '.' not in self.
_name:
1170 name = name[name.find(
'/') + 1:]
1191 return pop + Configurable.getPrintTitle(self)
1200 if isinstance(c, ConfigurableAlgTool):
1201 c.setParent(parentName)
1205 name = name[name.rfind(
'.') + 1:]
1209 dot = self._jobOptName.rfind(
'.')
1216 return self._jobOptName.startswith(parent +
'.')
1225 return self._jobOptName.startswith(
'ToolSvc.')
1236 name = name[name.rfind(
'.') + 1:]
1237 return str(self.
getType() +
'/' + name)
1244 __slots__ = {
'_jobOptName': 0,
'OutputLevel': 0,
'Enable': 1}
1247 super(ConfigurableAuditor, self).
__init__(name)
1249 name = name[name.find(
'/') + 1:]
1270 "__used_instances__": [],
1282 __used_configurables__ = []
1285 __queried_configurables__ = []
1287 def __init__(self, name=Configurable.DefaultName, _enabled=True, **kwargs):
1288 super(ConfigurableUser, self).
__init__(name)
1289 for n, v
in kwargs.items():
1307 if type(used)
is tuple:
1308 used, used_name = used
1312 if type(used)
is str:
1313 used_class = confDbGetConfigurable(used)
1318 inst = used_class(name=used_name, _enabled=
False)
1319 except AttributeError:
1323 inst = used_class(name=used_name)
1327 if type(queried)
is str:
1328 queried = confDbGetConfigurable(used)
1329 inst = queried(_enabled=
False)
1330 except AttributeError:
1336 Declare that we are going to modify the Configurable 'other' in our 1337 __apply_configuration__. 1339 self.__used_instances__.append(other)
1340 if hasattr(other,
"__users__"):
1341 other.__users__.append(self)
1345 Declare that we are going to retrieve property values from the 1346 ConfigurableUser 'other' in our __apply_configuration__. 1348 if not isinstance(other, ConfigurableUser):
1350 "'%s': Cannot make passive use of '%s', it is not a ConfigurableUser" 1351 % (self.
name(), other.name()))
1352 other.__addActiveUseOf(self)
1365 Remove this ConfigurableUser instance from the users list of the used 1371 used.__users__.remove(self)
1375 Propagate the property 'name' (if set) to other configurables (if possible). 1378 propagate to all the entries in __used_configurables__ 1379 a configurable instance: 1380 propagate only to it 1381 list of configurable instances: 1382 propagate to all of them. 1386 - if the local property is set, the other property will be overwritten 1387 - local property not set and other set => keep other 1388 - local property not set and other not set => overwrite the default for 1389 ConfigurableUser instances and set the property for Configurables 1394 elif type(others)
not in [list, tuple]:
1400 for other
in [o
for o
in others
if name
in o.__slots__]:
1403 if other.isPropertySet(name):
1405 "Property '%(prop)s' is set in both '%(self)s' and '%(other)s', using '%(self)s.%(prop)s'" 1407 "self": self.
name(),
1408 "other": other.name(),
1411 other.setProp(name, value)
1413 elif not other.isPropertySet(name):
1414 if isinstance(other, ConfigurableUser):
1415 otherType =
type(other._properties[name].getDefault())
1416 other._properties[name].setDefault(value)
1417 if otherType
in [list, dict]:
1420 other.setProp(name, otherType(value))
1422 other.setProp(name, value)
1427 Call propagateProperty for each property listed in 'names'. 1428 If 'names' is None, all the properties are propagated. 1432 names = [p
for p
in self.
__slots__ if not p.startswith(
"_")]
1438 Function to be overridden to convert the high level configuration into a 1440 The default implementation calls applyConf, which is the method defined 1441 in some ConfigurableUser implementations. 1447 Function to be overridden to convert the high level configuration into a 1454 Function used to define the name of the private instance of a given class 1456 This method is used when the __used_configurables_property__ declares the 1457 need of a private used configurable without specifying the name. 1459 if type(cls)
is str:
1462 clName = cls.__name__
1463 return "%s_%s" % (self.name(), clName)
1467 Return the used instance with a given name. 1470 if i.name() == name:
1471 if hasattr(i,
"_enabled"):
1476 raise KeyError(name)
1480 Return True is the instance can be "applied". 1486 postConfigActions = []
1491 Add a new callable ('function') to the list of post-configuration actions. 1492 If the callable is already in the list, it is moved to the end of the list. 1493 The list is directly accessible as 'GaudiKernel.Configurable.postConfigActions'. 1496 postConfigActions.remove(function)
1499 postConfigActions.append(function)
1504 Remove a callable from the list of post-config actions. 1505 The list is directly accessible as 'GaudiKernel.Configurable.postConfigActions'. 1507 postConfigActions.remove(function)
1510 _appliedConfigurableUsers_ =
False 1515 Call the apply method of all the ConfigurableUser instances respecting the 1516 dependencies. First the C.U.s that are not used by anybody, then the used 1517 ones, when they are not used anymore. 1520 global _appliedConfigurableUsers_, postConfigActions
1521 if _appliedConfigurableUsers_:
1523 _appliedConfigurableUsers_ =
True 1525 def applicableConfUsers():
1527 Generator returning all the configurables that can be applied in the 1528 order in which they can be applied. 1540 yield (c
for c
in Configurable.allConfigurables.values()
1541 if c.isApplicable()).next()
1543 debugApplyOrder =
'GAUDI_DUBUG_CONF_USER' in os.environ
1544 for c
in applicableConfUsers():
1546 log.info(
"applying configuration of %s", c.name())
1548 sys.stderr.write(
'applying %r' % c)
1549 c.__apply_configuration__()
1552 log.info(
"skipping configuration of %s", c.name())
1554 if hasattr(c,
"__detach_used__"):
1560 c
for c
in Configurable.allConfigurables.values()
if 1561 hasattr(c,
'__apply_configuration__')
and c._enabled
and not c._applied
1565 raise Error(
"Detected loop in the ConfigurableUser" 1566 " dependencies: %r" % [c.name()
for c
in leftConfUsers])
1569 unknown = set(Configurable.allConfigurables)
1573 log.debug(
'new configurable created automatically: %s', k)
1575 Configurable.allConfigurables[k].
properties()
1579 for action
in postConfigActions:
1585 Obsolete (buggy) implementation of applyConfigurableUsers(), kept to provide 1586 backward compatibility for configurations that where relying (implicitly) on 1587 bug #103803, or on a specific (non guaranteed) order of execution. 1589 @see applyConfigurableUsers() 1592 global _appliedConfigurableUsers_, postConfigActions
1593 if _appliedConfigurableUsers_:
1595 _appliedConfigurableUsers_ =
True 1597 debugApplyOrder =
'GAUDI_DUBUG_CONF_USER' in os.environ
1599 c
for c
in Configurable.allConfigurables.values()
1600 if hasattr(c,
"__apply_configuration__")
1603 while applied
and confUsers:
1607 if hasattr(c,
"__users__")
and c.__users__:
1608 newConfUsers.append(c)
1613 enabled = (
not hasattr(c,
"_enabled"))
or c._enabled
1615 log.info(
"applying configuration of %s", c.name())
1617 sys.stderr.write(
'applying %r' % c)
1618 c.__apply_configuration__()
1621 log.info(
"skipping configuration of %s", c.name())
1622 if hasattr(c,
"__detach_used__"):
1625 confUsers = newConfUsers
1628 raise Error(
"Detected loop in the ConfigurableUser " 1629 " dependencies: %r" % [c.name()
for c
in confUsers])
1632 unknown = set(Configurable.allConfigurables)
1636 log.debug(
'new configurable created automatically: %s', k)
1638 Configurable.allConfigurables[k].
properties()
1642 for action
in postConfigActions:
1648 Function to select all and only the configurables that have to be used in 1649 GaudiPython.AppMgr constructor. 1650 This is needed because in Athena the implementation have to be different (the 1651 configuration is used in a different moment). 1654 k
for k, v
in Configurable.allConfigurables.items()
1655 if v.getGaudiType() !=
"User" 1661 Clean up all configurations and configurables. 1663 for c
in Configurable.allConfigurables.values():
1664 c.__class__.configurables.clear()
1665 Configurable.allConfigurables.clear()
1668 ConfigurableGeneric.configurables.clear()
1669 from ProcessJobOptions
import _included_files
1672 for file
in _included_files:
1673 dirname, basname = os.path.split(file)
1674 basname, ext = os.path.splitext(basname)
1675 if basname
in sys.modules:
1676 del sys.modules[basname]
1677 _included_files.clear()
1686 return self.
stack[-1]
1694 name = prefix + str(cnt)
1695 while name
in allConfigurables:
1697 name = prefix + str(cnt)
1701 from Configurables
import GaudiSequencer
1706 if visitee
in (CFTrue, CFFalse):
1707 stack.append(self.
_newSeq(Invert=visitee
is CFFalse))
1708 elif isinstance(visitee, (ControlFlowLeaf, ConfigurableAlgorithm)):
1709 stack.append(visitee)
1710 elif isinstance(visitee, (OrNode, AndNode, OrderedNode)):
1715 ModeOR=isinstance(visitee, OrNode),
1716 ShortCircuit=
not isinstance(visitee, OrderedNode),
1719 elif isinstance(visitee, ignore):
1720 if hasattr(stack[-1],
'IgnoreFilterPassed'):
1721 stack[-1].IgnoreFilterPassed =
True 1725 Members=[stack.pop()], IgnoreFilterPassed=
True))
1726 elif isinstance(visitee, InvertNode):
1727 if hasattr(stack[-1],
'Invert'):
1728 stack[-1].Invert =
True 1730 stack.append(self.
_newSeq(Members=[stack.pop()], Invert=
True))
1735 Convert a control flow expression to nested GaudiSequencers. 1737 if not isinstance(expression, ControlFlowNode):
1738 raise ValueError(
'ControlFlowNode instance expected, got %s' %
1739 type(expression).__name__)
1741 expression.visitNode(visitor)
1742 return visitor.sequence
1747 Helper class to use a ControlFlowNode as an algorithm configurable 1754 if name
in Configurable.allConfigurables:
1755 instance = Configurable.allConfigurables[name]
1756 assert type(instance)
is cls, \
1757 (
'trying to reuse {0!r} as name of a {1} instance while it''s ' 1758 'already used for an instance of {2}').
format(
1761 type(instance).__name__)
1764 instance = super(SuperAlgorithm, cls).
__new__(cls, name, **kwargs)
1765 Configurable.allConfigurables[name] = instance
1772 setattr(self, key, kwargs[key])
1796 Instantiate and algorithm of type 'typ' with a name suitable for use 1797 inside a SuperAlgorithm. 1799 name =
'{0}_{1}'.
format(self.
name, kwargs.pop(
'name', typ.getType()))
1800 return typ(name, **kwargs)
1803 raise NotImplementedError()
1810 self.graph.visitNode(visitor)
1813 super(SuperAlgorithm, self).
__setattr__(name, value)
1814 if name
in (
'_name',
'graph'):
1818 class PropSetter(object):
1819 def enter(self, node):
1821 setattr(node, name, value)
1822 except (ValueError, AttributeError):
1826 def leave(self, node):
1829 self._visitSubNodes(PropSetter())
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 _newSeq(self, prefix='seq_', kwargs)
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 __init__(self, name=Configurable.DefaultName, _enabled=True, kwargs)
dictionary configurableServices
def __addPassiveUseOf(self, other)
def __new__(cls, args, kwargs)
def hasParent(self, parent)
def __init__(self, name=None, kwargs)
def appendPostConfigAction(function)
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 _makeAlg(self, typ, kwargs)
def _visitSubNodes(self, visitor)
def applyConfigurableUsers()
def clone(self, name=None, kwargs)
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)
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 __new__(cls, name=None, kwargs)
def getDefaultProperties(cls)
def __rshift__(self, rhs)
def __delattr__(self, attr)
def getUsedInstance(self, name)
def copyChild(self, child)
def applyConfigurableUsers_old()
def __setattr__(self, name, value)
def getFullJobOptName(self)
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 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)