Skip to content

Commit

Permalink
Skip validation if comparison test not run
Browse files Browse the repository at this point in the history
If the necessary output files for performing validation against
the version of each test case without inactive top cells aren't
present, skip validation with a warning message.
  • Loading branch information
xylar committed Aug 3, 2021
1 parent 483cff6 commit c0d5b9e
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 14 deletions.
21 changes: 14 additions & 7 deletions compass/ocean/tests/global_ocean/init/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,24 @@ def validate(self):

if self.with_inactive_top_cells:
# construct the work directory for the other test
filename1 = 'initial_state/initial_state_crop.nc'
filename2 = os.path.join(self.base_work_dir, self.mpas_core.name,
self.test_group.name,
self.inactive_top_comp_subdir,
'init/initial_state/initial_state.nc')
variables = [
'temperature', 'salinity', 'layerThickness', 'normalVelocity']
compare_variables(test_case=self, variables=variables,
filename1='initial_state/initial_state_crop.nc',
filename2=filename2, quiet=False,
check_outputs=False,
skip_if_step_not_run=False)
if os.path.exists(filename2):
variables = [
'temperature', 'salinity', 'layerThickness',
'normalVelocity']
compare_variables(test_case=self, variables=variables,
filename1=filename1, filename2=filename2,
quiet=False, check_outputs=False,
skip_if_step_not_run=False)

else:
self.logger.warn('The version of "init" without inactive top '
'cells was not run. Skipping\n'
'validation.')

if self.mesh.with_ice_shelf_cavities:
variables = ['ssh', 'landIcePressure']
Expand Down
20 changes: 13 additions & 7 deletions compass/ocean/tests/global_ocean/performance_test/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -65,19 +65,25 @@ def validate(self):

if self.init.with_inactive_top_cells:
# construct the work directory for the other test
filename1 = 'forward/output_crop.nc'

subdir = get_forward_subdir(self.init.inactive_top_comp_subdir,
self.time_integrator, self.name)
filename2 = os.path.join(self.base_work_dir, self.mpas_core.name,
self.test_group.name, subdir,
'forward/output.nc')

variables = ['temperature', 'salinity', 'layerThickness',
'normalVelocity']
compare_variables(test_case=self, variables=variables,
filename1='forward/output_crop.nc',
filename2=filename2,
quiet=False, check_outputs=False,
skip_if_step_not_run=False)
if os.path.exists(filename2):
variables = ['temperature', 'salinity', 'layerThickness',
'normalVelocity']
compare_variables(test_case=self, variables=variables,
filename1=filename1, filename2=filename2,
quiet=False, check_outputs=False,
skip_if_step_not_run=False)
else:
self.logger.warn('The version of "performance_test" without '
'inactive top cells was not run.\n'
'Skipping validation.')

if self.mesh.with_ice_shelf_cavities:
variables = [
Expand Down

0 comments on commit c0d5b9e

Please sign in to comment.