Skip to content

Enable partial updates of expected results for testing - #852

Open
forsyth2 wants to merge 3 commits into
mainfrom
partial-update-expectations
Open

Enable partial updates of expected results for testing#852
forsyth2 wants to merge 3 commits into
mainfrom
partial-update-expectations

Conversation

@forsyth2

@forsyth2 forsyth2 commented Aug 13, 2026

Copy link
Copy Markdown
Collaborator

Summary

Objectives:

  • Update the scripts that update expected results, along with accompanying documentation to allow for partial updates. For example, if we've confirmed new expected results look good for one task but not another, then we may want to only update the expected results for the former.

Select one: This pull request is...

  • a bug fix: increment the patch version
  • a small improvement: increment the minor version
  • a new feature: increment the minor version
  • an incompatible (non-backwards compatible) API change: increment the major version

Small Change

  • To merge, I will use "Squash and merge". That is, this change should be a single commit.
  • Logic: I have visually inspected the entire pull request myself.
  • Pre-commit checks: All the pre-commits checks have passed.

Previously, update_weekly_expected_files_*.sh and
update_campaign_expected_files.sh always overwrote every diag
subdirectory (e.g. e3sm_diags, mpas_analysis, ilamb, ...) or every
campaign in one pass, making it impossible to accept new results for
one diagnostic while leaving another pinned to its old expected output.

- template_update_weekly_expected_files.sh: add a `diags` selector
  array. Empty (default) preserves the old full-wipe-and-copy
  behavior. Populated (e.g. diags=("e3sm_diags")), only those
  subdirectories are refreshed; "bundle_files" is selectable the
  same way for the bundle*.bash copy step. The image list is still
  generated by walking the full directory, so it reflects both
  updated and untouched diags.

- template_update_campaign_expected_files.sh: hardcoded campaign
  list replaced with a `campaigns` array for the same kind of subset
  updates.

- template_update_bash_generation_expected_files.sh and
  template_update_defaults_expected_files.sh: unchanged -- each
  produces a single expected-files dir with nothing to partially select.

- docs/source/dev_guide/tests/update_expected_results.rst: document
  the new selectors and note the full backup step should still
  always run first.

This diff was generated by Claude (Anthropic).
Add the `update_` files that `python tests/integration/utils.py` creates.
@forsyth2 forsyth2 self-assigned this Aug 13, 2026
@forsyth2 forsyth2 added Documentation Files in `docs` modified Testing Files in `tests` modified labels Aug 13, 2026
@forsyth2

Copy link
Copy Markdown
Collaborator Author

Updating expected results for the 8/12 test run

Set up branch
git checkout partial-update-expectations
git fetch upstream main
git rebase upstream/main
git log --oneline | head -n 4
# b5d41f34 Add auto-generated update files
# ef72638c Change term from diags to tasks
# fffd2338 Support partial updates of weekly/campaign expected test results
# 4735ef4d Merge pull request #854 from E3SM-Project/update-pre-commit-deps

lcrc_conda
rm -rf build
conda clean --all --y
conda env create -f conda/dev.yml -n zppy-pr852-20260814 
conda activate zppy-pr852-20260814 
pre-commit run --all-files
python -m pip install .

cd docs
make html
cp -r _build/ /lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_docs_pr852
chmod -R 755 /lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_docs_pr852

Visit: https://web.lcrc.anl.gov/public/e3sm/diagnostic_output/ac.forsyth2/zppy_docs_pr852/html/dev_guide/tests/update_expected_results.html

# First, let's copy over the old expected results #############################
cp -r /lcrc/group/e3sm/public_html/zppy_test_resources /lcrc/group/e3sm/public_html/zppy_test_resources_previous/expected_results_until_20260814 # < 30 min

# Second, update the expected results #########################################
# Let's update the simpler tests' results first:
cd /lcrc/group/e3sm/ac.forsyth2/zppy_main_branch_test_dirs/zppy
git status
# You might have changed branches since you ran the tests.
# Good, on correct branch: test_zppy_20260812_run1
conda activate test-zppy-main-20260812_run1
# Good, now on correct env

# Make sure the update script permissions are set up
chmod 755 tests/integration/generated/update_bash_generation_expected_files_chrysalis.sh
chmod 755 tests/integration/generated/update_campaign_expected_files_chrysalis.sh
chmod 755 tests/integration/generated/update_defaults_expected_files_chrysalis.sh
chmod 755 tests/integration/generated/update_weekly_expected_files_chrysalis.sh

# Specific to partial updates:
# Update the task list
emacs tests/integration/generated/update_weekly_expected_files_chrysalis.sh
# This doesn't have the necessary lines yet because PR #852 didn't exist when this was run!
git add -A
git commit -m "Changes made during testing"
# Remove the old templates and replace with the files from PR #852
rm tests/integration/template_update_campaign_expected_files.sh
rm tests/integration/template_update_weekly_expected_files.sh
emacs tests/integration/template_update_campaign_expected_files.sh
emacs tests/integration/template_update_weekly_expected_files.sh
git diff # Looks ok
git add -A
git commit -m "Copy changes from PR 852"
# Now, we need to re-render the generated files
python tests/integration/utils.py
git diff # Looks ok
chmod 755 tests/integration/generated/update_campaign_expected_files_chrysalis.sh
chmod 755 tests/integration/generated/update_weekly_expected_files_chrysalis.sh
# Double check we have a record of the original expected results
ls -lt /lcrc/group/e3sm/public_html/zppy_test_resources_previous/expected_results_until_20260814
# Update the task list now that it's available:
emacs tests/integration/generated/update_weekly_expected_files_chrysalis.sh
# These are the 3 tasks we know we can update the expected results for:
# tasks=("e3sm_diags" "global_time_series" "pcmdi_diags")
git add -A
git commit -m "Update the update scripts"

# These scripts update the expected results and re-run the tests:
./tests/integration/generated/update_bash_generation_expected_files_chrysalis.sh
# 1 passed in 2.84s
./tests/integration/generated/update_campaign_expected_files_chrysalis.sh
# 6 passed in 2.43s
./tests/integration/generated/update_defaults_expected_files_chrysalis.sh
# 1 passed in 0.72s

# This script only updates the expected results
./tests/integration/generated/update_weekly_expected_files_chrysalis.sh # ~30 min

Skipped because pcmdi_diags only exists in one of the subdirs

WARNING: /lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_weekly_comprehensive_v2_www/zppy_main_branch_test_20260812_run1/v2.LR.historical_0201/pcmdi_diags does not exist -- skipping (test_name=comprehensive_v2).
WARNING: /lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_weekly_bundles_www/zppy_main_branch_test_20260812_run1/v3.LR.historical_0051/pcmdi_diags does not exist -- skipping (test_name=bundles).
WARNING: /lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_weekly_legacy_3.1.0_comprehensive_v2_www/zppy_main_branch_test_20260812_run1/v2.LR.historical_0201/pcmdi_diags does not exist -- skipping (test_name=legacy_3.1.0_comprehensive_v2).
WARNING: /lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_weekly_legacy_3.1.0_bundles_www/zppy_main_branch_test_20260812_run1/v3.LR.historical_0051/pcmdi_diags does not exist -- skipping (test_name=legacy_3.1.0_bundles).
WARNING: /lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_weekly_legacy_3.0.0_comprehensive_v2_www/zppy_main_branch_test_20260812_run1/v2.LR.historical_0201/pcmdi_diags does not exist -- skipping (test_name=legacy_3.0.0_comprehensive_v2).
WARNING: /lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_weekly_legacy_3.0.0_comprehensive_v3_www/zppy_main_branch_test_20260812_run1/v3.LR.historical_0051/pcmdi_diags does not exist -- skipping (test_name=legacy_3.0.0_comprehensive_v3).
WARNING: /lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_weekly_legacy_3.0.0_bundles_www/zppy_main_branch_test_20260812_run1/v3.LR.historical_0051/pcmdi_diags does not exist -- skipping (test_name=legacy_3.0.0_bundles).
ls /lcrc/group/e3sm/public_html/zppy_test_resources
# Confirmed there are expected results subdirs and image lists for each cfg
ls -lt /lcrc/group/e3sm/public_html/zppy_test_resources 
# Confirmed everything was updated today 8/14

cd /lcrc/group/e3sm/ac.forsyth2/zppy_main_branch_test_dirs/zppy
pytest tests/integration/test_bundles.py
# 2 passed in 1.53s
salloc --nodes=1 --partition=debug --time=02:00:00 --account=e3sm
bash
source ~/.bashrc
lcrc_conda
conda activate test-zppy-main-20260812_run1
pytest tests/integration/test_images.py # ~40 min
exit # Exit bash shell
exit # Exit compute note
Output

Output:

---------------------------------------------------- Captured stdout call ----------------------------------------------------
Preparing weekly cfg tests
Preparing legacy 3.1.0 cfg tests
Preparing legacy 3.0.0 cfg tests
Running 9 tests in parallel
Individual test logs will be written to test_<name>.log files
✓ Completed: bundles (3 tasks) (log: test_bundles.log)
✓ Completed: legacy_3.1.0_bundles (3 tasks) (log: test_legacy_3.1.0_bundles.log)
✓ Completed: legacy_3.1.0_comprehensive_v2 (4 tasks) (log: test_legacy_3.1.0_comprehensive_v2.log)
✓ Completed: comprehensive_v2 (4 tasks) (log: test_comprehensive_v2.log)
✓ Completed: legacy_3.0.0_comprehensive_v2 (4 tasks) (log: test_legacy_3.0.0_comprehensive_v2.log)
✓ Completed: legacy_3.0.0_bundles (3 tasks) (log: test_legacy_3.0.0_bundles.log)
✓ Completed: legacy_3.1.0_comprehensive_v3 (4 tasks) (log: test_legacy_3.1.0_comprehensive_v3.log)
✓ Completed: legacy_3.0.0_comprehensive_v3 (4 tasks) (log: test_legacy_3.0.0_comprehensive_v3.log)
✓ Completed: comprehensive_v3 (5 tasks) (log: test_comprehensive_v3.log)
Copy the output of test_images_summary.md to a Pull Request comment

Test Summary:
Test                                                    Total    Correct     Status
----------------------------------------------------------------------------------
bundles_e3sm_diags                                       1762       1762     ✓ PASS
bundles_global_time_series                                  3          3     ✓ PASS
bundles_ilamb                                             388        388     ✓ PASS
comprehensive_v2_e3sm_diags                              3816       3816     ✓ PASS
comprehensive_v2_mpas_analysis                            856          4     ✗ FAIL
comprehensive_v2_global_time_series                        12         12     ✓ PASS
comprehensive_v2_ilamb                                    776        776     ✓ PASS
comprehensive_v3_e3sm_diags                              5389       5389     ✓ PASS
comprehensive_v3_mpas_analysis                           1280          6     ✗ FAIL
comprehensive_v3_global_time_series                      1404       1404     ✓ PASS
comprehensive_v3_ilamb                                    837        837     ✓ PASS
comprehensive_v3_pcmdi_diags                              647        647     ✓ PASS
legacy_3.1.0_bundles_e3sm_diags                          1762       1762     ✓ PASS
legacy_3.1.0_bundles_global_time_series                     3          3     ✓ PASS
legacy_3.1.0_bundles_ilamb                                388        388     ✓ PASS
legacy_3.1.0_comprehensive_v2_e3sm_diags                 3816       3816     ✓ PASS
legacy_3.1.0_comprehensive_v2_mpas_analysis               856          4     ✗ FAIL
legacy_3.1.0_comprehensive_v2_global_time_series           12         12     ✓ PASS
legacy_3.1.0_comprehensive_v2_ilamb                       776        776     ✓ PASS
legacy_3.1.0_comprehensive_v3_e3sm_diags                 5385       5385     ✓ PASS
legacy_3.1.0_comprehensive_v3_mpas_analysis               856          4     ✗ FAIL
legacy_3.1.0_comprehensive_v3_global_time_series         1404       1404     ✓ PASS
legacy_3.1.0_comprehensive_v3_ilamb                       837        837     ✓ PASS
legacy_3.0.0_bundles_e3sm_diags                          1762       1762     ✓ PASS
legacy_3.0.0_bundles_global_time_series                     3          3     ✓ PASS
legacy_3.0.0_bundles_ilamb                                388        388     ✓ PASS
legacy_3.0.0_comprehensive_v2_e3sm_diags                 3816       3816     ✓ PASS
legacy_3.0.0_comprehensive_v2_mpas_analysis               856          4     ✗ FAIL
legacy_3.0.0_comprehensive_v2_global_time_series           12         12     ✓ PASS
legacy_3.0.0_comprehensive_v2_ilamb                       776        776     ✓ PASS
legacy_3.0.0_comprehensive_v3_e3sm_diags                 5385       5385     ✓ PASS
legacy_3.0.0_comprehensive_v3_mpas_analysis               856          4     ✗ FAIL
legacy_3.0.0_comprehensive_v3_global_time_series           90         90     ✓ PASS
legacy_3.0.0_comprehensive_v3_ilamb                       837        837     ✓ PASS
----------------------------------------------------------------------------------

⚠ Some tests had mismatched or missing images. Check individual log files for details.
================================================== short test summary info ===================================================
FAILED tests/integration/test_images.py::test_images - assert 856 == 4
=============================================== 1 failed in 2490.95s (0:41:30) ===============================================

cat test_images_summary.md:

Test name Total images Correct images Missing images Mismatched images
bundles_e3sm_diags 1762 1762 0 0
bundles_global_time_series 3 3 0 0
bundles_ilamb 388 388 0 0
comprehensive_v2_e3sm_diags 3816 3816 0 0
comprehensive_v2_mpas_analysis 856 4 0 852 (list, grid)
comprehensive_v2_global_time_series 12 12 0 0
comprehensive_v2_ilamb 776 776 0 0
comprehensive_v3_e3sm_diags 5389 5389 0 0
comprehensive_v3_mpas_analysis 1280 6 0 1274 (list, grid)
comprehensive_v3_global_time_series 1404 1404 0 0
comprehensive_v3_ilamb 837 837 0 0
comprehensive_v3_pcmdi_diags 647 647 0 0
legacy_3.1.0_bundles_e3sm_diags 1762 1762 0 0
legacy_3.1.0_bundles_global_time_series 3 3 0 0
legacy_3.1.0_bundles_ilamb 388 388 0 0
legacy_3.1.0_comprehensive_v2_e3sm_diags 3816 3816 0 0
legacy_3.1.0_comprehensive_v2_mpas_analysis 856 4 0 852 (list, grid)
legacy_3.1.0_comprehensive_v2_global_time_series 12 12 0 0
legacy_3.1.0_comprehensive_v2_ilamb 776 776 0 0
legacy_3.1.0_comprehensive_v3_e3sm_diags 5385 5385 0 0
legacy_3.1.0_comprehensive_v3_mpas_analysis 856 4 0 852 (list, grid)
legacy_3.1.0_comprehensive_v3_global_time_series 1404 1404 0 0
legacy_3.1.0_comprehensive_v3_ilamb 837 837 0 0
legacy_3.0.0_bundles_e3sm_diags 1762 1762 0 0
legacy_3.0.0_bundles_global_time_series 3 3 0 0
legacy_3.0.0_bundles_ilamb 388 388 0 0
legacy_3.0.0_comprehensive_v2_e3sm_diags 3816 3816 0 0
legacy_3.0.0_comprehensive_v2_mpas_analysis 856 4 0 852 (list, grid)
legacy_3.0.0_comprehensive_v2_global_time_series 12 12 0 0
legacy_3.0.0_comprehensive_v2_ilamb 776 776 0 0
legacy_3.0.0_comprehensive_v3_e3sm_diags 5385 5385 0 0
legacy_3.0.0_comprehensive_v3_mpas_analysis 856 4 0 852 (list, grid)
legacy_3.0.0_comprehensive_v3_global_time_series 90 90 0 0
legacy_3.0.0_comprehensive_v3_ilamb 837 837 0 0

Failing image check tests:

Test name Total images Correct images Missing images Mismatched images
comprehensive_v2_mpas_analysis 856 4 0 852 (list, grid)
comprehensive_v3_mpas_analysis 1280 6 0 1274 (list, grid)
legacy_3.1.0_comprehensive_v2_mpas_analysis 856 4 0 852 (list, grid)
legacy_3.1.0_comprehensive_v3_mpas_analysis 856 4 0 852 (list, grid)
legacy_3.0.0_comprehensive_v2_mpas_analysis 856 4 0 852 (list, grid)
legacy_3.0.0_comprehensive_v3_mpas_analysis 856 4 0 852 (list, grid)

Good, this table matches the mpas_analysis table from the 8/12 test run. That is, e3sm_diags, global_time_series, and pcmdi_diags have had their expected results successfully updated (no image check failures), but the mpas_analysis expected results were correctly skipped in the update.

@forsyth2 forsyth2 left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've visually inspected the code and tested it out here, so I believe this is ready to merge.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Documentation Files in `docs` modified Testing Files in `tests` modified

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant