Definition of a Trigger ART test to be configured and executed
Definition at line 19 of file Trigger/TrigValidation/TrigValTools/python/TrigValSteering/Test.py.
◆ __init__()
def python.TrigValSteering.Test.Test.__init__ |
( |
|
self | ) |
|
◆ configuration_error()
def python.TrigValSteering.Test.Test.configuration_error |
( |
|
self, |
|
|
|
message |
|
) |
| |
◆ configure()
def python.TrigValSteering.Test.Test.configure |
( |
|
self | ) |
|
Definition at line 31 of file Trigger/TrigValidation/TrigValTools/python/TrigValSteering/Test.py.
34 self.log.
info(
"Configuring test %s", self.name)
37 self.configure_timeout()
40 for step
in self.exec_steps:
42 for step
in self.check_steps:
43 self.log.
debug(
'Configuring check step %s', step.name)
46 duplicate_names = self.duplicate_step_names()
47 if len(duplicate_names) > 0:
48 self.configuration_error(
49 'Found test steps with duplicate names: '
50 '{}'.
format(duplicate_names)+
' Aborting because this'
51 ' configuration could lead to overwriting logs')
54 if self.dry_run
is None:
56 env = os.environ.get(
'TRIGVALSTEERING_DRY_RUN')
60 self.configured =
True
64 'Test configuration complete:\n-- %s',
65 '\n-- '.
join([
'{}: {}'.
format(k, v)
for k, v
in self.__dict__.
items()]))
◆ configure_name()
def python.TrigValSteering.Test.Test.configure_name |
( |
|
self | ) |
|
Definition at line 154 of file Trigger/TrigValidation/TrigValTools/python/TrigValSteering/Test.py.
154 def configure_name(self):
155 filename = os.path.basename(sys.argv[0])
156 self.log.
debug(
'Parsing file name %s', filename)
159 if not filename.startswith(prefix)
or not filename.endswith(suffix):
160 self.configuration_error(
161 'Test file name {} does not match '.
format(filename) +
162 'the required pattern {}*{}'.
format(prefix, suffix))
163 for package_name, package_prefix
in package_prefix_dict.items():
164 if filename.startswith(prefix+package_prefix):
165 self.package_name = package_name
166 this_package_prefix = package_prefix
167 if self.package_name
is None:
168 self.configuration_error(
169 'Test file name {} could not be matched '.
format(filename) +
170 'to any of the required package prefixes: {}'.
format(
171 package_prefix_dict.values()))
172 if not self.art_type
or self.art_type
not in [
'build',
'grid']:
173 self.configuration_error(
174 'Incorrect test art_type = {:s}, only "build" and "grid" are supported'.
format(self.art_type))
175 if not filename.endswith(
'_' + self.art_type + suffix)
and \
176 self.package_name !=
"TrigInDetValidation":
177 self.configuration_error(
178 'Test file name does not match the art_type="{:s}". '.
format(self.art_type) +
179 'Expected name {:s}'.
format(prefix+this_package_prefix+
'*_'+self.art_type+suffix))
181 if len(filename) > max_len:
182 self.configuration_error(
183 'Test file name is too long. The limit is {} '.
format(max_len) +
184 'characters, but it has {}'.
format(len(filename)))
185 self.name = filename[len(prefix):-len(suffix)]
◆ configure_timeout()
def python.TrigValSteering.Test.Test.configure_timeout |
( |
|
self | ) |
|
Set default timeout values for steps which don't have it set
Definition at line 143 of file Trigger/TrigValidation/TrigValTools/python/TrigValSteering/Test.py.
143 def configure_timeout(self):
144 '''Set default timeout values for steps which don't have it set'''
145 for exec_step
in self.exec_steps:
146 if exec_step.timeout
is None:
148 exec_step.timeout = 12*3600
if self.art_type ==
'grid' else 3600
149 for check_step
in self.check_steps:
150 if check_step.timeout
is None:
152 check_step.timeout = 5*60
◆ duplicate_step_names()
def python.TrigValSteering.Test.Test.duplicate_step_names |
( |
|
self | ) |
|
Definition at line 187 of file Trigger/TrigValidation/TrigValTools/python/TrigValSteering/Test.py.
187 def duplicate_step_names(self):
189 for step
in self.exec_steps:
190 d.setdefault(step.name, 0)
192 for step
in self.check_steps:
193 d.setdefault(step.name, 0)
195 duplicates = [name
for name, count
in d.items()
if count > 1]
196 self.log.
debug(
'all steps: %s', d)
197 self.log.
debug(
'duplicates: %s', duplicates)
◆ get_step()
def python.TrigValSteering.Test.Test.get_step |
( |
|
self, |
|
|
|
step_name |
|
) |
| |
◆ get_step_by_type()
def python.TrigValSteering.Test.Test.get_step_by_type |
( |
|
self, |
|
|
|
step_type |
|
) |
| |
◆ pre_exec()
def python.TrigValSteering.Test.Test.pre_exec |
( |
|
self | ) |
|
Extra pre-exec function executed just before the steps
Definition at line 217 of file Trigger/TrigValidation/TrigValTools/python/TrigValSteering/Test.py.
218 '''Extra pre-exec function executed just before the steps'''
221 if self.art_type ==
'grid':
222 cmd =
'which art.py >/dev/null 2>&1'
223 art_available = subprocess.call(cmd, shell=
True)
224 if art_available == 0:
225 cmd =
'art.py createpoolfile'
226 self.log.
debug(
'Executing pre-exec command %s', cmd)
227 subprocess.call(cmd, shell=
True)
◆ run()
def python.TrigValSteering.Test.Test.run |
( |
|
self | ) |
|
Definition at line 67 of file Trigger/TrigValidation/TrigValTools/python/TrigValSteering/Test.py.
68 if not self.configured:
71 self.log.
info(
"Running test %s", self.name)
77 commands = OrderedDict()
80 pre_exec_cmd = self.pre_exec()
81 if len(pre_exec_cmd) > 0:
82 commands[
'pre_exec'] = pre_exec_cmd
84 commands[
'exec_steps'] = []
85 commands[
'check_steps'] = []
88 self.run_steps(self.exec_steps, commands[
'exec_steps'])
92 if len(self.exec_steps) > 1:
93 for step
in self.exec_steps:
94 if step.result > exec_summary:
95 exec_summary = step.result
97 self.log.
info(
'At least one of the exec steps failed, using the largest code as ExecSummary')
99 self.log.
info(
'All exec steps succeeded')
101 elif len(self.exec_steps) == 1:
102 exec_summary = self.exec_steps[0].result
105 self.run_steps(self.check_steps, commands[
'check_steps'], exec_status=exec_summary)
108 with open(
'commands.json',
'w')
as outfile:
109 json.dump(commands, outfile, indent=4)
113 failed_required_steps = []
114 for step
in self.exec_steps + self.check_steps:
115 if step.required
and (step.result != 0):
116 self.log.
debug(
'Required step %s finished with result %s', step.name, step.result)
117 failed_required_steps.append(step.name)
118 if abs(step.result) > exit_code:
119 exit_code = abs(step.result)
120 exit_msg =
'Test {:s} finished with code {:d}'.
format(self.name, exit_code)
122 exit_msg +=
' because all required steps were successful'
124 exit_msg +=
' because the following required steps failed: {:s}'.
format(
str(failed_required_steps))
125 self.log.
info(exit_msg)
◆ run_steps()
def python.TrigValSteering.Test.Test.run_steps |
( |
|
self, |
|
|
|
steps, |
|
|
|
commands_list, |
|
|
|
exec_status = 0 |
|
) |
| |
Definition at line 128 of file Trigger/TrigValidation/TrigValTools/python/TrigValSteering/Test.py.
128 def run_steps(self, steps, commands_list, exec_status=0):
131 if (previous_code != 0
and step.depends_on_previous)
or \
132 (exec_status != 0
and step.depends_on_exec):
133 self.log.
error(
'Skipping step %s because previous step(s) failed', step.name)
135 code, cmd = step.result,
'# Skipped {} because of earlier failure'.
format(step.name)
136 if step.auto_report_result:
139 code, cmd = step.run(self.dry_run)
141 commands_list.append(cmd)
◆ art_type
python.TrigValSteering.Test.Test.art_type |
◆ check_steps
python.TrigValSteering.Test.Test.check_steps |
◆ configured
python.TrigValSteering.Test.Test.configured |
◆ dry_run
python.TrigValSteering.Test.Test.dry_run |
◆ exec_steps
python.TrigValSteering.Test.Test.exec_steps |
◆ log
python.TrigValSteering.Test.Test.log |
◆ name
python.TrigValSteering.Test.Test.name |
◆ package_name
python.TrigValSteering.Test.Test.package_name |
The documentation for this class was generated from the following file:
bool configure(asg::AnaToolHandle< ITrigGlobalEfficiencyCorrectionTool > &tool, ToolHandleArray< IAsgElectronEfficiencyCorrectionTool > &electronEffToolsHandles, ToolHandleArray< IAsgElectronEfficiencyCorrectionTool > &electronSFToolsHandles, ToolHandleArray< CP::IMuonTriggerScaleFactors > &muonToolsHandles, ToolHandleArray< IAsgPhotonEfficiencyCorrectionTool > &photonEffToolsHandles, ToolHandleArray< IAsgPhotonEfficiencyCorrectionTool > &photonSFToolsHandles, const std::string &triggers, const std::map< std::string, std::string > &legsPerTool, unsigned long nToys, bool debug)