ATLAS Offline Software
Toggle main menu visibility
Loading...
Searching...
No Matches
Trigger
TrigValidation
TrigValTools
python
TrigValSteering
Common.py
Go to the documentation of this file.
1
#
2
# Copyright (C) 2002-2026 CERN for the benefit of the ATLAS collaboration
3
#
4
5
'''
6
Common variables and functions used in Trigger ART test steering
7
'''
8
9
import
logging
10
import
sys
11
import
os
12
from
functools
import
lru_cache
13
14
15
# Logging level used across the package
16
trigvalsteering_logging_level = logging.INFO
17
18
# Dictionary of required prefixes identifying a package, see ATR-19735
19
package_prefix_dict = {
'TriggerTest'
:
'trig_'
,
20
'TrigP1Test'
:
'trigP1_'
,
21
'TrigAnalysisTest'
:
'trigAna_'
,
22
'TrigInDetValidation'
:
'trigID_'
,
23
'TrigGpuTest'
:
'trigGPU_'
,}
24
25
# Log file with all art-result statements
26
art_result_summary =
'art-result-summary.log'
27
28
# ART input directories for data and references
29
art_input_eos =
'/eos/atlas/atlascerngroupdisk/data-art/grid-input/'
30
art_input_cvmfs =
'/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/'
31
32
33
def
get_logger
():
34
'''Default TrigValSteering logger'''
35
logging.basicConfig(stream=sys.stdout,
36
format='%(asctime)s %(name)s %(levelname)-8s %(message)s',
37
datefmt='%Y-%m-%dT%H%M%S %Z',
38
level=trigvalsteering_logging_level)
39
return logging.getLogger('TrigValSteering')
40
41
42
def art_result(result, name):
43
'''
Print art-result to stdout and summary log file'''
44
45
line = 'art-result: {} {}\n'.format(result, name)
46
sys.stdout.write(line)
47
with open(art_result_summary, 'a') as summary:
48
summary.write(line)
49
50
51
def clear_art_summary():
52
'''Remove art-result summary file produced by the art_result function'''
53
54
if os.path.isfile(art_result_summary):
55
os.remove(art_result_summary)
56
57
58
def find_file(pattern, max_files=1):
59
'''
60
Bash inline command frequently used in multi-step tests
61
to pass the output of one step to the input of another
62
based on a name pattern rather than a fixed full file name.
63
64
By default only the first match is returned. Set max_files
65
to None to return all matches (as space separated list).
66
'''
67
cmd = f'find . -name \'{pattern}\''
68
if max_files is not None:
69
cmd += f' | tail -n {max_files}'
70
return f'`{cmd}`'
71
72
73
def find_file_in_path(filename, path_env_var):
74
'''Find filename in search path given by environment variable'''
75
76
# same as AthenaCommon.unixtools.FindFile but don't want AthenaCommon dependency
77
for path in os.environ[path_env_var].split(os.pathsep):
78
f = os.path.join( path, filename )
79
if os.access(f, os.R_OK):
80
return f
81
return None
82
83
84
@lru_cache
85
def running_in_CI():
86
return os.environ.get('gitlabTargetBranch') is not None
python.TrigValSteering.Common.get_logger
get_logger()
Definition
Common.py:33
Generated on
for ATLAS Offline Software by
1.17.0