Skip to content

Commit

Permalink
Exit code check (#933)
Browse files Browse the repository at this point in the history
* Always check the exit code in Tester, unless explicitly overriden.

* Updating gitignores.

* Using correct name for graph variable.

* Fixing use of keys() and str() that fails in Python3.

* Removing unused and not working ROM prints.

* Fixing to work with Python3.

* Switching some tests to error tests because they test errors.

* Removing unused and nonworking ROM printing.

* Skipping test that is missing a file needed to run successfully.

* Fixing review comment.
  • Loading branch information
joshua-cogliati-inl authored and alfoa committed Mar 26, 2019
1 parent c5191d0 commit da3551f
Show file tree
Hide file tree
Showing 17 changed files with 57 additions and 53 deletions.
2 changes: 1 addition & 1 deletion framework/MessageHandler.py
Original file line number Diff line number Diff line change
Expand Up @@ -287,7 +287,7 @@ def checkVerbosity(self,verb):
@ Out, currentVerb, int, integer equivalent to verbosity level
"""
if str(verb).strip().lower() not in self.verbCode.keys():
raise IOError('Verbosity key '+str(verb)+' not recognized! Options are '+str(self.verbCode.keys()+[None]),'ERROR','silent')
raise IOError('Verbosity key '+str(verb)+' not recognized! Options are '+str(list(self.verbCode.keys())+[None]),'ERROR','silent')
currentVerb = self.verbCode[str(verb).strip().lower()]
return currentVerb

Expand Down
4 changes: 2 additions & 2 deletions framework/Samplers/AdaptiveDynamicEventTree.py
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ def _checkClosestBranch(self):
if nntrain is not None:
neigh = neighbors.NearestNeighbors(n_neighbors=len(mapping.keys()))
neigh.fit(nntrain)
valBranch = self._checkValidityOfBranch(neigh.kneighbors([lowerCdfValues.values()]),mapping)
valBranch = self._checkValidityOfBranch(neigh.kneighbors([list(lowerCdfValues.values())]),mapping)
if self.hybridDETstrategy is not None:
returnTuple = valBranch,cdfValues,treer
else:
Expand Down Expand Up @@ -331,7 +331,7 @@ def _constructEndInfoFromBranch(self,model, myInput, info, cdfValues):
# The probability Thresholds are stored here in the cdfValues dictionary... We are sure that they are whitin the ones defined in the grid
# check is not needed
self.inputInfo['initiatorDistribution' ] = [self.toBeSampled[key] for key in cdfValues.keys()]
self.inputInfo['PbThreshold' ] = cdfValues.values()
self.inputInfo['PbThreshold' ] = list(cdfValues.values())
self.inputInfo['ValueThreshold' ] = [self.distDict[key].ppf(value) for key,value in cdfValues.items()]
self.inputInfo['SampledVars' ] = {}
self.inputInfo['SampledVarsPb' ] = {}
Expand Down
3 changes: 3 additions & 0 deletions rook/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
doc/rook.aux
doc/rook.log
doc/rook.pdf
4 changes: 1 addition & 3 deletions rook/GenericExecutable.py
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,5 @@ def process_results(self, _):
@ In, ignored, string, the output from the test case.
@ Out, None
"""
if self.results.exit_code != 0:
self.set_fail(str(self.results.exit_code))
return
#If the exit code != 0 then check_exit_code will fail the test.
self.set_success()
15 changes: 15 additions & 0 deletions rook/Tester.py
Original file line number Diff line number Diff line change
Expand Up @@ -560,6 +560,8 @@ def _run_backend(self, _):
self.results.group = self.group_timed_out
self.results.message = "Timed Out"
return self.results
if not self.check_exit_code(self.results.exit_code):
return self.results
self.process_results(output)
self._wait_for_all_written()
for differ in self.__differs:
Expand Down Expand Up @@ -645,6 +647,19 @@ def set_diff(self, message):
self.results.message = message
self.results.group = self.group_diff

def check_exit_code(self, exit_code):
"""
Lets the subclasses decide if the exit code fails the test.
@ In, exit_code, int, the exit code of the test command.
@ Out, check_exit_code, bool, if true the exit code is acceptable.
If false the tester should use set_fail or other methods to set the
status and message.
"""
if exit_code != 0:
self.set_fail("Running test failed with exit code "+str(exit_code))
return False
return True

def process_results(self, output):
"""
Handle the results of the test case.
Expand Down
4 changes: 1 addition & 3 deletions scripts/TestHarness/testers/CrowPython.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,6 @@ def process_results(self, output):
@ In, output: the output from the test case.
@ Out: a tuple with the error return code and the output passed in.
"""
if self.results.exit_code != 0:
self.set_fail(str(self.results.exit_code))
return output
#check_exit_code fails test if != 0 so passes
self.set_success()
return output
9 changes: 9 additions & 0 deletions scripts/TestHarness/testers/RavenErrors.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,3 +129,12 @@ def process_results(self, output):
self.set_success()
return
self.set_fail('The expected Error: ' +self.specs['expect_err']+' is not raised!')

def check_exit_code(self, _):
"""
Allow any exit code (but this could be extended to have an expected exit
code in the parameters at some point)
@ In, exit_code, int, the exit code of the test command.
@ Out, check_exit_code, bool, always True since errors are expected
"""
return True
4 changes: 1 addition & 3 deletions scripts/TestHarness/testers/RavenPython.py
Original file line number Diff line number Diff line change
Expand Up @@ -172,7 +172,5 @@ def process_results(self, _):
@ In, ignored, string, output of running the test.
@ Out, None
"""
if self.results.exit_code != 0:
self.set_fail(str(self.results.exit_code))
return
#check_exit_code fails test if != 0, so pass.
self.set_success()
12 changes: 12 additions & 0 deletions tests/framework/CodeInterfaceTests/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -87,3 +87,15 @@ Scale/SCALE_triton_origen_combined/sampleScale/2/decay_origen.inp
Scale/SCALE_triton_origen_combined/sampleScale/2/input_triton.inp
Scale/SCALE_triton_origen_combined/sampleScale/decay_origen.inp
Scale/SCALE_triton_origen_combined/sampleScale/input_triton.inp
RELAP5/RELAP5ensemble2relaps/testEnsemble2Relaps/MyRELAP++1
RELAP5/RELAP5ensemble2relaps/testEnsemble2Relaps/MyRELAP++2
RELAP5/RELAP5ensemble2relaps/testEnsemble2Relaps/MyRELAP_restart++1
RELAP5/RELAP5ensemble2relaps/testEnsemble2Relaps/MyRELAP_restart++2
RELAP5/RELAP5ensemble2relaps/testEnsemble2Relaps
RELAP5/RELAP5interfaceTest/testDummyStep
RELAP5/RELAP5interfaceTestAlias/testDummyStep
RELAP5/RELAP5interfaceTestMultiDeck/testDummyStep
RELAP5/RELAP5interfaceTestMultiDeckChoosingDeck/testDummyStep
RELAP5/RELAP5interfaceTestOperator/testDummyStep
RELAP5/RELAP5interfaceTestSingleRun/testDummyStep
RELAP5interfaceTestModifiedVersionINSS/
1 change: 1 addition & 0 deletions tests/framework/CodeInterfaceTests/tests
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@
input = 'test_maap5_code_interface_adaptive_det.xml'
UnorderedCsv = 'MAAP5_adaptiveDET_test/limitSurfDump.csv'
test_interface_only = True
skip = 'Missing file needed to run'
rel_err = 0.0001
[../]
[./MAAP5interfaceAHDETSampling]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@
<plot>
<type>line</type>
<x>mData|Output|Time</x>
<y>mData|Output|PCAEmbeddingVector1</y>
<y>mData|Output|PCADimension1</y>
<interpPointsX>300</interpPointsX>
<gridLocation>
<x>0</x>
Expand All @@ -86,7 +86,7 @@
<plot>
<type>line</type>
<x>mData|Output|Time</x>
<y>mData|Output|PCAEmbeddingVector2</y>
<y>mData|Output|PCADimension2</y>
<interpPointsX>300</interpPointsX>
<gridLocation>
<x>1</x>
Expand Down
8 changes: 4 additions & 4 deletions tests/framework/Samplers/AdaptiveBatch/tests
Original file line number Diff line number Diff line change
Expand Up @@ -84,14 +84,14 @@
remove_unicode_identifier = true
[../]
[./InvalidScoringStrategy]
type = 'RavenFramework'
type = 'RavenErrors'
input = 'test_invalid_score.xml'
xml = ''
expect_err = ' Requested unknown scoring type: '
[../]
[./InvalidBatchStrategy]
type = 'RavenFramework'
type = 'RavenErrors'
input = 'test_invalid_batch.xml'
xml = ''
expect_err = 'Requested unknown batch strategy:'
[../]
[./InvalidThickness]
type = 'RavenFramework'
Expand Down
8 changes: 1 addition & 7 deletions tests/framework/Samplers/Restart/test_restart_sobol.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Simulation verbosity="debug">
<RunInfo>
<WorkingDir>sobol</WorkingDir>
<Sequence>makeCoarse,makeRestart,makeFine,trainRestart,trainFine,print,printROM</Sequence>
<Sequence>makeCoarse,makeRestart,makeFine,trainRestart,trainFine,print</Sequence>
<batchSize>1</batchSize>
</RunInfo>
<TestInfo>
Expand Down Expand Up @@ -47,12 +47,6 @@
<Output class="OutStreams" type="Print">restart</Output>
<Output class="OutStreams" type="Print">fine</Output>
</IOStep>
<IOStep name="printROM">
<Input class="Models" type="ROM">romRestart</Input>
<Input class="Models" type="ROM">romFine</Input>
<Output class="OutStreams" type="Print">romRestart</Output>
<Output class="OutStreams" type="Print">romFine</Output>
</IOStep>
<RomTrainer name="trainRestart">
<Input class="DataObjects" type="PointSet">solnsRestart</Input>
<Output class="Models" type="ROM">romRestart</Output>
Expand Down
8 changes: 1 addition & 7 deletions tests/framework/Samplers/Restart/test_restart_stochpoly.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Simulation>
<RunInfo>
<WorkingDir>sparsegrid</WorkingDir>
<Sequence>makeCoarse,makeRestart,makeFine,trainRestart,trainFine,print,printROM</Sequence>
<Sequence>makeCoarse,makeRestart,makeFine,trainRestart,trainFine,print</Sequence>
<batchSize>1</batchSize>
</RunInfo>
<TestInfo>
Expand Down Expand Up @@ -47,12 +47,6 @@
<Output class="OutStreams" type="Print">restart</Output>
<Output class="OutStreams" type="Print">fine</Output>
</IOStep>
<IOStep name="printROM">
<Input class="Models" type="ROM">romRestart</Input>
<Input class="Models" type="ROM">romFine</Input>
<Output class="OutStreams" type="Print">romRestart</Output>
<Output class="OutStreams" type="Print">romFine</Output>
</IOStep>
<RomTrainer name="trainRestart">
<Input class="DataObjects" type="PointSet">solnsRestart</Input>
<Output class="Models" type="ROM">romRestart</Output>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Simulation printTimeStamps="false" verbosity="debug">
<RunInfo>
<WorkingDir>scgpcMVNCorrelated</WorkingDir>
<Sequence>Nmake,Nprint1,Ntrain,Ntest,Nprint2</Sequence>
<Sequence>Nmake,Nprint1,Ntrain,Ntest</Sequence>
<batchSize>1</batchSize>
</RunInfo>
<TestInfo>
Expand Down Expand Up @@ -76,12 +76,6 @@
<Input class="DataObjects" type="PointSet">Nsolns</Input>
<Output class="OutStreams" type="Print">Ndump</Output>
</IOStep>
<IOStep name="Nprint2">
<Input class="DataObjects" type="PointSet">Ntests</Input>
<Input class="Models" type="ROM">NROM</Input>
<Output class="OutStreams" type="Print">ROMdump1</Output>
<Output class="OutStreams" type="Print">ROMdump2</Output>
</IOStep>
<RomTrainer name="Ntrain">
<Input class="DataObjects" type="PointSet">Nsolns</Input>
<Output class="Models" type="ROM">NROM</Output>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Simulation printTimeStamps="false">
<RunInfo>
<WorkingDir>scgpc</WorkingDir>
<Sequence>Nmake,Nprint1,Ntrain,Ntest,Nprint2</Sequence>
<Sequence>Nmake,Nprint1,Ntrain,Ntest</Sequence>
<batchSize>1</batchSize>
</RunInfo>
<TestInfo>
Expand Down Expand Up @@ -71,12 +71,6 @@
<Input class="DataObjects" type="PointSet">Nsolns</Input>
<Output class="OutStreams" type="Print">Ndump</Output>
</IOStep>
<IOStep name="Nprint2">
<Input class="DataObjects" type="PointSet">Ntests</Input>
<Input class="Models" type="ROM">NROM</Input>
<Output class="OutStreams" type="Print">ROMdump1</Output>
<Output class="OutStreams" type="Print">ROMdump2</Output>
</IOStep>
<RomTrainer name="Ntrain">
<Input class="DataObjects" type="PointSet">Nsolns</Input>
<Output class="Models" type="ROM">NROM</Output>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<Simulation printTimeStamps="false" verbosity="debug">
<RunInfo>
<WorkingDir>scgpcMVNUncorrelated</WorkingDir>
<Sequence>Nmake,Nprint1,Ntrain,Ntest,Nprint2</Sequence>
<Sequence>Nmake,Nprint1,Ntrain,Ntest</Sequence>
<batchSize>1</batchSize>
</RunInfo>
<TestInfo>
Expand Down Expand Up @@ -76,12 +76,6 @@
<Input class="DataObjects" type="PointSet">Nsolns</Input>
<Output class="OutStreams" type="Print">Ndump</Output>
</IOStep>
<IOStep name="Nprint2">
<Input class="DataObjects" type="PointSet">Ntests</Input>
<Input class="Models" type="ROM">NROM</Input>
<Output class="OutStreams" type="Print">ROMdump1</Output>
<Output class="OutStreams" type="Print">ROMdump2</Output>
</IOStep>
<RomTrainer name="Ntrain">
<Input class="DataObjects" type="PointSet">Nsolns</Input>
<Output class="Models" type="ROM">NROM</Output>
Expand Down

0 comments on commit da3551f

Please sign in to comment.