ATLAS Offline Software
Loading...
Searching...
No Matches
python.Configurable.ConfigurableService Class Reference
Inheritance diagram for python.Configurable.ConfigurableService:
Collaboration diagram for python.Configurable.ConfigurableService:

Public Member Functions

 __deepcopy__ (self, memo)
 copyChild (self, child)
 getHandle (self)
 getGaudiType (self)
 getGaudiHandle (self)
 toStringProperty (self)
 __new__ (cls, *args, **kwargs)
 __getstate__ (self)
 __setstate__ (self, dct)
 __getnewargs__ (self)
 __len__ (self)
 __iter__ (self)
 __iadd__ (self, configs, descr=None, index=None)
 __getattr__ (self, attr)
 __delattr__ (self, attr)
 remove (self, items)
 removeAll (self)
 clone (self, newname)
 setParent (self, parentName)
 getParent (self)
 hasParent (self, parent)
 copyChildAndSetParent (self, cfg, parent)
 getChildren (self)
 overwriteChild (self, idx, newChild)
 getAllChildren (self)
 getSequence (self)
 setup (self)
 lock (self)
 unlock (self)
 isLocked (self)
 isPrinting (self)
 getProperties (self)
 getValuedProperties (self)
 properties (self)
 getDefaultProperties (cls)
 getDefaultProperty (cls, name)
 getType (cls)
 getName (self)
 name (self)
 getJobOptName (self)
 isPublic (self)
 getFullName (self)
 getFullJobOptName (self)
 getPrintTitle (self)
 getTitleName (self)
 setDefaults (cls, handle)
 __repr__ (self)
 __str__ (self, indent=0, headerLastIndentUnit=indentUnit)
 getFlattenedProperties (self)
 getStrDescriptor (self)
 __eq__ (self, rhs)
 __ne__ (self, rhs)
 __bool__ (self)
 __call__ (cls, *args, **kwargs)

Static Public Attributes

 propertyNoValue
str indentUnit = '| '
int printHeaderWidth = 100
int printHeaderPre = 5
 allConfigurables = weakref.WeakValueDictionary()

Protected Member Functions

 _isInSetDefaults (self)

Static Protected Member Functions

 _printHeader (indentStr, title)
 _printFooter (indentStr, title)

Protected Attributes

 _name = self.__class__.DefaultedName
int _flags = 0

Static Protected Attributes

int _fInSetDefaults = 0x01
int _fIsLocked = 0x02
int _fIsPrinting = 0x04
int _fInitOk = 0x08
int _fSetupOk = 0x10
int _printOnce = 0
bool _useGlobalInstances = True

Private Member Functions

 __setupDlls (self)
 __setupDefaults (self)

Private Attributes

 __name__
list __children = []
 __class__

Static Private Attributes

dict __slots__
 __hash__ = object.__hash__

Detailed Description

Definition at line 842 of file Configurable.py.

Member Function Documentation

◆ __bool__()

python.Configurable.Configurable.__bool__ ( self)
inherited

Definition at line 807 of file Configurable.py.

807 def __bool__ (self):
808 return True
809

◆ __call__()

python.ConfigurableMeta.ConfigurableMeta.__call__ ( cls,
* args,
** kwargs )
inherited
To Gaudi, any object with the same type/name is the same object. Hence,
   this is mimicked in the configuration: instantiating a new Configurable
   of a type with the same name will return the same instance.

Definition at line 95 of file ConfigurableMeta.py.

95 def __call__( cls, *args, **kwargs ):
96 """To Gaudi, any object with the same type/name is the same object. Hence,
97 this is mimicked in the configuration: instantiating a new Configurable
98 of a type with the same name will return the same instance."""
99
100 # Get the instance: `singleton' logic needs to be in __new__, not here,
101 # for compatibililty with pickling.)
102 cfg = cls.__new__( cls, *args, **kwargs )
103
104 # Initialize the object, if not done already.
105 if cfg and ( not hasattr(cfg, '_fInitOk') or not cfg._fInitOk ):
106 cls.__init__( cfg, *args, **kwargs )
107
108 return cfg

◆ __deepcopy__()

python.Configurable.ConfigurableService.__deepcopy__ ( self,
memo )

Definition at line 846 of file Configurable.py.

846 def __deepcopy__( self, memo ):
847 return self # services are always shared
848

◆ __delattr__()

python.Configurable.Configurable.__delattr__ ( self,
attr )
inherited

Definition at line 348 of file Configurable.py.

348 def __delattr__( self, attr ):
349 # remove as property, otherwise try as child
350 try:
351 # remove history etc., then reset to default (in case set before)
352 prop = self._properties[ attr ]
353 prop.__delete__( self )
354 prop.__set__( self, prop.default )
355 return # reaches here? was property: done now
356 except KeyError:
357 pass
358
359 # otherwise, remove child, if one is so named
360 for c in self.__children:
361 if c.getName() == attr:
362 self.__children.remove( c )
363
364 # potentially, there are left over caches (certain user derived classes)
365 try:
366 del self.__dict__[ attr ]
367 except (AttributeError,KeyError):
368 pass
369

◆ __eq__()

python.Configurable.Configurable.__eq__ ( self,
rhs )
inherited

Definition at line 790 of file Configurable.py.

790 def __eq__(self,rhs):
791 # Check identity first
792 if self is rhs: return True
793 # Avoid comparing against None...
794 if not rhs: return False
795 # Class check
796 if not isinstance(rhs,Configurable): return False
797 # Type/Name check
798 if self.getFullName() != rhs.getFullName(): return False
799 # If identical types and names, then go the whole hog and test children
800 # Could be sped up by testing property by property...
801 return self.getStrDescriptor() == rhs.getStrDescriptor()

◆ __getattr__()

python.Configurable.Configurable.__getattr__ ( self,
attr )
inherited

Definition at line 339 of file Configurable.py.

339 def __getattr__( self, attr ): # until ToolProperties exist ...
340 if attr[0] == "_":
341 return super( Configurable, self ).__getattribute__(attr)
342 for c in self.__children:
343 if c.getName() == attr:
344 return c
345
346 raise AttributeError( "'%s' object has no attribute '%s'" % (self.__class__,attr) )
347

◆ __getnewargs__()

python.Configurable.Configurable.__getnewargs__ ( self)
inherited

Definition at line 274 of file Configurable.py.

274 def __getnewargs__( self ):
275 return (self._name,)
276

◆ __getstate__()

python.Configurable.Configurable.__getstate__ ( self)
inherited

Definition at line 241 of file Configurable.py.

241 def __getstate__( self ):
242 d = {}
243 for name, proxy in self._properties.items():
244 try:
245 d[ name ] = proxy.__get__( self )
246 except AttributeError:
247 pass
248
249 d[ '_Configurable__children' ] = self.__children
250 d[ '_name' ] = self._name
251 if hasattr(self, '_jobOptName'):
252 d[ '_jobOptName' ] = self.getJobOptName()
253 d[ '_fIsLocked' ] = self.isLocked()
254
255 return d
256

◆ __iadd__()

python.Configurable.Configurable.__iadd__ ( self,
configs,
descr = None,
index = None )
inherited

Definition at line 301 of file Configurable.py.

301 def __iadd__( self, configs, descr = None, index = None ):
302 if self.isLocked():
303 raise RuntimeError( f"cannot add children to locked configurable {self.getJobOptName()}" )
304
305 if not type(configs) in (list,tuple):
306 configs = ( configs, )
307
308 joname = self.getJobOptName()
309
310 for cfg in configs:
311 # prevent type mismatches
312 if not isinstance( cfg, Configurable ):
313 raise TypeError( "'%s' is not a Configurable" % str(cfg) )
314
315 cc = self.copyChildAndSetParent( cfg, joname )
316
317 # filters dupes; usually "ok" (backdoor should catch them)
318 ccjo = cc.getJobOptName()
319 for c in self.__children:
320 if c.getJobOptName() == ccjo:
321 log.debug( 'attempt to add a duplicate (%s.%s) ... dupe ignored', joname or self.name(), ccjo )
322 break
323 else:
324 if index is None:
325 self.__children.append( cc )
326 else:
327 self.__children.insert( index, cc )
328
329 try:
330 if descr: # support for tool properties
331 descr.__set__( self, cc )
332 else:
333 setattr( self, cc.getName(), cc )
334 except AttributeError:
335 pass # to allow free addition of tools/subalgorithms
336
337 return self
338

◆ __iter__()

python.Configurable.Configurable.__iter__ ( self)
inherited

Definition at line 281 of file Configurable.py.

281 def __iter__( self ):
282 return iter( self.__children )
283

◆ __len__()

python.Configurable.Configurable.__len__ ( self)
inherited

Definition at line 278 of file Configurable.py.

278 def __len__( self ):
279 return len( self.__children )
280

◆ __ne__()

python.Configurable.Configurable.__ne__ ( self,
rhs )
inherited

Definition at line 802 of file Configurable.py.

802 def __ne__(self,rhs):
803 return (not self.__eq__(rhs))
804

◆ __new__()

python.Configurable.Configurable.__new__ ( cls,
* args,
** kwargs )
inherited
To Gaudi, any object with the same type/name is the same object. Hence,
   this is mimicked in the configuration: instantiating a new Configurable
   of a type with the same name will return the same instance.

Definition at line 89 of file Configurable.py.

89 def __new__ ( cls, *args, **kwargs ):
90 """To Gaudi, any object with the same type/name is the same object. Hence,
91 this is mimicked in the configuration: instantiating a new Configurable
92 of a type with the same name will return the same instance."""
93
94 # try to get the name of the Configurable (having a name is compulsory)
95 if 'name' in kwargs:
96 # simple keyword (by far the easiest)
97 name = kwargs[ 'name' ]
98 elif 'name' in cls.__init__.__code__.co_varnames:
99 # either positional in args, or default
100 index = list(cls.__init__.__code__.co_varnames).index( 'name' )
101 try:
102 # var names index is offset by one as __init__ is to be called with self
103 name = args[ index - 1 ]
104 except IndexError:
105 # retrieve default value, then
106 name = cls.__init__.__defaults__[ index - (len(args)+1) ]
107 else:
108 # positional index is assumed (will work most of the time)
109 try:
110 name = args[1] # '0' is for self
111 except (IndexError,TypeError):
112 raise TypeError( 'no "name" argument while instantiating "%s"' % cls.__name__ )
113
114 if name == Configurable.DefaultName:
115 # select either conventional name, or the type of the class
116 if hasattr( cls, 'DefaultedName' ):
117 name = cls.DefaultedName
118 else:
119 name = cls.getType()
120 elif not name or type(name) is not str:
121 # unnamed, highly specialized user code, etc. ... unacceptable
122 raise TypeError( 'could not retrieve name from %s.__init__ arguments' % cls.__name__ )
123
124 # close backdoor access to otherwise private subalgs/tools
125 if 0 <= name.find( '.' ):
126 raise NameError( '"%s": Gaudi name indexing with "." to private configurables not '
127 'allowed, as it leads to uncheckable backdoors' % name )
128
129 if 0 <= name.find( '/' ):
130 raise NameError( '"%s": type separator "/" no allowed in component name, '
131 'typename is derived from configurable instead' % name )
132
133 if cls._useGlobalInstances:
134 # ordinary recycle case
135 try:
136 conf = cls.configurables[ name ]
137
138 # initialize additional properties, if any
139 for n,v in kwargs.items():
140 try:
141 setattr( conf, n, v )
142 except AttributeError as originalAttributeError:
143
144 # now for a completely different can of worms ...
145 acceptableKeyWord = False
146
147 # little helper
148 def flat( classtree ):
149 if isinstance(classtree, (list, tuple)):
150 return [ j for i in classtree for j in flat( i ) ]
151 else:
152 return [ classtree ]
153
154 # the following attempts to figure out if the missing attribute
155 # is in fact an acceptable formal function argument to __init__,
156 import inspect
157 allclasses = flat( inspect.getclasstree( [ conf.__class__ ] ) )
158 for confklass in allclasses:
159 try:
160 # the following may result in the same init tried several
161 # times, but we shouldn't be in this loop too often anyway
162 if n in confklass.__init__.__code__.co_varnames:
163 acceptableKeyWord = True
164 break
165 except AttributeError:
166 pass
167
168 # raising here will break the usage of keywords in __init__, but
169 # there don't appear to be such cases in ATLAS yet ...
170 if not acceptableKeyWord:
171 raise originalAttributeError
172 return conf
173 except KeyError:
174 pass
175 else:
176 #Run 3 style config
177 #Uncomment this line to verify that RecExCommon doesn't use that
178 #print "Run 3 style config"
179 pass #end if not new configuration approach
180 # still here: create a new instance ...
181 conf = object.__new__( cls )
182
183 # ... python convention says to silently return, if __new__ fails ...
184 if conf is None:
185 return
186
187 # ... initialize it
188 cls.__init__( conf, *args, **kwargs )
189
190 # update normal, per-class cache
191 if cls._useGlobalInstances:
192 cls.configurables[ name ] = conf
193
194 # update generics super-cache
195 if name in cls.allConfigurables and conf.getType() != cls.allConfigurables[ name ].getType():
196 raise TypeError( 'attempt to redefine type of "%s" (was: %s, new: %s)' %
197 (name,cls.allConfigurables[ name ].getType(), conf.getType()) )
198 cls.allConfigurables[ name ] = conf
199
200 return conf
201
Definition index.py:1

◆ __repr__()

python.Configurable.Configurable.__repr__ ( self)
inherited

Definition at line 646 of file Configurable.py.

646 def __repr__( self ):
647 return '<%s at %s>' % (self.getFullJobOptName(),hex(id(self)))
648

◆ __setstate__()

python.Configurable.Configurable.__setstate__ ( self,
dct )
inherited

Definition at line 257 of file Configurable.py.

257 def __setstate__( self, dct ):
258 # flags are set to neutral, not from pickle except for lockedness
259 self._flags = 0
260 self._flags |= self._fInitOk
261 self._flags &= ~self._fInSetDefaults
262 if '_fIsLocked' in dct:
263 if dct[ '_fIsLocked' ]:
264 self._flags &= self._fIsLocked
265 else:
266 self._flags &= ~self._fIsLocked
267 del dct['_fIsLocked']
268 self._flags &= ~self._fIsPrinting
269 for (n, v) in dct.items():
270 setattr( self, n, v )
271
272 return
273

◆ __setupDefaults()

python.Configurable.Configurable.__setupDefaults ( self)
privateinherited

Definition at line 625 of file Configurable.py.

625 def __setupDefaults( self ):
626 # set handle defaults flags to inform __setattr__ that it is being
627 # called during setDefaults of the concrete Configurable
628 self._flags |= self._fInSetDefaults
629 self.setDefaults( self )
630 self._flags &= ~self._fInSetDefaults
631

◆ __setupDlls()

python.Configurable.Configurable.__setupDlls ( self)
privateinherited

Definition at line 614 of file Configurable.py.

614 def __setupDlls( self ):
615 dlls = self.getDlls()
616 if not dlls:
617 dlls = []
618 elif isinstance(dlls, str):
619 dlls = [ dlls ]
620
621 from AthenaCommon.AppMgr import theApp
622 dlls = filter( lambda d: d not in theApp.Dlls, dlls )
623 if dlls: theApp.Dlls += dlls
624

◆ __str__()

python.Configurable.Configurable.__str__ ( self,
indent = 0,
headerLastIndentUnit = indentUnit )
inherited

Definition at line 649 of file Configurable.py.

649 def __str__( self, indent = 0, headerLastIndentUnit=indentUnit ):
650 def _sorted_repr_set(value):
651 """Helper to print sorted set representation"""
652 return "{" + repr(sorted(value))[1:-1] + "}" if value else "set()"
653
654 indentStr = indent*Configurable.indentUnit
655 # print header
656 title = self.getPrintTitle()
657
658 # if run under WARNING and hight only, stick with title
659 if logging.WARNING <= log.level:
660 if not Configurable._printOnce:
661 Configurable._printOnce = 1
662 return "Reduced Configurable printout; change log level for more details, e.g.:\n import AthenaCommon.Configurable as Configurable\n Configurable.log.setLevel( INFO )\n" + title
663 else:
664 return title
665
666 # avoid auto-setting private AlgTools while doing printout
667 self._flags |= self._fIsPrinting
668
669 # print line to easily see start-of-configurable
670 if indent > 0:
671 headerIndent = (indent-1)*Configurable.indentUnit + headerLastIndentUnit
672 else:
673 headerIndent = ''
674 rep = Configurable._printHeader( headerIndent, title )
675 rep += os.linesep
676 # print own properties
677 props = self.getProperties()
678 defs = self.getDefaultProperties()
679 if not props:
680 rep += indentStr + '|-<no properties>' + os.linesep
681 else:
682 # get property name with
683 nameWidth = 0
684 for p in props.keys():
685 nameWidth=max(nameWidth,len(p))
686 propNames = sorted(props.keys())
687 for p in propNames:
688 v = props[p]
689 # start with indent and property name
690 prefix = indentStr + '|-%-*s' % (nameWidth,p)
691 # add memory address for debugging (not for defaults)
692 if log.isEnabledFor( logging.DEBUG ):
693 if v != Configurable.propertyNoValue:
694 address = ' @%11s' % hex(id(v))
695 else:
696 address = 13*' '
697 prefix += address
698 # add value and default
699 default = defs.get(p)
700
701 if not isinstance(v,MutableSequence) and v == Configurable.propertyNoValue:
702 # show default value as value, and no extra 'default'
703 strVal = repr(default)
704 strDef = None
705 else:
706 # convert configurable to handle
707 if isinstance(v,Configurable):
708 vv = v.getGaudiHandle()
709 else:
710 vv = v
711 if isinstance(vv,(GaudiHandles.GaudiHandle,
712 GaudiHandles.GaudiHandleArray,
713 DataHandle.DataHandle)):
714 strVal = repr(vv)
715 strDef = repr(default.toStringProperty())
716 if strDef == repr(vv.toStringProperty()):
717 strDef = None
718 elif isinstance(vv, set):
719 strVal = _sorted_repr_set(vv)
720 strDef = _sorted_repr_set(default)
721 else:
722 strVal = repr(vv)
723 strDef = repr(default)
724 # add the value
725 line = prefix + ' = ' + strVal
726 # add default if present
727 if strDef is not None:
728 # put default on new line if too big
729 if len(line) + len(strDef) > Configurable.printHeaderWidth:
730 line += os.linesep + indentStr + '| ' + (len(prefix)-len(indentStr)-3)*' '
731 line += ' (default: %s)' % (strDef,)
732 # add the line to the total string
733 rep += line + os.linesep
734
735 # print configurables + their properties, or loop over sequence
736 childNotToSort = []
737 childToSort = []
738 for c in self.getAllChildren():
739 if isinstance(c, ConfigurableAlgorithm): childNotToSort.append(c)
740 else: childToSort.append(c)
741 # sort the non-algs
742 childToSort.sort(key=lambda x : x.getName())
743 for cfg in childToSort + childNotToSort:
744 rep += cfg.__str__( indent + 1, '|=' ) + os.linesep
745
746 # print line to easily see end-of-configurable. Note: No linesep!
747 rep += Configurable._printFooter( indentStr, title )
748
749 self._flags &= ~self._fIsPrinting
750 return rep
751
752 # hash method for set/dict operations
753 # first attempt, assuming need to recurse into child properties
754 # if too much overhead, could attempt to cache with python
755 # properties, but hard to propagate changes upwards to parents
756
#define max(a, b)
Definition cfImp.cxx:41

◆ _isInSetDefaults()

python.Configurable.Configurable._isInSetDefaults ( self)
protectedinherited

Definition at line 611 of file Configurable.py.

611 def _isInSetDefaults( self ):
612 return self._flags & self._fInSetDefaults
613

◆ _printFooter()

python.Configurable.Configurable._printFooter ( indentStr,
title )
staticprotectedinherited

Definition at line 640 of file Configurable.py.

640 def _printFooter( indentStr, title ):
641 preLen = Configurable.printHeaderPre
642 postLen = Configurable.printHeaderWidth - preLen - 12 - len(title)# - len(indentStr)
643 postLen = max(preLen,postLen)
644 return indentStr + '\\%s (End of %s) %s' % (preLen*'-',title,postLen*'-')
645

◆ _printHeader()

python.Configurable.Configurable._printHeader ( indentStr,
title )
staticprotectedinherited

Definition at line 633 of file Configurable.py.

633 def _printHeader( indentStr, title ):
634 preLen = Configurable.printHeaderPre
635 postLen = Configurable.printHeaderWidth - preLen - 3 - len(title)# - len(indentStr)
636 postLen = max(preLen,postLen)
637 return indentStr + '/%s %s %s' % (preLen*'*',title,postLen*'*')
638

◆ clone()

python.Configurable.Configurable.clone ( self,
newname )
inherited

Definition at line 380 of file Configurable.py.

380 def clone( self, newname ):
381 if newname == self.getName():
382 log.error( 'not cloning %s, because new name given is same as old name', self.getName() )
383 return None
384
385 return self.__class__( newname, **self.getValuedProperties() )
386

◆ copyChild()

python.Configurable.ConfigurableService.copyChild ( self,
child )

Reimplemented from python.Configurable.Configurable.

Definition at line 849 of file Configurable.py.

849 def copyChild( self, child ):
850 # Copy private tools but all else is shared
851 if isinstance(child, ConfigurableAlgTool) and not child.isPublic():
852 return copy.deepcopy( child )
853 else:
854 return child
855

◆ copyChildAndSetParent()

python.Configurable.Configurable.copyChildAndSetParent ( self,
cfg,
parent )
inherited

Definition at line 400 of file Configurable.py.

400 def copyChildAndSetParent(self,cfg,parent):
401 cc = self.copyChild( cfg )
402
403 if hasattr( cc, 'setParent' ) and parent:
404 cc.setParent( parent )
405
406 return cc
407

◆ getAllChildren()

python.Configurable.Configurable.getAllChildren ( self)
inherited
Get all (private) configurable children, both explicit ones (added with +=)
and the ones in the private GaudiHandle properties

Definition at line 414 of file Configurable.py.

414 def getAllChildren( self ):
415 """Get all (private) configurable children, both explicit ones (added with +=)
416 and the ones in the private GaudiHandle properties"""
417 childs = []
418 # add private configurable properties (also inside handles)
419 for proxy in self._properties.values():
420 try:
421 c = proxy.__get__( self )
422 except AttributeError:
423 pass
424 else:
425 if isinstance(c,Configurable) and not c.isPublic():
426 childs.append(c)
427 elif isinstance(c,GaudiHandles.GaudiHandle):
428 try:
429 conf = c.configurable
430 except AttributeError:
431 pass
432 else:
433 if not conf.isPublic():
434 childs.append(conf)
435 elif isinstance(c,GaudiHandles.GaudiHandleArray):
436 # only setup private arrays
437 if not c.isPublic():
438 for ci in c:
439 if isinstance(ci,Configurable):
440 childs.append(ci)
441 else:
442 try:
443 conf = ci.configurable
444 except AttributeError:
445 pass
446 else:
447 childs.append(conf)
448
449 # add explicit children
450 childs += self.__children
451 return childs
452

◆ getChildren()

python.Configurable.Configurable.getChildren ( self)
inherited

Definition at line 408 of file Configurable.py.

408 def getChildren( self ):
409 return self.__children[:] # read only
410

◆ getDefaultProperties()

python.Configurable.Configurable.getDefaultProperties ( cls)
inherited

Definition at line 544 of file Configurable.py.

544 def getDefaultProperties( cls ):
545
546 # user provided defaults
547 c = Configurable.DefaultCollector()
548 cls.setDefaults( c )
549
550 # defaults from C++
551 for k,v in cls._properties.items():
552 if k not in c.__dict__ and hasattr( v, 'default' ):
553 c.__dict__[ k ] = v.default
554
555 return c.__dict__
556

◆ getDefaultProperty()

python.Configurable.Configurable.getDefaultProperty ( cls,
name )
inherited

Definition at line 558 of file Configurable.py.

558 def getDefaultProperty( cls, name ):
559
560 # user provided defaults
561 c = Configurable.DefaultCollector()
562 cls.setDefaults( c )
563
564 if name in c.__dict__:
565 return c.__dict__[ name ]
566
567 # defaults from C++
568 try:
569 v = cls._properties[name]
570 if hasattr( v, 'default' ):
571 return v.default
572 except KeyError:
573 pass
574
575 return None
576

◆ getFlattenedProperties()

python.Configurable.Configurable.getFlattenedProperties ( self)
inherited

Definition at line 757 of file Configurable.py.

757 def getFlattenedProperties(self):
758 self._flags |= self._fIsPrinting
759 properties = self.getValuedProperties()
760 propstr = ""
761 for key,val in sorted(properties.items()):
762 if isinstance(val, (GaudiHandles.PublicToolHandle, GaudiHandles.PrivateToolHandle)):
763 propstr += val.getFullName()
764 elif isinstance(val,Configurable):
765 propstr += "({0}:{1})".format(key,val.getFlattenedProperties())
766 elif isinstance(val, (GaudiHandles.PublicToolHandleArray, GaudiHandles.PrivateToolHandleArray)):
767 for th in val:
768 # Handle ToolHandles that have just been set as strings(?)
769 if isinstance(th,Configurable):
770 propstr += "({0}:{1}".format(th.getFullName(), th.getFlattenedProperties())
771 else:
772 propstr += th.getFullName()
773 else:
774 propstr += "({0}:{1})".format(key,str(val))
775 self._flags &= ~self._fIsPrinting
776 return propstr
777

◆ getFullJobOptName()

python.Configurable.Configurable.getFullJobOptName ( self)
inherited

Definition at line 596 of file Configurable.py.

596 def getFullJobOptName( self ):
597 return "%s/%s" % (self.getType(),self.getJobOptName() or self.getName())
598

◆ getFullName()

python.Configurable.Configurable.getFullName ( self)
inherited

Definition at line 593 of file Configurable.py.

593 def getFullName( self ) :
594 return str( self.getType() + '/' + self.getName() )
595

◆ getGaudiHandle()

python.Configurable.ConfigurableService.getGaudiHandle ( self)

Definition at line 866 of file Configurable.py.

866 def getGaudiHandle( self ):
867 return GaudiHandles.ServiceHandle( self.toStringProperty() )
868

◆ getGaudiType()

python.Configurable.ConfigurableService.getGaudiType ( self)

Definition at line 863 of file Configurable.py.

863 def getGaudiType( self ):
864 return 'Service'
865

◆ getHandle()

python.Configurable.ConfigurableService.getHandle ( self)

Definition at line 856 of file Configurable.py.

856 def getHandle( self ):
857 try:
858 from GaudiPython.Bindings import iService
859 except ImportError:
860 from gaudimodule import iService
861 return iService( self._name )
862

◆ getJobOptName()

python.Configurable.Configurable.getJobOptName ( self)
inherited

Reimplemented in python.Configurable.ConfigurableAlgorithm, python.Configurable.ConfigurableAlgTool, and python.Configurable.ConfigurableAuditor.

Definition at line 586 of file Configurable.py.

586 def getJobOptName( self ): # full hierachical name
587 return self.getName()
588

◆ getName()

python.Configurable.Configurable.getName ( self)
inherited

Definition at line 580 of file Configurable.py.

580 def getName( self ):
581 return self._name
582

◆ getParent()

python.Configurable.Configurable.getParent ( self)
inherited

Reimplemented in python.Configurable.ConfigurableAlgTool.

Definition at line 394 of file Configurable.py.

394 def getParent( self ):
395 return ""
396

◆ getPrintTitle()

python.Configurable.Configurable.getPrintTitle ( self)
inherited

Reimplemented in python.Configurable.ConfigurableAlgTool.

Definition at line 599 of file Configurable.py.

599 def getPrintTitle(self):
600 return self.getGaudiType() + ' ' + self.getTitleName()
601

◆ getProperties()

python.Configurable.Configurable.getProperties ( self)
inherited

Definition at line 515 of file Configurable.py.

515 def getProperties( self ):
516 props = {}
517 for name, proxy in self._properties.items():
518 try:
519 props[ name ] = proxy.__get__( self )
520 except AttributeError:
521 props[ name ] = Configurable.propertyNoValue
522
523 return props
524

◆ getSequence()

python.Configurable.Configurable.getSequence ( self)
inherited

Definition at line 453 of file Configurable.py.

453 def getSequence( self ):
454 elems = []
455 for c in self.__children:
456 elems.append( c.getFullName() )
457 return elems
458

◆ getStrDescriptor()

python.Configurable.Configurable.getStrDescriptor ( self)
inherited

Definition at line 778 of file Configurable.py.

778 def getStrDescriptor(self):
779
780 descr = ""
781 if hasattr( self,"_name" ):
782 propstr = self.getFlattenedProperties()
783 descr = (self.getFullName(), propstr)
784 else: # Not yet initialised?
785 descr = self.getType()
786
787 return descr
788

◆ getTitleName()

python.Configurable.Configurable.getTitleName ( self)
inherited

Definition at line 602 of file Configurable.py.

602 def getTitleName( self ):
603 if log.isEnabledFor( logging.DEBUG ):
604 return self.getFullJobOptName()
605 else:
606 return self.getFullName()
607

◆ getType()

python.Configurable.Configurable.getType ( cls)
inherited

Reimplemented in python.AppMgr.AthServiceManager.

Definition at line 577 of file Configurable.py.

577 def getType( cls ):
578 return cls.__name__
579

◆ getValuedProperties()

python.Configurable.Configurable.getValuedProperties ( self)
inherited

Definition at line 525 of file Configurable.py.

525 def getValuedProperties( self ):
526 props = {}
527 for name, proxy in self._properties.items():
528 try:
529 value = proxy.__get__( self )
530 if hasattr(value, 'getFullName') :
531 value = value.getFullName()
532 elif type(value) is list and len(value) > 0 and hasattr(value[0], 'getFullName'):
533 value = [ i.getFullName() for i in value ]
534 props[ name ] = value
535 except AttributeError:
536 pass
537
538 return props
539

◆ hasParent()

python.Configurable.Configurable.hasParent ( self,
parent )
inherited

Reimplemented in python.Configurable.ConfigurableAlgTool.

Definition at line 397 of file Configurable.py.

397 def hasParent( self, parent ):
398 return False
399

◆ isLocked()

python.Configurable.Configurable.isLocked ( self)
inherited

Definition at line 507 of file Configurable.py.

507 def isLocked( self ):
508 # check whether this configurable is currently locked
509 return self._flags & self._fIsLocked
510

◆ isPrinting()

python.Configurable.Configurable.isPrinting ( self)
inherited

Definition at line 511 of file Configurable.py.

511 def isPrinting( self ):
512 # check whether this configurable is currently being printed (see PropertyProxy.py)
513 return self._flags & self._fIsPrinting
514

◆ isPublic()

python.Configurable.Configurable.isPublic ( self)
inherited

Reimplemented in python.Configurable.ConfigurableAlgTool.

Definition at line 589 of file Configurable.py.

589 def isPublic( self ):
590 return True
591

◆ lock()

python.Configurable.Configurable.lock ( self)
inherited

Definition at line 487 of file Configurable.py.

487 def lock( self ):
488 # prevent any further changes, unless unlocked
489 self._flags |= self._fIsLocked
490
491 # same for any of its private ToolHandle properties
492 for k, v in self.getProperties().items():
493 if isinstance( v, Configurable ):
494 v.lock()
495
496 # leave children alone ... most likely are public (and can't check otherwise)
497

◆ name()

python.Configurable.Configurable.name ( self)
inherited

Definition at line 583 of file Configurable.py.

583 def name( self ):
584 return self.getName()
585

◆ overwriteChild()

python.Configurable.Configurable.overwriteChild ( self,
idx,
newChild )
inherited

Definition at line 411 of file Configurable.py.

411 def overwriteChild( self, idx, newChild ):
412 self.__children[idx] = newChild
413

◆ properties()

python.Configurable.Configurable.properties ( self)
inherited

Definition at line 540 of file Configurable.py.

540 def properties( self ):
541 return self.getProperties() # compatibility
542

◆ remove()

python.Configurable.Configurable.remove ( self,
items )
inherited

Definition at line 370 of file Configurable.py.

370 def remove( self, items ):
371 if not isinstance(items, (list, tuple)):
372 items = [ items ]
373
374 self.__children = [ e for e in self.__children if e not in items ]
375

◆ removeAll()

python.Configurable.Configurable.removeAll ( self)
inherited

Definition at line 376 of file Configurable.py.

376 def removeAll( self ):
377 self.remove( self.__children )
378

◆ setDefaults()

python.Configurable.Configurable.setDefaults ( cls,
handle )
inherited

Definition at line 608 of file Configurable.py.

608 def setDefaults( cls, handle ):
609 pass
610

◆ setParent()

python.Configurable.Configurable.setParent ( self,
parentName )
inherited

Reimplemented in python.Configurable.ConfigurableAlgTool.

Definition at line 391 of file Configurable.py.

391 def setParent( self, parentName ):
392 pass
393

◆ setup()

python.Configurable.Configurable.setup ( self)
inherited

Reimplemented in python.AppMgr.AthServiceManager.

Definition at line 459 of file Configurable.py.

459 def setup( self ):
460 # make sure base class init has been called
461 if not hasattr(self,'_fInitOk') or not self._fInitOk:
462 # could check more, but this is the only explanation
463 raise TypeError("Configurable.__init__ not called in %s override" % self.__class__.__name__)
464
465 # setup self: this collects all values on the python side
466 self.__setupDlls()
467 self.__setupDefaults()
468
469 # setup children
470 for c in self.getAllChildren():
471 c.setup()
472
473 # now get handle to work with for moving properties into the catalogue
474 handle = self.getHandle()
475 if not handle:
476 log.debug( 'no handle for %s: not transporting properties', self._name )
477 return # allowed, done early
478
479 # pass final set of properties on to handle on the C++ side or JobOptSvc
480 for name in self._properties.keys():
481 if hasattr( self, name ): # means property has python-side value/default
482 setattr( handle, name, getattr(self,name) )
483
484 # for debugging purposes
485 self._flags |= self._fSetupOk
486
bool setup(asg::AnaToolHandle< Interface > &tool, const std::string &type, const std::vector< std::string > &config, const std::string &progressFile="")
mostly useful for athena, which will otherwise re-use the previous tool

◆ toStringProperty()

python.Configurable.ConfigurableService.toStringProperty ( self)

Definition at line 869 of file Configurable.py.

869 def toStringProperty( self ):
870 # called on conversion to a string property for the jocat
871 return self.getName()
872
873

◆ unlock()

python.Configurable.Configurable.unlock ( self)
inherited

Definition at line 498 of file Configurable.py.

498 def unlock( self ):
499 # allow again changes to be made
500 import sys, traceback
501 stack = traceback.extract_stack( sys._getframe(1), 1 )
502 log.warning( 'unlock() called on configurable "%s" in %s', self.getJobOptName(), stack[0][0] )
503 self._flags &= ~self._fIsLocked
504
505 # note that unlock() does not unlock the children; do that individually
506

Member Data Documentation

◆ __children

python.Configurable.Configurable.__children = []
privateinherited

Definition at line 212 of file Configurable.py.

◆ __class__

python.Configurable.Configurable.__class__
privateinherited

Definition at line 216 of file Configurable.py.

◆ __hash__

python.Configurable.Configurable.__hash__ = object.__hash__
staticprivateinherited

Definition at line 805 of file Configurable.py.

◆ __name__

python.Configurable.Configurable.__name__
privateinherited

Definition at line 112 of file Configurable.py.

◆ __slots__

dict python.Configurable.ConfigurableService.__slots__
staticprivate
Initial value:
= { 'OutputLevel' : 0, \
'AuditServices' : 0, 'AuditInitialize' : 0, 'AuditFinalize' : 0 }

Definition at line 843 of file Configurable.py.

◆ _fInitOk

int python.Configurable.Configurable._fInitOk = 0x08
staticprotectedinherited

Definition at line 69 of file Configurable.py.

◆ _fInSetDefaults

int python.Configurable.Configurable._fInSetDefaults = 0x01
staticprotectedinherited

Definition at line 66 of file Configurable.py.

◆ _fIsLocked

int python.Configurable.Configurable._fIsLocked = 0x02
staticprotectedinherited

Definition at line 67 of file Configurable.py.

◆ _fIsPrinting

int python.Configurable.Configurable._fIsPrinting = 0x04
staticprotectedinherited

Definition at line 68 of file Configurable.py.

◆ _flags

int python.Configurable.Configurable._flags = 0
protectedinherited

Definition at line 223 of file Configurable.py.

◆ _fSetupOk

int python.Configurable.Configurable._fSetupOk = 0x10
staticprotectedinherited

Definition at line 70 of file Configurable.py.

◆ _name

python.Configurable.Configurable._name = self.__class__.DefaultedName
protectedinherited

Definition at line 217 of file Configurable.py.

◆ _printOnce

int python.Configurable.Configurable._printOnce = 0
staticprotectedinherited

Definition at line 83 of file Configurable.py.

◆ _useGlobalInstances

bool python.Configurable.Configurable._useGlobalInstances = True
staticprotectedinherited

Definition at line 87 of file Configurable.py.

◆ allConfigurables

python.Configurable.Configurable.allConfigurables = weakref.WeakValueDictionary()
staticinherited

Definition at line 79 of file Configurable.py.

◆ indentUnit

str python.Configurable.Configurable.indentUnit = '| '
staticinherited

Definition at line 62 of file Configurable.py.

◆ printHeaderPre

int python.Configurable.Configurable.printHeaderPre = 5
staticinherited

Definition at line 64 of file Configurable.py.

◆ printHeaderWidth

int python.Configurable.Configurable.printHeaderWidth = 100
staticinherited

Definition at line 63 of file Configurable.py.

◆ propertyNoValue

python.Configurable.Configurable.propertyNoValue
staticinherited

Definition at line 61 of file Configurable.py.


The documentation for this class was generated from the following file: