ATLAS Offline Software
Loading...
Searching...
No Matches
python.TrigValSteering.Input Namespace Reference

Classes

class  TrigValInput

Functions

 load_input_json ()
 is_input_defined (keyword)
 get_input (keyword)

Variables

str input_json = 'TrigValTools/TrigValInputs.json'

Detailed Description

Common way to configure input samples for Trigger ART tests

Function Documentation

◆ get_input()

python.TrigValSteering.Input.get_input ( keyword)
Common getter function to retrieve inputs by keyword

Definition at line 96 of file Input.py.

96def get_input(keyword):
97 '''Common getter function to retrieve inputs by keyword'''
98
99 log = get_logger()
100
101 # use rucio dataset for grid jobs, else rely on EOS/cvmfs inputs (TrigValInputs.json)
102 import os
103 paths = os.getenv("ArtInFile",None)
104
105 if paths:
106 source = "data" if "data" in paths else "mc"
107 format = None
108 for key,value in {'RAW':'BS', 'HITS':'HITS', 'RDO':'RDO', 'ESD':'ESD', 'AOD':'AOD'}.items():
109 if key in paths:
110 format = value
111 break
112 data_object = {"source":source, "format":format, "paths":[paths]}
113 else:
114 data = load_input_json()
115 if keyword not in data.keys():
116 log.error('Failed to find keyword "%s" in input JSON %s',keyword, input_json)
117 return None
118
119 data_object = data[keyword]
120
121 # for ART tests running on RAW data:
122 # - build tests use small files on cvmfs
123 # - grid tests running interactively must copy large files from EOS to the local area
124 if data_object["format"] == "BS":
125 grid = False
126 Nfiles = 0
127 import sys
128 with open(sys.argv[0], 'r') as f:
129 for line in f:
130 if "# art-type:" in line:
131 grid = line.split()[2]=="grid"
132 if "# art-input-nfiles:" in line:
133 Nfiles = int(line.split()[2])
134 if grid:
135 data_object["paths"] = [path for path in data_object["paths"] if "/eos/" in path]
136 import subprocess
137 local_files = []
138 for i in range(Nfiles):
139 f = data_object["paths"][i].split('/')[-1]
140 if not (os.path.exists(f)) and not os.environ.get('TRIGVALSTEERING_DRY_RUN'):
141 print(f'copying {data_object["paths"][i]}')
142 result = subprocess.run(['xrdcp',f'root://eosatlas.cern.ch/{data_object["paths"][i]}','.'])
143 if result.returncode != 0:
144 raise Exception("xrdcp failed, please check you have a valid kerberos ticket")
145 local_files.append(f)
146 data_object["paths"] = local_files
147 else:
148 data_object["paths"] = [path for path in data_object["paths"] if "/cvmfs/" in path]
149
150 result = TrigValInput(
151 keyword,
152 data_object["source"],
153 data_object["format"],
154 data_object["paths"]
155 )
156
157 if result.is_valid():
158 return result
159 else:
160 log.error('Failed to create a valid input object')
161 return None
void print(char *figname, TCanvas *c1)
std::vector< std::string > split(const std::string &s, const std::string &t=":")
Definition hcg.cxx:177

◆ is_input_defined()

python.TrigValSteering.Input.is_input_defined ( keyword)
Checks if the keyword exists in the input json file

Definition at line 90 of file Input.py.

90def is_input_defined(keyword):
91 '''Checks if the keyword exists in the input json file'''
92 data = load_input_json()
93 return keyword in data
94
95

◆ load_input_json()

python.TrigValSteering.Input.load_input_json ( )
Reads the json file with input definitions and returns the data as dictionary

Definition at line 75 of file Input.py.

75def load_input_json():
76 '''Reads the json file with input definitions and returns the data as dictionary'''
77
78 log = get_logger()
79
80 input_json_fullpath = find_file_in_path(input_json, 'DATAPATH')
81 if not input_json_fullpath:
82 log.error('Failed to determine full path for input JSON %s', input_json)
83 return None
84
85 log.debug('Reading %s', input_json_fullpath)
86 with open(input_json_fullpath) as data_file:
87 return json.load(data_file)
88
89

Variable Documentation

◆ input_json

str python.TrigValSteering.Input.input_json = 'TrigValTools/TrigValInputs.json'

Definition at line 16 of file Input.py.