ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Control
AthenaConfiguration
python
Deduplication.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
2
#
3
# Functions used by the ComponentAccumulator to de-duplicate components.
4
#
5
6
from
AthenaConfiguration.DebuggingContext
import
raiseWithCurrentContext
7
8
class
DeduplicationFailed
(RuntimeError):
9
pass
10
11
12
def
deduplicate
(newComp, compList):
13
"""Merge newComp with compList. If a matching component is found it is updated
14
in compList. Otherwise a new component is added to compList.
15
16
Returns True if a new component has been added, otherwise False. If merging fails,
17
an exception is raised.
18
"""
19
20
for
idx, comp
in
enumerate(compList):
21
if
comp.__cpp_type__==newComp.__cpp_type__
and
comp.name==newComp.name:
22
exception =
None
23
try
:
24
newComp.merge(comp)
25
except
Exception
as
e:
26
exception = e
# remember exception and raise again outside the handler
27
if
exception:
28
raiseWithCurrentContext(exception)
29
30
# We found a service of the same type and name and could reconcile the two instances.
31
# Overwrite the component in the list with the new (merged) component.
32
compList[idx] = newComp
33
return
False
34
35
# No component of the same type and name found, simply append
36
compList.append(newComp)
37
return
True
38
39
40
def
deduplicateOne
(newComp, oldComp):
41
"""Merge newComp with oldComp and provide diagnostics on failure."""
42
43
exception =
None
44
try
:
45
assert
oldComp.__cpp_type__ == newComp.__cpp_type__,
"Deduplicating components of different type"
46
assert
oldComp.name == newComp.name,
"Deduplicating components of different name"
47
oldComp.merge(newComp)
48
except
Exception
as
e:
49
exception = e
# remember exception and raise again outside the handler
50
if
exception:
51
raiseWithCurrentContext(exception)
python.Deduplication.DeduplicationFailed
Definition
Deduplication.py:8
python.Deduplication.deduplicateOne
deduplicateOne(newComp, oldComp)
Definition
Deduplication.py:40
python.Deduplication.deduplicate
deduplicate(newComp, compList)
Definition
Deduplication.py:12
Generated on
for ATLAS Offline Software by
1.17.0