ATLAS Offline Software
Classes | Functions | Variables
python.Deduplication Namespace Reference

Classes

class  DeduplicationFailed
 

Functions

def deduplicate (newComp, compList)
 
def deduplicateOne (newComp, oldComp)
 

Variables

 _msg
 

Function Documentation

◆ deduplicate()

def python.Deduplication.deduplicate (   newComp,
  compList 
)
Merge newComp with compList. If a matching component is found it is updated
in compList. Otherwise a new component is added to compList.

Returns True if a new component has been added, otherwise False. If merging fails,
an exception is raised.

Definition at line 15 of file Deduplication.py.

15 def deduplicate(newComp, compList):
16  """Merge newComp with compList. If a matching component is found it is updated
17  in compList. Otherwise a new component is added to compList.
18 
19  Returns True if a new component has been added, otherwise False. If merging fails,
20  an exception is raised.
21  """
22 
23  for idx, comp in enumerate(compList):
24  if comp.__cpp_type__==newComp.__cpp_type__ and comp.name==newComp.name:
25  exception = None
26  try:
27  newComp.merge(comp)
28  except Exception as e:
29  exception = e # remember exception and raise again outside the handler
30  if exception:
31  raiseWithCurrentContext(exception)
32 
33  # We found a service of the same type and name and could reconcile the two instances.
34  # Overwrite the component in the list with the new (merged) component.
35  _msg.verbose("Reconciled configuration of component %s", comp.name)
36  compList[idx] = newComp
37  return False
38 
39  # No component of the same type and name found, simply append
40  _msg.debug("Adding component %s/%s to the job", newComp.__cpp_type__, newComp.name)
41  compList.append(newComp)
42  return True
43 
44 

◆ deduplicateOne()

def python.Deduplication.deduplicateOne (   newComp,
  oldComp 
)
Merge newComp with oldComp and provide diagnostics on failure.

Definition at line 45 of file Deduplication.py.

45 def deduplicateOne(newComp, oldComp):
46  """Merge newComp with oldComp and provide diagnostics on failure."""
47 
48  exception = None
49  try:
50  assert oldComp.__cpp_type__ == newComp.__cpp_type__, "Deduplicating components of different type"
51  assert oldComp.name == newComp.name, "Deduplicating components of different name"
52  oldComp.merge(newComp)
53  except Exception as e:
54  exception = e # remember exception and raise again outside the handler
55  if exception:
56  raiseWithCurrentContext(exception)

Variable Documentation

◆ _msg

python.Deduplication._msg
private

Definition at line 12 of file Deduplication.py.

python.DebuggingContext.raiseWithCurrentContext
def raiseWithCurrentContext(exception)
Definition: DebuggingContext.py:44
python.Deduplication.deduplicateOne
def deduplicateOne(newComp, oldComp)
Definition: Deduplication.py:45
python.Deduplication.deduplicate
def deduplicate(newComp, compList)
Definition: Deduplication.py:15