Skip to content

Commit 23e8ab6

Browse files
committed
Post-zppy-zi-split
1 parent 6c26e08 commit 23e8ab6

File tree

2 files changed

+111
-81
lines changed

2 files changed

+111
-81
lines changed

tests/integration/utils.py

Lines changed: 28 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -145,6 +145,9 @@ def get_chyrsalis_expansions(config):
145145
"case_name": "v3.LR.historical_0051",
146146
"case_name_v2": "v2.LR.historical_0201",
147147
"constraint": "",
148+
# To run this test, replace conda environment with your e3sm_diags dev environment
149+
# To use default environment_commands, set to ""
150+
"diags_environment_commands": "source <INSERT PATH TO CONDA>/conda.sh; conda activate <INSERT ENV NAME>",
148151
"diags_walltime": "5:00:00",
149152
"e3sm_to_cmip_environment_commands": "",
150153
"environment_commands_test": "",
@@ -172,6 +175,9 @@ def get_compy_expansions(config):
172175
"case_name": "v3.LR.historical_0051",
173176
"case_name_v2": "v2.LR.historical_0201",
174177
"constraint": "",
178+
# To run this test, replace conda environment with your e3sm_diags dev environment
179+
# To use default environment_commands, set to ""
180+
"diags_environment_commands": "source <INSERT PATH TO CONDA>/conda.sh; conda activate <INSERT ENV NAME>",
175181
"diags_walltime": "03:00:00",
176182
"e3sm_to_cmip_environment_commands": "",
177183
"environment_commands_test": "",
@@ -199,6 +205,9 @@ def get_perlmutter_expansions(config):
199205
"case_name": "v3.LR.historical_0051",
200206
"case_name_v2": "v2.LR.historical_0201",
201207
"constraint": "cpu",
208+
# To run this test, replace conda environment with your e3sm_diags dev environment
209+
# To use default environment_commands, set to ""
210+
"diags_environment_commands": "source <INSERT PATH TO CONDA>/conda.sh; conda activate <INSERT ENV NAME>",
202211
"diags_walltime": "6:00:00",
203212
"e3sm_to_cmip_environment_commands": "",
204213
"environment_commands_test": "",
@@ -252,14 +261,18 @@ def substitute_expansions(expansions, file_in, file_out):
252261
file_write.write(line)
253262

254263

255-
def generate_cfgs(unified_testing=False, diags_environment_commands="", dry_run=False):
264+
def generate_cfgs(
265+
unified_testing=False,
266+
diags_environment_commands=None,
267+
global_time_series_environment_commands=None,
268+
dry_run=False,
269+
):
256270
git_top_level = (
257271
subprocess.check_output("git rev-parse --show-toplevel".split())
258272
.strip()
259273
.decode("utf-8")
260274
)
261275
expansions = get_expansions()
262-
263276
if unified_testing:
264277
expansions["environment_commands"] = expansions["environment_commands_test"]
265278
else:
@@ -269,8 +282,10 @@ def generate_cfgs(unified_testing=False, diags_environment_commands="", dry_run=
269282

270283
if diags_environment_commands:
271284
expansions["diags_environment_commands"] = diags_environment_commands
272-
else:
273-
expansions["diags_environment_commands"] = ""
285+
if global_time_series_environment_commands:
286+
expansions["global_time_series_environment_commands"] = (
287+
global_time_series_environment_commands
288+
)
274289

275290
machine = expansions["machine"]
276291

@@ -368,6 +383,12 @@ def generate_cfgs(unified_testing=False, diags_environment_commands="", dry_run=
368383

369384

370385
if __name__ == "__main__":
371-
generate_cfgs(
372-
unified_testing=(sys.argv[1] == "True"), diags_environment_commands=sys.argv[2]
373-
)
386+
if len(sys.argv) <= 2:
387+
generate_cfgs(unified_testing=False, dry_run=False)
388+
else:
389+
generate_cfgs(
390+
unified_testing=sys.argv[2] == "True",
391+
diags_environment_commands=sys.argv[3],
392+
global_time_series_environment_commands=sys.argv[4],
393+
dry_run=False,
394+
)

tests/scripts/test_dev.bash

Lines changed: 83 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -2,108 +2,117 @@
22

33
# Before running this script ########################################################
44

5-
# Make sure you're on the branch you want to test!
6-
5+
# Set up branch
76
# If you want to test `main`, do the following:
87
# git fetch upstream main
9-
# git checkout -b test_pre_zppy_rc<#>_<machine_name> upstream/main
8+
# git checkout -b test_main_<date> upstream/main
109
# git log # check the commits match https://github.com/E3SM-Project/zppy/commits/main
1110

12-
# Set these parameters
13-
DIAGS_DIR=/home/ac.forsyth2/e3sm_diags/
14-
DIAGS_DEV=diags_dev_2023_10_05
11+
# Set these parameters:
12+
13+
# Make sure you do not have important changes in any of these directories. This script will reset them!
1514
ZPPY_DIR=/home/ac.forsyth2/zppy/
16-
DIAGS_ENV_CMD="source /home/ac.forsyth2/miniconda3/etc/profile.d/conda.sh; conda activate ${DIAGS_DEV}"
15+
DIAGS_DIR=/home/ac.forsyth2/e3sm_diags/
16+
ZI_DIR=/home/ac.forsyth2/zppy-interfaces/
17+
1718
ZPPY_DEV=zppy_dev_n516
19+
DIAGS_DEV=diags_dev_2024_12_13
20+
ZI_DEV=zi_dev_2024_12_13
1821

19-
# Make sure you do not have important changes on the `main` branch in your
20-
# E3SM_DIAGS_DIRECTORY. This script will reset that branch to match `upstream`!
22+
DIAGS_ENV_CMD="source /home/ac.forsyth2/miniconda3/etc/profile.d/conda.sh; conda activate ${DIAGS_DEV}"
23+
ZI_ENV_CMD="source /home/ac.forsyth2/miniconda3/etc/profile.d/conda.sh; conda activate ${ZI_DEV}"
24+
25+
UNIQUE_ID="unique_id"
2126

2227
#####################################################################################
2328

24-
echo "Update E3SM Diags"
25-
# `cd` to e3sm_diags directory
29+
# Set up zppy-interfaces env
30+
cd ${ZI_DIR}
31+
git fetch upstream main
32+
git checkout main upstream/main
33+
if [ $? != 0 ]; then
34+
echo 'ERROR (1): Could not check out zppy-interfaces main branch'
35+
exit 1
36+
fi
37+
git reset --hard upstream/main
38+
conda clean --all --y
39+
# TODO: previous iterations of this script had issues with activating conda environments
40+
conda env create -f conda/dev.yml -n ${ZI_DEV}
41+
conda activate ${ZI_DEV}
42+
pip install .
43+
pytest tests/global_time_series/test_*.py
44+
if [ $? != 0 ]; then
45+
echo 'ERROR (2): zppy-interfaces unit tests failed'
46+
exit 2
47+
fi
48+
49+
# Set up e3sm_diags env
2650
cd ${DIAGS_DIR}
27-
git checkout main
2851
git fetch upstream
52+
git checkout main
53+
if [ $? != 0 ]; then
54+
echo 'ERROR (3): Could not check out e3sm_diags main branch'
55+
exit 3
56+
fi
2957
git reset --hard upstream/main
30-
git log # Should match https://github.com/E3SM-Project/e3sm_diags/commits/main # TODO: Requires user review
31-
mamba clean --all # TODO: Requires user input to advance
32-
conda remove -n ${DIAGS_DEV} --all
33-
mamba env create -f conda-env/dev.yml -n ${DIAGS_DEV}
34-
conda activate ${DIAGS_DEV} # TODO: errors with ./tests/scripts/test_dev.bash: line 34: {DIAGS_DEV}: command not found
58+
conda clean --all --y
59+
conda env create -f conda-env/dev.yml -n ${DIAGS_DEV}
60+
conda activate ${DIAGS_DEV}
3561
pip install .
36-
cd ${ZPPY_DIR}
3762

38-
echo "Make sure we're using the latest packages"
39-
UNIFIED_TESTING=False
40-
python tests/integration/utils.py ${UNIFIED_TESTING} ${DIAGS_ENV_CMD}
41-
42-
echo "Set up our environment"
43-
mamba clean --all # TODO: Requires user input to advance
44-
mamba env create -f conda/dev.yml -n ${ZPPY_DEV}
45-
conda activate ${ZPPY_DEV} # TODO: errors with CommandNotFoundError: Your shell has not been properly configured to use 'conda activate'.
63+
# Set up zppy env
64+
cd ${ZPPY_DIR}
65+
# We should already be on the branch we want to test!
66+
conda clean --all --y
67+
conda env create -f conda/dev.yml -n ${ZPPY_DEV}
68+
conda activate ${ZPPY_DEV}
4669
pip install .
47-
48-
echo "Run unit tests"
49-
python -u -m unittest tests/test_*.py
70+
pytest tests/test_*.py
5071
if [ $? != 0 ]; then
51-
echo 'ERROR (1): unit tests failed'
52-
exit 1
72+
echo 'ERROR (4): zppy unit tests failed'
73+
exit 4
5374
fi
5475

55-
exit 7
56-
57-
echo "Set up integration tests"
58-
# TODO: somehow use Mache (a Python package) to get machine-independent paths in this bash script!
59-
# test_complete_run
60-
rm -rf /lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_test_complete_run_www/v2.LR.historical_0201
61-
rm -rf /lcrc/group/e3sm/ac.forsyth2/zppy_test_complete_run_output/v2.LR.historical_0201/post
62-
# Run jobs:
63-
zppy -c tests/integration/generated/test_complete_run_chrysalis.cfg
64-
# TODO: how can we possibly tell, automatically, when this is finished?
65-
# After they finish, check the results:
66-
cd /lcrc/group/e3sm/ac.forsyth2/zppy_test_complete_run_output/v2.LR.historical_0201/post/scripts
76+
# Integration testing for zppy
77+
python tests/integration/utils.py False ${DIAGS_DEV} ${ZI_DEV}
78+
79+
80+
zppy -c tests/integration/generated/test_weekly_comprehensive_v3_chrysalis.cfg
81+
zppy -c tests/integration/generated/test_weekly_comprehensive_v2_chrysalis.cfg
82+
zppy -c tests/integration/generated/test_weekly_bundles_chrysalis.cfg # Runs 1st part of bundles cfg
83+
84+
# TODO: figure out how to wait for all those jobs to finish
85+
86+
zppy -c tests/integration/generated/test_weekly_bundles_chrysalis.cfg
87+
88+
# TODO: figure out how to wait for all those jobs to finish
89+
90+
# Check output
91+
cd /lcrc/group/e3sm/${USER}/zppy_weekly_comprehensive_v3_output/${UNIQUE_ID}/v3.LR.historical_0051/post/scripts/
6792
grep -v "OK" *status
6893
if [ $? == 0 ]; then
69-
# The above command succeeds only if there are reported failures.
70-
echo 'ERROR (2): zppy complete run failed.'
71-
exit 2
94+
echo 'ERROR (5): weekly_comprehensive_v3 failed'
95+
exit 5
7296
fi
73-
cd ${ZPPY_DIR}
74-
# test_bundles
75-
rm -rf /lcrc/group/e3sm/public_html/diagnostic_output/ac.forsyth2/zppy_test_bundles_www/v2.LR.historical_0201
76-
rm -rf /lcrc/group/e3sm/ac.forsyth2/zppy_test_bundles_output/v2.LR.historical_0201/post
77-
# Run first set of jobs:
78-
zppy -c tests/integration/generated/test_bundles_chrysalis.cfg
79-
# TODO: how can we possibly tell, automatically, when this is finished?
80-
# bundle1 and bundle2 should run. After they finish, check the results:
81-
cd /lcrc/group/e3sm/ac.forsyth2/zppy_test_bundles_output/v2.LR.historical_0201/post/scripts
97+
98+
cd /lcrc/group/e3sm/${USER}/zppy_weekly_comprehensive_v2_output/${UNIQUE_ID}/v2.LR.historical_0201/post/scripts
8299
grep -v "OK" *status
83100
if [ $? == 0 ]; then
84-
# The above command succeeds only if there are reported failures.
85-
echo 'ERROR (3): zppy bundles 1st run failed.'
86-
exit 3
101+
echo 'ERROR (6): weekly_comprehensive_v2 failed'
102+
exit 6
87103
fi
88-
cd ${ZPPY_DIR}
89-
# Now, invoke zppy again to run jobs that needed to wait for dependencies:
90-
zppy -c tests/integration/generated/test_bundles_chrysalis.cfg
91-
# TODO: how can we possibly tell, automatically, when this is finished?
92-
# bundle3 and ilamb should run. After they finish, check the results:
93-
cd /lcrc/group/e3sm/ac.forsyth2/zppy_test_bundles_output/v2.LR.historical_0201/post/scripts
104+
105+
cd /lcrc/group/e3sm/${USER}/zppy_weekly_bundles_output/${UNIQUE_ID}/v3.LR.historical_0051/post/scripts
94106
grep -v "OK" *status
95107
if [ $? == 0 ]; then
96-
# The above command succeeds only if there are reported failures.
97-
echo 'ERROR (4): zppy bundles 2nd run failed.'
98-
exit 4
108+
echo 'ERROR (7): weekly_bundles failed'
109+
exit 7
99110
fi
100-
cd ${ZPPY_DIR}
101111

102-
echo "Run the integration tests"
103-
python -u -m unittest tests/integration/test_*.py
112+
# Run integration tests
113+
cd ~/ez/zppy
114+
pytest tests/integration/test_*.py
104115
if [ $? != 0 ]; then
105-
echo 'ERROR (5): integration tests failed'
106-
exit 5
116+
echo 'ERROR (8): zppy integration tests failed'
117+
exit 8
107118
fi
108-
109-
echo "All tests passed!"

0 commit comments

Comments
 (0)