ATLAS Offline Software
Control
AthenaConfiguration
python
DebuggingContext.py
Go to the documentation of this file.
1
# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
2
3
4
# set of utilities allowing to get a better context information when issues with CA occur
5
class
Context
(
object
):
6
"""
7
Keeps the context info as a stack
8
Usage:
9
context = Context("context string") # this is it
10
"""
11
hint=
"Unknown context (enable it with ComponentAccumulator.debugMode = \"trackCA trackEventAlgo etc. see ComponentAccumulator documentation\")"
12
__context = []
13
14
def
__init__
(self, c):
15
Context.__context.append(c)
16
17
def
__del__
(self):
18
Context.__context.pop()
19
20
@classmethod
21
def
current
(cls):
22
return
Context.__context[-1]
23
24
@classmethod
25
def
complete
(cls):
26
return
Context.hint
if
not
Context.__context
else
"\n"
.
join
(Context.__context)
27
28
29
def
shortCallStack
():
30
"""
31
Obtains (a very abbreviated) context of the current call stack (from the top, excluding the code using this function)
32
"""
33
import
inspect
34
compact =
' >>> '
35
for
frameInfo
in
inspect.stack()[2:][::-1]:
36
compact +=
"{}:{}({}) "
.
format
(frameInfo.filename.split(
'/'
)[-1], frameInfo.frame.f_lineno, frameInfo.function)
37
return
compact
38
39
40
def
createContextForDeduplication
(message, compName, destContext):
41
return
Context
(f
"{message} : {compName} : {destContext.get(compName, Context.hint)}"
)
42
43
44
def
raiseWithCurrentContext
(exception):
45
"""
46
Raises the exception with the message supplemented with context information
47
"""
48
raise
type
(exception)(
str
(exception) +
'\nWith the context:\n{}'
.
format
(Context.complete()) )
python.DebuggingContext.raiseWithCurrentContext
def raiseWithCurrentContext(exception)
Definition:
DebuggingContext.py:44
vtune_athena.format
format
Definition:
vtune_athena.py:14
python.DebuggingContext.Context.current
def current(cls)
Definition:
DebuggingContext.py:21
python.DebuggingContext.createContextForDeduplication
def createContextForDeduplication(message, compName, destContext)
Definition:
DebuggingContext.py:40
python.DebuggingContext.Context.__del__
def __del__(self)
Definition:
DebuggingContext.py:17
python.DebuggingContext.Context.complete
def complete(cls)
Definition:
DebuggingContext.py:25
TCS::join
std::string join(const std::vector< std::string > &v, const char c=',')
Definition:
Trigger/TrigT1/L1Topo/L1TopoCommon/Root/StringUtils.cxx:10
python.DebuggingContext.Context.__init__
def __init__(self, c)
Definition:
DebuggingContext.py:14
python.CaloScaleNoiseConfig.type
type
Definition:
CaloScaleNoiseConfig.py:78
pickleTool.object
object
Definition:
pickleTool.py:30
python.DebuggingContext.Context
Definition:
DebuggingContext.py:5
str
Definition:
BTagTrackIpAccessor.cxx:11
python.DebuggingContext.shortCallStack
def shortCallStack()
Definition:
DebuggingContext.py:29
Generated on Fri Jan 17 2025 21:09:13 for ATLAS Offline Software by
1.8.18