ATLAS Offline Software
Loading...
Searching...
No Matches
python.TrigValSteering.CheckSteps.RegTestStep Class Reference
Inheritance diagram for python.TrigValSteering.CheckSteps.RegTestStep:
Collaboration diagram for python.TrigValSteering.CheckSteps.RegTestStep:

Public Member Functions

 __init__ (self, name='RegTest')
 configure (self, test)
 prepare_inputs (self)
 rename_ref (self)
 run (self, dry_run=False)

Public Attributes

str regex = 'REGTEST'
str executable = 'diff'
str input_base_name = 'athena'
bool auto_report_result = True
 output_stream = Step.OutputStream.FILE_AND_STDOUT
int result = 1
 reference = None
 ref_test_name = None
 input_file = None
bool explicit_reference = False
 name
 required

Detailed Description

Execute RegTest comparing a log file against a reference

Definition at line 292 of file CheckSteps.py.

Constructor & Destructor Documentation

◆ __init__()

python.TrigValSteering.CheckSteps.RegTestStep.__init__ ( self,
name = 'RegTest' )

Definition at line 295 of file CheckSteps.py.

295 def __init__(self, name='RegTest'):
296 super(RegTestStep, self).__init__(name)
297 self.regex = 'REGTEST'
298 self.executable = 'diff'
299 self.input_base_name = 'athena'
300 self.auto_report_result = True
301 self.output_stream = Step.OutputStream.FILE_AND_STDOUT
302

Member Function Documentation

◆ configure()

python.TrigValSteering.CheckSteps.RegTestStep.configure ( self,
test )

Reimplemented from python.TrigValSteering.CheckSteps.RefComparisonStep.

Definition at line 303 of file CheckSteps.py.

303 def configure(self, test):
304 self.input_file = self.input_base_name+'.regtest'
305 RefComparisonStep.configure(self, test)
306 self.args += ' -U 2 -b {} {}'.format(self.input_file, self.reference)
307 Step.configure(self, test)
308
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)

◆ prepare_inputs()

python.TrigValSteering.CheckSteps.RegTestStep.prepare_inputs ( self)

Definition at line 309 of file CheckSteps.py.

309 def prepare_inputs(self):
310 log_file = self.input_base_name+'.log'
311 if not os.path.isfile(log_file):
312 self.log.error('%s input file %s is missing', self.name, log_file)
313 return False
314 with open(log_file, encoding='utf-8') as f_in:
315 matches = re.findall('({}.*).*$'.format(self.regex),
316 f_in.read(), re.MULTILINE)
317 with open(self.input_file, 'w', encoding='utf-8') as f_out:
318 for line in matches:
319 linestr = str(line[0]) if type(line) is tuple else line
320 f_out.write(linestr+'\n')
321 return True
322

◆ rename_ref()

python.TrigValSteering.CheckSteps.RegTestStep.rename_ref ( self)

Definition at line 323 of file CheckSteps.py.

323 def rename_ref(self):
324 try:
325 if self.reference:
326 new_name = os.path.basename(self.reference) + '.new'
327 else:
328 new_name = os.path.basename(self.input_file) + '.new'
329 os.rename(self.input_file, new_name)
330 self.log.debug('Renamed %s to %s', self.input_file, new_name)
331 except OSError:
332 self.log.warning('Failed to rename %s to %s',
333 self.input_file, new_name)
334
const bool debug

◆ run()

python.TrigValSteering.CheckSteps.RegTestStep.run ( self,
dry_run = False )

Definition at line 335 of file CheckSteps.py.

335 def run(self, dry_run=False):
336 if not dry_run and not self.prepare_inputs():
337 self.log.error('%s failed in prepare_inputs()', self.name)
338 self.result = 1
339 if self.auto_report_result:
340 self.report_result()
341 return self.result, '# (internal) {} -> failed'.format(self.name)
342 if self.reference is None:
343 self.log.error('Missing reference for %s', self.name)
344 if not dry_run:
345 self.rename_ref()
346 self.result = 999
347 if self.auto_report_result:
348 self.report_result()
349 return self.result, '# (internal) {} -> failed'.format(self.name)
350 retcode, cmd = super(RegTestStep, self).run(dry_run)
351 if not dry_run:
352 self.rename_ref()
353 return retcode, cmd
354
355
Definition run.py:1

Member Data Documentation

◆ auto_report_result

bool python.TrigValSteering.CheckSteps.RegTestStep.auto_report_result = True

Definition at line 300 of file CheckSteps.py.

◆ executable

str python.TrigValSteering.CheckSteps.RegTestStep.executable = 'diff'

Definition at line 298 of file CheckSteps.py.

◆ explicit_reference

bool python.TrigValSteering.CheckSteps.RefComparisonStep.explicit_reference = False
inherited

Definition at line 27 of file CheckSteps.py.

◆ input_base_name

str python.TrigValSteering.CheckSteps.RegTestStep.input_base_name = 'athena'

Definition at line 299 of file CheckSteps.py.

◆ input_file

python.TrigValSteering.CheckSteps.RefComparisonStep.input_file = None
inherited

Definition at line 26 of file CheckSteps.py.

◆ name

python.TrigValSteering.CheckSteps.RefComparisonStep.name
inherited

Definition at line 46 of file CheckSteps.py.

◆ output_stream

python.TrigValSteering.CheckSteps.RegTestStep.output_stream = Step.OutputStream.FILE_AND_STDOUT

Definition at line 301 of file CheckSteps.py.

◆ ref_test_name

python.TrigValSteering.CheckSteps.RefComparisonStep.ref_test_name = None
inherited

Definition at line 25 of file CheckSteps.py.

◆ reference

python.TrigValSteering.CheckSteps.RefComparisonStep.reference = None
inherited

Definition at line 24 of file CheckSteps.py.

◆ regex

str python.TrigValSteering.CheckSteps.RegTestStep.regex = 'REGTEST'

Definition at line 297 of file CheckSteps.py.

◆ required

python.TrigValSteering.CheckSteps.RefComparisonStep.required
inherited

Definition at line 69 of file CheckSteps.py.

◆ result

python.TrigValSteering.CheckSteps.RegTestStep.result = 1

Definition at line 338 of file CheckSteps.py.


The documentation for this class was generated from the following file: