Skip to content

Commit e67a3ff

Browse files
authored
Merge branch 'main' into dependabot/pip/tests/local/utils/pillow-10.3.0
2 parents dd0e232 + e80c79c commit e67a3ff

File tree

11 files changed

+793
-104
lines changed

11 files changed

+793
-104
lines changed

.github/workflows/test-pr.yml

Lines changed: 144 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -21,10 +21,22 @@ jobs:
2121
configuration: [nwm_ana, nwm_long_range, gridded, reach]
2222
runs-on: ubuntu-latest
2323

24+
env:
25+
MPI_HOME: /usr/share/miniconda
26+
NETCDF: /usr/share/miniconda
27+
NETCDF_INCLUDES: /usr/share/miniconda/include
28+
NETCDF_LIBRARIES: /usr/share/miniconda/lib
29+
30+
2431
steps:
32+
- uses: actions/checkout@v4
33+
- uses: actions/setup-python@v5
34+
with:
35+
python-version: '3.10'
36+
2537
- name: Checkout candidate (pull request / push)
2638
if: ${{ github.event_name == 'pull_request' || github.event_name == 'push' }}
27-
uses: actions/checkout@v3
39+
uses: actions/checkout@v4
2840
with:
2941
path: candidate
3042

@@ -36,14 +48,14 @@ jobs:
3648

3749
- name: Checkout reference (pull request)
3850
if: ${{ github.event_name == 'pull_request' }}
39-
uses: actions/checkout@v3
51+
uses: actions/checkout@v4
4052
with:
4153
ref: ${{ github.event.pull_request.base.ref }}
4254
path: reference
4355

4456
- name: Checkout reference (push)
4557
if: ${{ github.event_name == 'push' }}
46-
uses: actions/checkout@v3
58+
uses: actions/checkout@v4
4759
with:
4860
ref: ${{ github.event.before }}
4961
path: reference
@@ -54,29 +66,148 @@ jobs:
5466
GITHUB_TOKEN: ${{secrets.GITHUB_TOKEN}}
5567
run: gh repo clone ${{ github.repository }} reference && cd reference && git checkout origin/$(gh pr view ${{ github.event.inputs.pr }} --json baseRefName --jq '.baseRefName')
5668

57-
- name: Run testing container
69+
- name: Install dependencies with apt-get
5870
run: |
59-
docker run -e TRAVIS=1 -t --name test_container \
60-
-v $GITHUB_WORKSPACE/candidate:/home/docker/candidate \
61-
-v $GITHUB_WORKSPACE/reference:/home/docker/reference \
62-
wrfhydro/dev:modeltesting --config ${{ matrix.configuration }} --domain_tag dev
71+
sudo apt-get update \
72+
&& sudo apt-get install -yq --no-install-recommends \
73+
wget \
74+
curl \
75+
bzip2 \
76+
ca-certificates \
77+
libhdf5-dev \
78+
gfortran \
79+
g++ \
80+
m4 \
81+
make \
82+
libswitch-perl \
83+
git \
84+
bc \
85+
openmpi-bin openmpi-common libopenmpi-dev \
86+
libxml2-dev \
87+
libnetcdf-dev \
88+
libnetcdff-dev
6389
64-
- name: Copy test results from container
90+
- name: Install dependencies with pip
91+
run: |
92+
python3 -m pip install matplotlib numpy xarray dask netCDF4 pygithub
93+
94+
- name: Compile reference
95+
run: |
96+
cd $GITHUB_WORKSPACE/reference
97+
cmake -B build
98+
make -C build -j
99+
100+
- name: Compile candidate
101+
run: |
102+
cd $GITHUB_WORKSPACE/candidate
103+
cmake -B build
104+
make -C build -j
105+
106+
- name: Run reference model
107+
run: |
108+
cd $GITHUB_WORKSPACE/reference/build/Run
109+
make run-croton-${{ matrix.configuration }}
110+
111+
- name: Run candidate model
112+
run: |
113+
cd $GITHUB_WORKSPACE/candidate/build/Run
114+
make run-croton-${{ matrix.configuration }}
115+
116+
- name: Compare HYDRO_RST.* output with xrcmp
117+
if: ${{ always() }}
118+
run: |
119+
cd $GITHUB_WORKSPACE/candidate/build/Run
120+
for file in output_${{ matrix.configuration }}/HYDRO_RST.*; do\
121+
python ${GITHUB_WORKSPACE}/candidate/tests/utils/xrcmp.py \
122+
--candidate $file \
123+
--reference $GITHUB_WORKSPACE/reference/build/Run/$file \
124+
--log_file $file_diff.txt \
125+
--n_cores 1; \
126+
done
127+
128+
- name: Compare RESTART.* output with xrcmp
65129
if: ${{ always() }}
66-
run: docker cp test_container:/home/docker/test_out $GITHUB_WORKSPACE/test_report
130+
run: |
131+
cd $GITHUB_WORKSPACE/candidate/build/Run
132+
for file in output_${{ matrix.configuration }}/RESTART.*; do\
133+
python ${GITHUB_WORKSPACE}/candidate/tests/utils/xrcmp.py \
134+
--candidate $file \
135+
--reference $GITHUB_WORKSPACE/reference/build/Run/$file \
136+
--log_file $file_diff.txt \
137+
--n_cores 1; \
138+
done
139+
140+
- name: Compare last *.CHANOBS_DOMAIN1 output with xrcmp
141+
if: ${{ always() }}
142+
run: |
143+
cd $GITHUB_WORKSPACE/candidate/build/Run
144+
file=$(ls -t output_${{ matrix.configuration }}/*.CHANOBS_DOMAIN1 | head -n 1)
145+
python ${GITHUB_WORKSPACE}/candidate/tests/utils/xrcmp.py \
146+
--candidate $file \
147+
--reference $GITHUB_WORKSPACE/reference/build/Run/$file \
148+
--log_file $file_diff.txt \
149+
--n_cores 1; \
150+
151+
- name: Compare last *.CHRTOUT_DOMAIN1 output with xrcmp
152+
if: ${{ always() }}
153+
run: |
154+
cd $GITHUB_WORKSPACE/candidate/build/Run
155+
file=$(ls -t output_${{ matrix.configuration }}/*.CHRTOUT_DOMAIN1 | head -n 1)
156+
python ${GITHUB_WORKSPACE}/candidate/tests/utils/xrcmp.py \
157+
--candidate $file \
158+
--reference $GITHUB_WORKSPACE/reference/build/Run/$file \
159+
--log_file $file_diff.txt \
160+
--n_cores 1; \
161+
162+
- name: Compare last *.LSMOUT_DOMAIN1 output with xrcmp
163+
if: ${{ always() }}
164+
run: |
165+
cd $GITHUB_WORKSPACE/candidate/build/Run
166+
file=$(ls -t output_${{ matrix.configuration }}/*.LSMOUT_DOMAIN1 | head -n 1)
167+
python ${GITHUB_WORKSPACE}/candidate/tests/utils/xrcmp.py \
168+
--candidate $file \
169+
--reference $GITHUB_WORKSPACE/reference/build/Run/$file \
170+
--log_file $file_diff.txt \
171+
--n_cores 1; \
67172
68-
- name: Checkout Github API
173+
- name: Compare last *.RTOUT_DOMAIN1 output with xrcmp
69174
if: ${{ always() }}
70175
run: |
71-
pip install pygithub
176+
cd $GITHUB_WORKSPACE/candidate/build/Run
177+
file=$(ls -t output_${{ matrix.configuration }}/*.RTOUT_DOMAIN1 | head -n 1)
178+
python ${GITHUB_WORKSPACE}/candidate/tests/utils/xrcmp.py \
179+
--candidate $file \
180+
--reference $GITHUB_WORKSPACE/reference/build/Run/$file \
181+
--log_file $file_diff.txt \
182+
--n_cores 1; \
183+
184+
- name: Compare output with compare_output
185+
if: ${{ always() }}
186+
run: |
187+
cd $GITHUB_WORKSPACE/candidate/build/Run
188+
mkdir output_diff
189+
python -c \
190+
"import sys; \
191+
sys.path.append('${GITHUB_WORKSPACE}/candidate/tests/utils'); \
192+
import compare_output; \
193+
from pathlib import Path; \
194+
compare_output.plot_diffs('${GITHUB_WORKSPACE}/candidate/build/Run/output_diff', \
195+
'${GITHUB_WORKSPACE}/candidate/build/Run/output_${{ matrix.configuration }}/', \
196+
'${GITHUB_WORKSPACE}/reference/build/Run/output_${{ matrix.configuration }}/', \
197+
'${{ matrix.configuration }}')"
198+
199+
- name: Copy test results from container
200+
if: ${{ always() }}
201+
run: |
202+
mkdir -p $GITHUB_WORKSPACE/test_report
203+
cp -r $GITHUB_WORKSPACE/candidate/build/Run/output_${{ matrix.configuration }}/* $GITHUB_WORKSPACE/test_report/
72204
73205
- name: Attach diff plots to PR
74206
if: ${{ always() }}
75207
run: |
76208
cd $GITHUB_WORKSPACE/candidate/tests/local/utils
77209
bash attach_all_plots.bash $(jq --raw-output .pull_request.number "$GITHUB_EVENT_PATH") ${{ matrix.configuration }}
78210
79-
80211
- name: Archive test results to GitHub
81212
if: ${{ always() }}
82213
uses: actions/upload-artifact@v3

tests/ctests/CMakeLists.txt

Lines changed: 27 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,35 @@
1-
# add Makefile target to setup test runs
2-
# - croton test options: {Gridded, Gridded_no_lakes, NWM, Reach, ReachLakes}
1+
# add Makefile targets to setup test runs
2+
# Croton Test Options: {Gridded, Gridded_no_lakes, NWM, Reach, ReachLakes}
3+
set(croton_testcases "gridded" "gridded_no_lakes" "nwm" "nwm_ana"
4+
"nwm_long_range" "reach" "reach_lakes")
5+
6+
# set default croton setup and run target
7+
set(croton_default_testcase "gridded")
38
add_custom_target(croton
49
COMMAND bash
5-
${CMAKE_CURRENT_SOURCE_DIR}/setup_cmake_testcase.sh Gridded ${CMAKE_BINARY_DIR})
6-
add_custom_target(croton-gridded
7-
COMMAND bash
8-
${CMAKE_CURRENT_SOURCE_DIR}/setup_cmake_testcase.sh Gridded ${CMAKE_BINARY_DIR})
9-
add_custom_target(croton-gridded-no-lakes
10-
COMMAND bash
11-
${CMAKE_CURRENT_SOURCE_DIR}/setup_cmake_testcase.sh Gridded_no_lakes ${CMAKE_BINARY_DIR})
12-
add_custom_target(croton-nwm
13-
COMMAND bash
14-
${CMAKE_CURRENT_SOURCE_DIR}/setup_cmake_testcase.sh NWM ${CMAKE_BINARY_DIR})
15-
add_custom_target(croton-reach
10+
${CMAKE_CURRENT_SOURCE_DIR}/setup_cmake_testcase.sh ${croton_default_testcase} ${CMAKE_BINARY_DIR})
11+
add_custom_target(run-croton
1612
COMMAND bash
17-
${CMAKE_CURRENT_SOURCE_DIR}/setup_cmake_testcase.sh Reach ${CMAKE_BINARY_DIR})
18-
add_custom_target(croton-reach-lakes
13+
${CMAKE_CURRENT_SOURCE_DIR}/run_cmake_testcase.sh ${croton_default_testcase} ${CMAKE_BINARY_DIR} 1)
14+
add_custom_target(run-croton-parallel
1915
COMMAND bash
20-
${CMAKE_CURRENT_SOURCE_DIR}/setup_cmake_testcase.sh ReachLakes ${CMAKE_BINARY_DIR})
16+
${CMAKE_CURRENT_SOURCE_DIR}/run_cmake_testcase.sh ${croton_default_testcase} ${CMAKE_BINARY_DIR} 2)
2117

18+
# generate commands for every croton testcase option
19+
foreach(croton_testcase ${croton_testcases})
20+
string(TOLOWER ${croton_testcase} testcase)
21+
add_custom_target(croton-${testcase}
22+
COMMAND bash
23+
${CMAKE_CURRENT_SOURCE_DIR}/setup_cmake_testcase.sh ${croton_testcase} ${CMAKE_BINARY_DIR})
24+
add_custom_target(run-croton-${testcase}
25+
DEPENDS croton-${testcase}
26+
COMMAND bash
27+
${CMAKE_CURRENT_SOURCE_DIR}/run_cmake_testcase.sh ${croton_testcase} ${CMAKE_BINARY_DIR} 1)
28+
add_custom_target(run-croton-${testcase}-parallel
29+
DEPENDS croton-${testcase}
30+
COMMAND bash
31+
${CMAKE_CURRENT_SOURCE_DIR}/run_cmake_testcase.sh ${croton_testcase} ${CMAKE_BINARY_DIR} 2)
32+
endforeach()
2233

2334
# generic ctests
2435
add_executable(fortran_ctest_should_fail

tests/ctests/run_cmake_testcase.sh

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
#!/bin/bash
2+
3+
# Bash script is meant to be used by CMake. It runs the Croton testcases after
4+
# setup_cmake_testcase.sh uses them
5+
6+
# setup directory variables in script
7+
testcase_type=${1}
8+
binary_dir=${2}
9+
np=${3}
10+
run_dir=${binary_dir}/Run
11+
output_dir=output_${testcase_type}
12+
13+
if [ "$np" -eq "1" ]; then
14+
run_cmd="./wrf_hydro.exe"
15+
else
16+
run_cmd="mpiexec -np ${np} ./wrf_hydro.exe"
17+
fi
18+
19+
# run testcase
20+
cd $run_dir
21+
${run_cmd}
22+
23+
# collect output, and fail silently if files not outputted at this point
24+
mkdir -p ${output_dir}
25+
mv *.CHANOBS_DOMAIN1 ${output_dir}/ 2>/dev/null
26+
mv *.CHRTOUT_DOMAIN1 ${output_dir}/ 2>/dev/null
27+
mv *.CHRTOUT_GRID1 ${output_dir}/ 2>/dev/null
28+
mv *.GWOUT_DOMAIN1 ${output_dir}/ 2>/dev/null
29+
mv *.LAKEOUT_DOMAIN1 ${output_dir}/ 2>/dev/null
30+
mv *.LDASOUT_DOMAIN1 ${output_dir}/ 2>/dev/null
31+
mv *.LSMOUT_DOMAIN1 ${output_dir}/ 2>/dev/null
32+
mv *.RTOUT_DOMAIN1 ${output_dir}/ 2>/dev/null
33+
mv HYDRO_RST.*_DOMAIN1 ${output_dir}/ 2>/dev/null
34+
mv RESTART.*_DOMAIN1 ${output_dir}/ 2>/dev/null
35+
mv diag_hydro.* ${output_dir}/ 2>/dev/null

tests/ctests/run_dir_makefile.mk

Lines changed: 45 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -10,20 +10,56 @@ run:
1010
# download and extract Croton, NY test case to Run directory
1111
# testcase options: {Gridded, Gridded_no_lakes, NWM, Reach, ReachLakes}
1212
croton:
13-
make -C .. croton
13+
make -C .. $@
1414
croton-gridded:
15-
make -C .. croton-gridded
15+
make -C .. $@
1616
croton-gridded-no-lakes:
17-
make -C .. croton-gridded-no-lakes
17+
make -C .. $@
1818
croton-nwm:
19-
make -C .. croton-nwm
19+
make -C .. $@
20+
croton-nwm_ana:
21+
make -C .. $@
22+
croton-nwm_long_range:
23+
make -C .. $@
2024
croton-reach:
21-
make -C .. croton-reach
25+
make -C .. $@
2226
croton-reach-lakes:
23-
make -C .. croton-reach-lakes
27+
make -C .. $@
28+
# run croton targets
29+
run-croton:
30+
make -C .. $@
31+
run-croton-gridded:
32+
make -C .. $@
33+
run-croton-gridded-no-lakes:
34+
make -C .. $@
35+
run-croton-nwm:
36+
make -C .. $@
37+
run-croton-nwm_ana:
38+
make -C .. $@
39+
run-croton-nwm_long_range:
40+
make -C .. $@
41+
run-croton-reach:
42+
make -C .. $@
43+
run-croton-reach-lakes:
44+
make -C .. $@
45+
# run in parallel
46+
run-croton-gridded-parallel:
47+
make -C .. $@
48+
run-croton-gridded-no-lakes-parallel:
49+
make -C .. $@
50+
run-croton-nwm-parallel:
51+
make -C .. $@
52+
run-croton-nwm_ana-parallel:
53+
make -C .. $@
54+
run-croton-nwm_long_range-parallel:
55+
make -C .. $@
56+
run-croton-reach-parallel:
57+
make -C .. $@
58+
run-croton-reach-lakes-parallel:
59+
make -C .. $@
2460

2561
clean:
26-
rm -f *.LDASOUT_DOMAIN1 *.LAKEOUT_DOMAIN1 *.CHRTOUT_DOMAIN1
27-
rm -f *.GWOUT_DOMAIN1 *.RTOUT_DOMAIN1 *.CHANOBS_DOMAIN1
28-
rm -f RESTART.*_DOMAIN1 HYDRO_RST.*_DOMAIN1
62+
rm -f *.CHANOBS_DOMAIN1 *.CHRTOUT_DOMAIN1 *.GWOUT_DOMAIN1
63+
rm -f *.LAKEOUT_DOMAIN1 *.LDASOUT_DOMAIN1 *.LSMOUT_DOMAIN1
64+
rm -f *.RTOUT_DOMAIN1 RESTART.*_DOMAIN1 HYDRO_RST.*_DOMAIN1
2965
rm -f diag_hydro.*

0 commit comments

Comments
 (0)