ATLAS Offline Software
Public Member Functions | Private Attributes | List of all members
python.PythonConfig.PrivateToolConfig Class Reference
Inheritance diagram for python.PythonConfig.PrivateToolConfig:
Collaboration diagram for python.PythonConfig.PrivateToolConfig:

Public Member Functions

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

Private Attributes

 _algorithm
 
 _prefix
 
 _type
 
 _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 303 of file PythonConfig.py.

Constructor & Destructor Documentation

◆ __init__()

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

Definition at line 311 of file PythonConfig.py.

311  def __init__( self, algorithm, prefix, type ):
312  """Constructor for an private tool configuration object
313  """
314 
315  self._algorithm = algorithm
316  self._prefix = prefix
317  self._type = type
318  self._props = {}
319 
320  pass
321 

Member Function Documentation

◆ __getattr__()

def python.PythonConfig.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 322 of file PythonConfig.py.

322  def __getattr__( self, name ):
323  """Get a previously set property value from the configuration
324 
325  This function allows us to retrieve the value of a tool property that
326  was already set for an algorithm's private tool, to possibly use it in
327  some configuration decisions in the Python code itself.
328 
329  Keyword arguments:
330  name -- The name of the property
331  """
332 
333  # Fail if the property was not (yet) set:
334  if not name in self._props:
335  raise AttributeError( 'Property "%s" was not set on "%s/%s.%s"' %
336  ( name, self._algorithm.type(),
337  self._algorithm.name(), self._prefix ) )
338 
339  # Return the property value:
340  return self._props[ name ]
341 

◆ __setattr__()

def python.PythonConfig.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 342 of file PythonConfig.py.

342  def __setattr__( self, key, value ):
343  """Set a tool property on an existing configuration object
344 
345  This function allows us to set/override properties on a private tool
346  of an algorithm configuration object. Allowing for the following syntax:
347 
348  alg = ...
349  alg.Tool.IntProperty = 66
350  alg.Tool.FloatProperty = 3.141592
351  alg.Tool.StringProperty = "Foo"
352 
353  Keyword arguments:
354  key -- The key/name of the property
355  value -- The value to set for the property
356  """
357 
358  # Private variables should be set directly:
359  if key[ 0 ] == '_':
360  return super( PrivateToolConfig, self ).__setattr__( key, value )
361 
362  # Construct the full name, used in the C++ code:
363  fullName = self._prefix + "." + key
364 
365  # Set the property, and remember its value:
366  self._algorithm.setPropertyFromString( fullName,
367  stringPropValue( value ) )
368  self._props[ key ] = copy.deepcopy( value )
369  pass
370 

◆ __str__()

def python.PythonConfig.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 371 of file PythonConfig.py.

371  def __str__( self ):
372  """Print the private tool configuration in a user friendly way
373 
374  This is just to help with debugging configurations, allowing
375  the user to get a nice printout of their job configuration.
376  """
377 
378  name = 'Private Tool %s/%s' % ( self._type, self._prefix )
379  result = ' \n'
380  result += PythonConfig._printHeader( name )
381  result += '\n'
382  for key, value in sorted( self._props.items() ):
383  if isinstance( value, str ):
384  printedValue = "'%s'" % value
385  else:
386  printedValue = value
387  pass
388  result += "|- %s: %s\n" % ( key, indentBy( printedValue, "| " ) )
389  pass
390  result += PythonConfig._printFooter( name )
391  return result
392 

Member Data Documentation

◆ _algorithm

python.PythonConfig.PrivateToolConfig._algorithm
private

Definition at line 315 of file PythonConfig.py.

◆ _prefix

python.PythonConfig.PrivateToolConfig._prefix
private

Definition at line 316 of file PythonConfig.py.

◆ _props

python.PythonConfig.PrivateToolConfig._props
private

Definition at line 318 of file PythonConfig.py.

◆ _type

python.PythonConfig.PrivateToolConfig._type
private

Definition at line 317 of file PythonConfig.py.


The documentation for this class was generated from the following file:
python.PythonConfig.stringPropValue
def stringPropValue(value)
Definition: PythonConfig.py:396
python.PythonConfig.indentBy
def indentBy(propValue, indent)
Definition: PythonConfig.py:406
DerivationFramework::TriggerMatchingUtils::sorted
std::vector< typename T::value_type > sorted(T begin, T end)
Helper function to create a sorted vector from an unsorted one.
name
std::string name
Definition: Control/AthContainers/Root/debug.cxx:195
TrigJetMonitorAlgorithm.items
items
Definition: TrigJetMonitorAlgorithm.py:79
python.processes.powheg.ZZ.ZZ.__init__
def __init__(self, base_directory, **kwargs)
Constructor: all process options are set here.
Definition: ZZ.py:18
python.CaloScaleNoiseConfig.type
type
Definition: CaloScaleNoiseConfig.py:78
python.PyAthenaComps.__setattr__
__setattr__
Definition: PyAthenaComps.py:41