ATLAS Offline Software
Loading...
Searching...
No Matches
python.AnaAlgorithmConfig.PrivateToolConfig Class Reference
Collaboration diagram for python.AnaAlgorithmConfig.PrivateToolConfig:

Public Member Functions

 __init__ (self, algorithm, prefix, type)
 __getattr__ (self, name)
 __setattr__ (self, key, value)
 __str__ (self)

Protected Attributes

 _algorithm = algorithm
 _prefix = prefix
 _type = type
dict _props = {}

Detailed Description

Standalone Private Tool Configuration

This class is used to mimic the behaviour of Athena tool configurable
classes. To be able to set the properties of private tools used by
dual-use algorithms in a way that's valid for both Athena and EventLoop.

Definition at line 278 of file AnaAlgorithmConfig.py.

Constructor & Destructor Documentation

◆ __init__()

python.AnaAlgorithmConfig.PrivateToolConfig.__init__ ( self,
algorithm,
prefix,
type )
Constructor for an private tool configuration object

Definition at line 286 of file AnaAlgorithmConfig.py.

286 def __init__( self, algorithm, prefix, type ):
287 """Constructor for an private tool configuration object
288 """
289
290 self._algorithm = algorithm
291 self._prefix = prefix
292 self._type = type
293 self._props = {}
294

Member Function Documentation

◆ __getattr__()

python.AnaAlgorithmConfig.PrivateToolConfig.__getattr__ ( self,
name )
Get a previously set property value from the configuration

This function allows us to retrieve the value of a tool property that
was already set for an algorithm's private tool, to possibly use it in
some configuration decisions in the Python code itself.

Keyword arguments:
  name -- The name of the property

Definition at line 295 of file AnaAlgorithmConfig.py.

295 def __getattr__( self, name ):
296 """Get a previously set property value from the configuration
297
298 This function allows us to retrieve the value of a tool property that
299 was already set for an algorithm's private tool, to possibly use it in
300 some configuration decisions in the Python code itself.
301
302 Keyword arguments:
303 name -- The name of the property
304 """
305
306 # Short-circuit internal/dunder attribute lookups, which are never
307 # properties (and would otherwise recurse if '_props' is missing):
308 if name.startswith( '_' ):
309 raise AttributeError( name )
310
311 # Fail if the property was not (yet) set:
312 if name not in self._props:
313 raise AttributeError(
314 f'Property "{name}" was not set on '
315 f'"{self._algorithm.type()}/{self._algorithm.name()}.{self._prefix}"' )
316
317 # Return the property value:
318 return self._props[ name ]
319

◆ __setattr__()

python.AnaAlgorithmConfig.PrivateToolConfig.__setattr__ ( self,
key,
value )
Set a tool property on an existing configuration object

This function allows us to set/override properties on a private tool
of an algorithm configuration object. Allowing for the following syntax:

   alg = ...
   alg.Tool.IntProperty = 66
   alg.Tool.FloatProperty = 3.141592
   alg.Tool.StringProperty = "Foo"

Keyword arguments:
  key   -- The key/name of the property
  value -- The value to set for the property

Definition at line 320 of file AnaAlgorithmConfig.py.

320 def __setattr__( self, key, value ):
321 """Set a tool property on an existing configuration object
322
323 This function allows us to set/override properties on a private tool
324 of an algorithm configuration object. Allowing for the following syntax:
325
326 alg = ...
327 alg.Tool.IntProperty = 66
328 alg.Tool.FloatProperty = 3.141592
329 alg.Tool.StringProperty = "Foo"
330
331 Keyword arguments:
332 key -- The key/name of the property
333 value -- The value to set for the property
334 """
335
336 # Private variables should be set directly:
337 if key[ 0 ] == '_':
338 return super().__setattr__( key, value )
339
340 # Construct the full name, used in the C++ code:
341 fullName = self._prefix + "." + key
342
343 # Set the property, and remember its value:
344 self._algorithm.setPropertyFromString( fullName,
345 stringPropValue( value ) )
346 self._props[ key ] = copy.deepcopy( value )
347

◆ __str__()

python.AnaAlgorithmConfig.PrivateToolConfig.__str__ ( self)
Print the private tool configuration in a user friendly way

This is just to help with debugging configurations, allowing
the user to get a nice printout of their job configuration.

Definition at line 348 of file AnaAlgorithmConfig.py.

348 def __str__( self ):
349 """Print the private tool configuration in a user friendly way
350
351 This is just to help with debugging configurations, allowing
352 the user to get a nice printout of their job configuration.
353 """
354
355 name = f'Private Tool {self._type}/{self._prefix}'
356 result = ' \n'
357 result += AnaAlgorithmConfig._printHeader( name )
358 result += '\n'
359 for key, value in sorted( self._props.items() ):
360 if isinstance( value, str ):
361 printedValue = f"'{value}'"
362 else:
363 printedValue = value
364 result += f"|- {key}: {indentBy( printedValue, '| ' )}\n"
365 result += AnaAlgorithmConfig._printFooter( name )
366 return result
367
368

Member Data Documentation

◆ _algorithm

python.AnaAlgorithmConfig.PrivateToolConfig._algorithm = algorithm
protected

Definition at line 290 of file AnaAlgorithmConfig.py.

◆ _prefix

python.AnaAlgorithmConfig.PrivateToolConfig._prefix = prefix
protected

Definition at line 291 of file AnaAlgorithmConfig.py.

◆ _props

dict python.AnaAlgorithmConfig.PrivateToolConfig._props = {}
protected

Definition at line 293 of file AnaAlgorithmConfig.py.

◆ _type

python.AnaAlgorithmConfig.PrivateToolConfig._type = type
protected

Definition at line 292 of file AnaAlgorithmConfig.py.


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