ATLAS Offline Software
Loading...
Searching...
No Matches
Common.py
Go to the documentation of this file.
2# Copyright (C) 2002-2023 CERN for the benefit of the ATLAS collaboration
3#
4
5'''
6Common variables and functions used in Trigger ART test steering
7'''
8
9import logging
10import sys
11import os
12from functools import lru_cache
13
14
15# Logging level used across the package
16trigvalsteering_logging_level = logging.INFO
17
18# Dictionary of required prefixes identifying a package, see ATR-19735
19package_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
26art_result_summary = 'art-result-summary.log'
27
28# ART input directories for data and references
29art_input_eos = '/eos/atlas/atlascerngroupdisk/data-art/grid-input/'
30art_input_cvmfs = '/cvmfs/atlas-nightlies.cern.ch/repo/data/data-art/'
31
32
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
42def 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
51def 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
58def 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
66def 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
78def running_in_CI():
79 return os.environ.get('gitlabTargetBranch') is not None