Skip to content

Commit

Permalink
Shorten tests (#209)
Browse files Browse the repository at this point in the history
  • Loading branch information
forsyth2 authored Mar 9, 2022
1 parent 6babd11 commit 9793c65
Show file tree
Hide file tree
Showing 8 changed files with 94 additions and 227 deletions.
33 changes: 3 additions & 30 deletions docs/source/dev_guide/testing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -33,22 +33,10 @@ Before running ``tests/integration/test_complete_run.py`` run the following:
# 1) Edit the paths below
# 2) Edit `output` and `www` parameters in `tests/integration/test_complete_run.cfg`
# 3) Edit `actual_images_dir` in `tests/integration/test_complete_run.py`
rm -rf /lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_test_complete_run_www/20210122.v2_test01.piControl.ne30pg2_EC30to60E2r2-1900_ICG.chrysalis
rm -rf /lcrc/group/e3sm/ac.forsyth2/zppy_test_complete_run_output/20210122.v2_test01.piControl.ne30pg2_EC30to60E2r2-1900_ICG.chrysalis/post
rm -rf /lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_test_complete_run_www/v2.LR.historical_0201
rm -rf /lcrc/group/e3sm/ac.forsyth2/zppy_test_complete_run_output/v2.LR.historical_0201/post
zppy -c tests/integration/test_complete_run.cfg
Before running ``tests/integration/test_environment_commands.py`` run the following:

.. code::
# You'll need to set some paths to your own directories:
# 1) Edit the paths below
# 2) Edit `output`, `www`, and `environment_commands` parameters in `tests/integration/test_environment_commands.cfg`
# 3) Edit `actual_images_dir` in `tests/integration/test_environment_commands.py`
rm -rf /lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_test_environment_commands_www/20210122.v2_test01.piControl.ne30pg2_EC30to60E2r2-1900_ICG.chrysalis
rm -rf /lcrc/group/e3sm/ac.forsyth2/zppy_test_environment_commands_output/20210122.v2_test01.piControl.ne30pg2_EC30to60E2r2-1900_ICG.chrysalis/post
zppy -c tests/integration/test_environment_commands.cfg
Commands to run to replace outdated expected files
--------------------------------------------------

Expand Down Expand Up @@ -78,28 +66,13 @@ To replace the expected images for ``test_complete_run.py`` run the following:
rm -rf /lcrc/group/e3sm/public_html/zppy_test_resources/expected_complete_run
# Your output will now become the new expectation.
# Copy output so you don't have to rerun zppy to generate the output.
cp -r /lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_test_complete_run_www/20210122.v2_test01.piControl.ne30pg2_EC30to60E2r2-1900_ICG.chrysalis /lcrc/group/e3sm/public_html/zppy_test_resources/expected_complete_run
cp -r /lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_test_complete_run_www/v2.LR.historical_0201 /lcrc/group/e3sm/public_html/zppy_test_resources/expected_complete_run
cd /lcrc/group/e3sm/public_html/zppy_test_resources/expected_complete_run
# This file will list all the expected images.
find . -type f -name '*.png' > ../image_list_expected_complete_run.txt
cd <top level of zppy repo>
# Rerun test
python -m unittest tests/integration/test_complete_run.py
To replace the expected images for ``test_environment_commands.py`` run the following:

.. code::
rm -rf /lcrc/group/e3sm/public_html/zppy_test_resources/expected_environment_commands
# Your output will now become the new expectation.
# Copy output so you don't have to rerun zppy to generate the output.
cp -r /lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_test_environment_commands_www/20210122.v2_test01.piControl.ne30pg2_EC30to60E2r2-1900_ICG.chrysalis /lcrc/group/e3sm/public_html/zppy_test_resources/expected_environment_commands
cd /lcrc/group/e3sm/public_html/zppy_test_resources/expected_environment_commands
# This file will list all the expected images.
find . -type f -name '*.png' > ../image_list_expected_environment_commands.txt
cd <top level of zppy repo>
# Rerun test
python -m unittest tests/integration/test_environment_commands.py
Automated tests
===============
Expand Down
72 changes: 46 additions & 26 deletions tests/integration/test_complete_run.cfg
Original file line number Diff line number Diff line change
@@ -1,18 +1,19 @@
[default]
input = /lcrc/group/e3sm/ac.forsyth2/E3SM_simulations/20210122.v2_test01.piControl.ne30pg2_EC30to60E2r2-1900_ICG.chrysalis
input = /lcrc/group/e3sm/ac.forsyth2/E3SMv2/v2.LR.historical_0201
input_subdir = archive/atm/hist
# To run this test, edit `output` and `www` in this file, along with `actual_images_dir` in test_complete_run.py
output = /lcrc/group/e3sm/ac.forsyth2/zppy_test_complete_run_output/20210122.v2_test01.piControl.ne30pg2_EC30to60E2r2-1900_ICG.chrysalis
case = 20210122.v2_test01.piControl.ne30pg2_EC30to60E2r2-1900_ICG.chrysalis
output = /lcrc/group/e3sm/ac.forsyth2/zppy_test_complete_run_output/v2.LR.historical_0201
case = v2.LR.historical_0201
www = /lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_test_complete_run_www
partition = debug
ref_start_yr = 1979
ref_final_yr = 2016
ref_start_yr = 1985
ref_final_yr = 2014
environment_commands = "source /lcrc/soft/climate/e3sm-unified/load_latest_e3sm_unified_chrysalis.sh"

[climo]
active = True
years = "1:100:20", "1:100:50",
walltime = "00:30:00"
years = "1850:1854:2", "1850:1854:4",
# Use default vars

[[ atm_monthly_180x360_aave ]]
Expand All @@ -28,7 +29,8 @@ years = "1:100:20", "1:100:50",

[ts]
active = True
years = "1:100:10",
walltime = "00:30:00"
years = "1850:1854:2",

[[ atm_monthly_180x360_aave ]]
input_subdir = "archive/atm/hist"
Expand All @@ -49,6 +51,7 @@ years = "1:100:10",
input_files = "eam.h0"
frequency = "monthly"
mapping_file = "glb"
years = "1850:1860:5",
# Use default vars

[[ land_monthly ]]
Expand All @@ -68,42 +71,59 @@ years = "1:100:10",

[tc_analysis]
active = True
years = "1:20:20", "1:50:50",
walltime = "00:30:00"
years = "1850:1852:2",
scratch = "/lcrc/globalscratch/ac.forsyth2"

[e3sm_diags]
active = True
years = "1:20:20", "1:50:50",
ts_num_years = 10
# Currently using default `sets`
walltime = "00:30:00"
years = "1850:1854:2", "1850:1854:4",
ts_num_years = 2
short_name = 'v2.LR.historical_0201'
grid = '180x360_aave'
reference_data_path = '/lcrc/soft/climate/e3sm_diags_data/obs_for_e3sm_diags/climatology'
obs_ts = '/lcrc/soft/climate/e3sm_diags_data/obs_for_e3sm_diags/time-series'

[[ atm_monthly_180x360_aave ]]
short_name = '20210122.v2_test01.piControl.ne30pg2_EC30to60E2r2-1900_ICG.chrysalis'
grid = '180x360_aave'
reference_data_path = '/lcrc/soft/climate/e3sm_diags_data/obs_for_e3sm_diags/climatology'
obs_ts = '/lcrc/soft/climate/e3sm_diags_data/obs_for_e3sm_diags/time-series'
sets = "lat_lon","zonal_mean_xy","zonal_mean_2d","polar","cosp_histogram","meridional_mean_2d","enso_diags","qbo","diurnal_cycle","annual_cycle_zonal_mean","streamflow", "zonal_mean_2d_stratosphere",
dc_obs_climo = '/lcrc/group/e3sm/public_html/e3sm_diags_test_data/unit_test_complete_run/obs/climatology'
climo_diurnal_subsection = "atm_monthly_diurnal_8xdaily_180x360_aave"
climo_diurnal_frequency = "diurnal_8xdaily"
streamflow_obs_ts = '/lcrc/group/e3sm/public_html/e3sm_diags_test_data/unit_test_complete_run/obs/time-series/'

[[ atm_monthly_180x360_aave_environment_commands ]]
sets = "qbo",
environment_commands="source /home/ac.forsyth2/miniconda3/etc/profile.d/conda.sh; conda activate e3sm_diags_dev_20220228"
climo_subsection = "atm_monthly_180x360_aave"
ts_subsection = "atm_monthly_180x360_aave"

[[ atm_monthly_180x360_aave_tc_analysis ]]
# Running as its own subtask because tc_analysis requires jobs to run sequentially, which slows down testing
sets = "tc_analysis",
years = "1850:1852:2",
climo_subsection = "atm_monthly_180x360_aave"
ts_subsection = "atm_monthly_180x360_aave"
tc_obs = '/lcrc/group/e3sm/public_html/diagnostics/observations/Atm/tc-analysis/'

[mpas_analysis]
active = True
walltime = "00:30:00"
partition = compute
walltime = "24:00:00"
parallelTaskCount = 6
ts_years = "1-50", "1-100",
enso_years = "11-50", "11-100",
climo_years ="21-50", "51-100",
anomalyRefYear = 1850
ts_years = "1850-1854", "1850-1860",
enso_years = "1850-1854", "1855-1860",
climo_years ="1850-1854", "1855-1860",
mesh = "EC30to60E2r2"

[global_time_series]
active = True
years = "1-100",
ts_num_years = 10
figstr=coupled_v2_test01
moc_file=mocTimeSeries_0001-0100.nc
experiment_name=20210122.v2_test01.piControl.chrysalis
ts_years = "1-50", "1-100",
climo_years ="21-50", "51-100",
walltime = "00:30:00"
years = "1850-1860",
ts_num_years = 5
figstr = "v2_historical_0201"
moc_file=mocTimeSeries_1850-1860.nc
experiment_name = "v2.LR.historical_0201"
ts_years = "1850-1854", "1850-1860",
climo_years ="1850-1854", "1855-1860",
2 changes: 1 addition & 1 deletion tests/integration/test_complete_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ def compare_images(
class TestCompleteRun(unittest.TestCase):
def test_complete_run(self):
# See docs/source/dev_guide/testing.rst for steps to run before running this test.
actual_images_dir = "/lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_test_complete_run_www/20210122.v2_test01.piControl.ne30pg2_EC30to60E2r2-1900_ICG.chrysalis"
actual_images_dir = "/lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_test_complete_run_www/v2.LR.historical_0201"

# The expected_images_file lists all images we expect to compare.
expected_images_file = "/lcrc/group/e3sm/public_html/zppy_test_resources/image_list_expected_complete_run.txt"
Expand Down
45 changes: 0 additions & 45 deletions tests/integration/test_environment_commands.cfg

This file was deleted.

105 changes: 0 additions & 105 deletions tests/integration/test_environment_commands.py

This file was deleted.

18 changes: 13 additions & 5 deletions zppy/e3sm_diags.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,11 @@ def e3sm_diags(config, scriptDir):
c["year2"] = s[1]
c["scriptDir"] = scriptDir
if c["subsection"]:
sub = c["subsection"]
c["sub"] = c["subsection"]
else:
sub = c["grid"]
c["sub"] = c["grid"]
prefix = "e3sm_diags_%s_%s_%04d-%04d" % (
sub,
c["sub"],
c["tag"],
c["year1"],
c["year2"],
Expand All @@ -59,10 +59,14 @@ def e3sm_diags(config, scriptDir):
f.write(template.render(**c))

# List of dependencies
if "climo_subsection" in c.keys():
climo_sub = c["climo_subsection"]
else:
climo_sub = c["sub"]
dependencies.append(
os.path.join(
scriptDir,
"climo_%s_%04d-%04d.status" % (sub, c["year1"], c["year2"]),
"climo_%s_%04d-%04d.status" % (climo_sub, c["year1"], c["year2"]),
),
)
if "diurnal_cycle" in c["sets"]:
Expand Down Expand Up @@ -90,11 +94,15 @@ def e3sm_diags(config, scriptDir):
or ("qbo" in c["sets"])
or ("area_mean_time_series" in c["sets"])
):
if "ts_subsection" in c.keys():
ts_sub = c["ts_subsection"]
else:
ts_sub = c["sub"]
dependencies.append(
os.path.join(
scriptDir,
"ts_%s_%04d-%04d-%04d.status"
% (sub, start_yr, end_yr, c["ts_num_years"]),
% (ts_sub, start_yr, end_yr, c["ts_num_years"]),
)
)
if "streamflow" in c["sets"]:
Expand Down
Loading

0 comments on commit 9793c65

Please sign in to comment.