ATLAS Offline Software
Common.py
Go to the documentation of this file.
1 #
2 # Copyright (C) 2002-2023 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 
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):
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  return '`find . -name \'{:s}\' | tail -n 1`'.format(pattern)
65 
66 def find_file_in_path(filename, path_env_var):
67  '''Find filename in search path given by environment variable'''
68 
69  # same as AthenaCommon.unixtools.FindFile but don't want AthenaCommon dependency
70  for path in os.environ[path_env_var].split(os.pathsep):
71  f = os.path.join( path, filename )
72  if os.access(f, os.R_OK):
73  return f
74  return None
75 
76 
77 @lru_cache
79  return os.environ.get('gitlabTargetBranch') is not None
vtune_athena.format
format
Definition: vtune_athena.py:14
python.TrigValSteering.Common.find_file
def find_file(pattern)
Definition: Common.py:58
python.TrigValSteering.Common.running_in_CI
def running_in_CI()
Definition: Common.py:78
python.TrigValSteering.Common.clear_art_summary
def clear_art_summary()
Definition: Common.py:51
python.TrigValSteering.Common.find_file_in_path
def find_file_in_path(filename, path_env_var)
Definition: Common.py:66
Trk::open
@ open
Definition: BinningType.h:40
python.TrigValSteering.Common.get_logger
def get_logger()
Definition: Common.py:33
python.TrigValSteering.Common.art_result
def art_result(result, name)
Definition: Common.py:42
Trk::split
@ split
Definition: LayerMaterialProperties.h:38