| The Gaudi Framework v28r2p1 (f1a77ff4)

- Main Page
- Related Pages
- Modules
- Namespaces
- Classes
- Files

- Namespace List
- Namespace Members

Classes | Functions | Variables
GaudiKernel.Configurable Namespace Reference

## Classes
class | Configurable
class | ConfigurableAlgorithm
class | ConfigurableAlgTool
class | ConfigurableAuditor
class | ConfigurableGeneric
class | ConfigurableService
class | ConfigurableUser
class | CreateSequencesVisitor
class | DummyDescriptor
| classes for generic Gaudi component =========== More...
class | Error
class | PropertyReference
| Allow references to options as in old style. More...
class | SuperAlgorithm

## Functions
def | expandvars (data)
def | isApplicable (self)
| if isinstance(v,Configurable) and not v.isPublic(): rep += v.__str__( indent + 1 ) + os.linesep elif isinstance(v,GaudiHandleArray): for vi in v: if isinstance(vi,Configurable) and not vi.isPublic(): rep += vi.__str__( indent + 1 ) + os.linesep More...
def | appendPostConfigAction (function)
def | removePostConfigAction (function)
def | applyConfigurableUsers ()
def | applyConfigurableUsers_old ()
def | getNeededConfigurables ()
def | purge ()
def | makeSequences (expression)

## Variables
list | __all__
| data ------------------------------------------------------------------— More...
| log = logging.getLogger( 'Configurable' )
list | postConfigActions = []
bool | _appliedConfigurableUsers_ = False

## Function Documentation

def GaudiKernel.Configurable.appendPostConfigAction | ( |  | function | ) |

    Add a new callable ('function') to the list of post-configuration actions.
    If the callable is already in the list, it is moved to the end of the list.
    The list is directly accessible as 'GaudiKernel.Configurable.postConfigActions'.

Definition at line 1376 of file Configurable.py.

1376 def appendPostConfigAction(function):
1377 """
1378 Add a new callable ('function') to the list of post-configuration actions.
1379 If the callable is already in the list, it is moved to the end of the list.
1380 The list is directly accessible as 'GaudiKernel.Configurable.postConfigActions'.
1381 """
1382 try:
1383 postConfigActions.remove(function)
1384 except:
1385 pass
1386 postConfigActions.append(function)
GaudiKernel.Configurable.appendPostConfigAction
def appendPostConfigAction(function)
Definition: Configurable.py:1376

def GaudiKernel.Configurable.applyConfigurableUsers | ( |  | ) |

    Call the apply method of all the ConfigurableUser instances respecting the
    dependencies. First the C.U.s that are not used by anybody, then the used
    ones, when they are not used anymore.

Definition at line 1395 of file Configurable.py.

1395 def applyConfigurableUsers():
1396 """
1397 Call the apply method of all the ConfigurableUser instances respecting the
1398 dependencies. First the C.U.s that are not used by anybody, then the used
1399 ones, when they are not used anymore.
1400 """
1401 # Avoid double calls
1402 global _appliedConfigurableUsers_, postConfigActions
1403 if _appliedConfigurableUsers_:
1404 return
1405 _appliedConfigurableUsers_ = True
1406
1407 def applicableConfUsers():
1408 '''
1409 Generator returning all the configurables that can be applied in the
1410 order in which they can be applied.
1411 '''
1412 # This is tricky...
1413 # We keep on looking for the first configurable that can be applied.
1414 # When we cannot find any, 'next()' raises a StopIteration that is
1415 # propagated outside of the infinite loop and the function, then handled
1416 # correctly from outside (it is the exception that is raised when you
1417 # exit from a generator).
1418 # Checking every time the full list is inefficient, but it is the
1419 # easiest way to fix bug #103803.
1420 # <https://savannah.cern.ch/bugs/?103803>
1421 while True:
1422 yield (c for c in Configurable.allConfigurables.values()
1423 if c.isApplicable()).next()
1424
1425 debugApplyOrder = 'GAUDI_DUBUG_CONF_USER' in os.environ
1426 for c in applicableConfUsers():
1427 if c._enabled:
1428 log.info("applying configuration of %s", c.name())
1429 if debugApplyOrder:
1430 sys.stderr.write('applying %r' % c)
1431 c.__apply_configuration__()
1432 log.info(c)
1433 else:
1434 log.info("skipping configuration of %s", c.name())
1435 c._applied = True # flag the instance as already applied
1436 if hasattr(c, "__detach_used__"):
1437 # tells the used configurables that they are not needed anymore
1438 c.__detach_used__()
1439
1440 # check for dependency loops
1441 leftConfUsers = [c for c in Configurable.allConfigurables.values()
1442 if hasattr(c, '__apply_configuration__') and
1443 c._enabled and not c._applied]
1444 # if an enabled configurable has not been applied, there must be a dependency loop
1445 if leftConfUsers:
1446 raise Error("Detected loop in the ConfigurableUser"
1447 " dependencies: %r" % [ c.name()
1448 for c in leftConfUsers ])
1449 # ensure that all the Handles have been triggered
1450 known = set()
1451 unknown = set(Configurable.allConfigurables)
1452 while unknown:
1453 for k in unknown:
1454 if not known: # do not print during the first iteration
1455 log.debug('new configurable created automatically: %s', k)
1456 # this trigger the instantiation from handles
1457 Configurable.allConfigurables[k].properties()
1458 known.add(k)
1459 unknown -= known
1460 # Call post-config actions
1461 for action in postConfigActions:
1462 action()
1463
std::function< StatusCode()>
GaudiKernel.Configurable.applyConfigurableUsers
def applyConfigurableUsers()
Definition: Configurable.py:1395
gaudiComponentHelp.properties
properties
Definition: gaudiComponentHelp.py:37
GaudiKernel.Configurable.Error
Definition: Configurable.py:56

def GaudiKernel.Configurable.applyConfigurableUsers_old | ( |  | ) |

    Obsolete (buggy) implementation of applyConfigurableUsers(), kept to provide
    backward compatibility for configurations that where relying (implicitly) on
    bug #103803, or on a specific (non guaranteed) order of execution.

    @see applyConfigurableUsers()

Definition at line 1464 of file Configurable.py.

1464 def applyConfigurableUsers_old():
1465 """
1466 Obsolete (buggy) implementation of applyConfigurableUsers(), kept to provide
1467 backward compatibility for configurations that where relying (implicitly) on
1468 bug #103803, or on a specific (non guaranteed) order of execution.
1469
1470 @see applyConfigurableUsers()
1471 """
1472 # Avoid double calls
1473 global _appliedConfigurableUsers_, postConfigActions
1474 if _appliedConfigurableUsers_:
1475 return
1476 _appliedConfigurableUsers_ = True
1477
1478 debugApplyOrder = 'GAUDI_DUBUG_CONF_USER' in os.environ
1479 confUsers = [ c
1480 for c in Configurable.allConfigurables.values()
1481 if hasattr(c,"__apply_configuration__") ]
1482 applied = True # needed to detect dependency loops
1483 while applied and confUsers:
1484 newConfUsers = [] # list of conf users that cannot be applied yet
1485 applied = False
1486 for c in confUsers:
1487 if hasattr(c,"__users__") and c.__users__:
1488 newConfUsers.append(c) # cannot use this one yet
1489 else: # it does not have users or the list is empty
1490 applied = True
1491 # the ConfigurableUser is enabled if it doesn't have an _enabled
1492 # property or its value is True
1493 enabled = (not hasattr(c, "_enabled")) or c._enabled
1494 if enabled:
1495 log.info("applying configuration of %s", c.name())
1496 if debugApplyOrder:
1497 sys.stderr.write('applying %r' % c)
1498 c.__apply_configuration__()
1499 log.info(c)
1500 else:
1501 log.info("skipping configuration of %s", c.name())
1502 if hasattr(c, "__detach_used__"):
1503 # tells the used configurables that they are not needed anymore
1504 c.__detach_used__()
1505 confUsers = newConfUsers # list of C.U.s still to go
1506 if confUsers:
1507 # this means that some C.U.s could not be applied because of a dependency loop
1508 raise Error("Detected loop in the ConfigurableUser "
1509 " dependencies: %r" % [ c.name()
1510 for c in confUsers ])
1511 # ensure that all the Handles have been triggered
1512 known = set()
1513 unknown = set(Configurable.allConfigurables)
1514 while unknown:
1515 for k in unknown:
1516 if not known: # do not print during the first iteration
1517 log.debug('new configurable created automatically: %s', k)
1518 # this trigger the instantiation from handles
1519 Configurable.allConfigurables[k].properties()
1520 known.add(k)
1521 unknown -= known
1522 # Call post-config actions
1523 for action in postConfigActions:
1524 action()
1525
std::function< StatusCode()>
GaudiKernel.Configurable.applyConfigurableUsers_old
def applyConfigurableUsers_old()
Definition: Configurable.py:1464
gaudiComponentHelp.properties
properties
Definition: gaudiComponentHelp.py:37
GaudiKernel.Configurable.Error
Definition: Configurable.py:56

def GaudiKernel.Configurable.expandvars | ( |  | data | ) |

    Expand environment variables "data".
    Data can be string, list, tuple and dictionary. For collection, all the
    contained strings will be manipulated (recursively).

Definition at line 34 of file Configurable.py.

34 def expandvars(data):
35 """
36 Expand environment variables "data".
37 Data can be string, list, tuple and dictionary. For collection, all the
38 contained strings will be manipulated (recursively).
39 """
40 import os.path
41 typ = type(data)
42 if typ is str:
43 return os.path.expandvars(data)
44 elif typ in [list, tuple]:
45 collect = []
46 for i in data:
47 collect.append(expandvars(i))
48 return typ(collect)
49 elif typ is dict:
50 collect = {}
51 for k in data:
52 collect[expandvars(k)] = expandvars(data[k])
53 return collect
54 return data
55
gaudirun.type
type
Definition: gaudirun.py:125
GaudiKernel.Configurable.expandvars
def expandvars(data)
Definition: Configurable.py:34

def GaudiKernel.Configurable.getNeededConfigurables | ( |  | ) |

    Function to select all and only the configurables that have to be used in
    GaudiPython.AppMgr constructor.
    This is needed because in Athena the implementation have to be different (the
    configuration is used in a different moment).

Definition at line 1526 of file Configurable.py.

1526 def getNeededConfigurables():
1527 """
1528 Function to select all and only the configurables that have to be used in
1529 GaudiPython.AppMgr constructor.
1530 This is needed because in Athena the implementation have to be different (the
1531 configuration is used in a different moment).
1532 """
1533 return [ k
1534 for k, v in Configurable.allConfigurables.items()
1535 if v.getGaudiType() != "User" ] # Exclude ConfigurableUser instances
1536
GaudiKernel.Configurable.getNeededConfigurables
def getNeededConfigurables()
Definition: Configurable.py:1526

def GaudiKernel.Configurable.isApplicable | ( |  | self | ) |

if isinstance(v,Configurable) and not v.isPublic(): rep += v.__str__( indent + 1 ) + os.linesep elif isinstance(v,GaudiHandleArray): for vi in v: if isinstance(vi,Configurable) and not vi.isPublic(): rep += vi.__str__( indent + 1 ) + os.linesep

for cfg in self.__children:

    Return True is the instance can be "applied".
    Always False for plain Configurable instances
    (i.e. not ConfigurableUser).

Definition at line 930 of file Configurable.py.

930 def isApplicable(self):
931 '''
932 Return True is the instance can be "applied".
933 Always False for plain Configurable instances
934 (i.e. not ConfigurableUser).
935 '''
936 return False
937
GaudiKernel.Configurable.isApplicable
def isApplicable(self)
if isinstance(v,Configurable) and not v.isPublic(): rep += v.__str__( indent + 1 ) + os...
Definition: Configurable.py:930

def GaudiKernel.Configurable.makeSequences | ( |  | expression | ) |

    Convert a control flow expression to nested GaudiSequencers.

Definition at line 1609 of file Configurable.py.

1609 def makeSequences(expression):
1610 '''
1611 Convert a control flow expression to nested GaudiSequencers.
1612 '''
1613 if not isinstance(expression, ControlFlowNode):
1614 raise ValueError('ControlFlowNode instance expected, got %s' %
1615 type(expression).__name__)
1616 visitor = CreateSequencesVisitor()
1617 expression.visitNode(visitor)
1618 return visitor.sequence
1619
1620
GaudiKernel.Configurable.CreateSequencesVisitor
Definition: Configurable.py:1557
GaudiKernel.Configurable.makeSequences
def makeSequences(expression)
Definition: Configurable.py:1609
gaudirun.type
type
Definition: gaudirun.py:125

def GaudiKernel.Configurable.purge | ( |  | ) |

    Clean up all configurations and configurables.

Definition at line 1537 of file Configurable.py.

1537 def purge():
1538 """
1539 Clean up all configurations and configurables.
1540 """
1541 for c in Configurable.allConfigurables.values():
1542 c.__class__.configurables.clear()
1543 Configurable.allConfigurables.clear()
1544 # FIXME: (MCl) this is needed because instances of ConfigurableGeneric are not
1545 # migrated to the correct class when this is known.
1546 ConfigurableGeneric.configurables.clear()
1547 from ProcessJobOptions import _included_files
1548 import os.path, sys
1549 for file in _included_files:
1550 dirname, basname = os.path.split(file)
1551 basname, ext = os.path.splitext(basname)
1552 if basname in sys.modules:
1553 del sys.modules[basname]
1554 _included_files.clear()
1555
1556
GaudiKernel.Configurable.purge
def purge()
Definition: Configurable.py:1537

def GaudiKernel.Configurable.removePostConfigAction | ( |  | function | ) |

    Remove a callable from the list of post-config actions.
    The list is directly accessible as 'GaudiKernel.Configurable.postConfigActions'.

Definition at line 1387 of file Configurable.py.

1387 def removePostConfigAction(function):
1388 """
1389 Remove a callable from the list of post-config actions.
1390 The list is directly accessible as 'GaudiKernel.Configurable.postConfigActions'.
1391 """
1392 postConfigActions.remove(function)
1393
GaudiKernel.Configurable.removePostConfigAction
def removePostConfigAction(function)
Definition: Configurable.py:1387

## Variable Documentation

list GaudiKernel.Configurable.__all__
| private

Initial value:
1 = [ 'Configurable',
2 'ConfigurableAlgorithm',
3 'ConfigurableAlgTool',
4 'ConfigurableAuditor',
5 'ConfigurableService',
6 'ConfigurableUser',
7 'VERBOSE','DEBUG','INFO', 'WARNING', 'ERROR', 'FATAL',
8 'appendPostConfigAction', 'removePostConfigAction' ]

data ------------------------------------------------------------------—

Definition at line 21 of file Configurable.py.

bool GaudiKernel.Configurable._appliedConfigurableUsers_ = False
| private

Definition at line 1394 of file Configurable.py.

GaudiKernel.Configurable.log = logging.getLogger( 'Configurable' )

Definition at line 32 of file Configurable.py.

list GaudiKernel.Configurable.postConfigActions = []

Definition at line 1375 of file Configurable.py.