Skip to content

Commit dd58a34

Browse files
author
T. Joe Mills
authored
Merge pull request #156 from jmills-ncar/bugfix-5.0.x
upgraded testing on v5.0.x release
2 parents c4af97c + d15f285 commit dd58a34

File tree

11 files changed

+705
-182
lines changed

11 files changed

+705
-182
lines changed

tests/.DS_Store

6 KB
Binary file not shown.

tests/conftest.py

Lines changed: 116 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,4 @@
11
import pytest
2-
import shutil
3-
import pathlib
42
from wrfhydropy import *
53

64

@@ -36,8 +34,8 @@ def pytest_addoption(parser):
3634
parser.addoption("--config",
3735
required=True,
3836
action='store',
39-
help=("List of model configurations to test, options are 'NWM'," +
40-
"'Gridded',and 'Reach'")
37+
help=("The configuration to test, "
38+
"must be one listed in trunk/NDHMS/hydro_namelist.json keys.")
4139
)
4240

4341
# Optional args
@@ -46,7 +44,14 @@ def pytest_addoption(parser):
4644
default='gfort',
4745
required=False,
4846
action='store',
49-
help='compiler, options are intel or gfort'
47+
help='compiler, options are ifort or gfort'
48+
)
49+
50+
parser.addoption("--option_suite",
51+
required=False,
52+
action='store',
53+
help=("An option suite to test on top of the specified configuration,"
54+
"must be one listed in hydro_option_suites.json")
5055
)
5156

5257
parser.addoption( '--ncores',
@@ -57,11 +62,8 @@ def pytest_addoption(parser):
5762
)
5863

5964
parser.addoption('--scheduler',
60-
default=None,
61-
required=False,
62-
action='store',
63-
help='Scheduler to use for testing, options are PBSCheyenne or do not specify for no '
64-
'scheduler')
65+
action='store_true',
66+
help='Use PBS scheduler on cheyenne')
6567

6668
parser.addoption('--nnodes',
6769
default='2',
@@ -74,24 +76,42 @@ def pytest_addoption(parser):
7476
action='store',
7577
help='Account number to use if using a scheduler.')
7678

79+
parser.addoption('--walltime',
80+
default='02:00:00',
81+
required=False,
82+
action='store',
83+
help='Wall clock time for each test run in hh:mm:ss format')
84+
85+
parser.addoption('--queue',
86+
default='regular',
87+
required=False,
88+
action='store',
89+
help='Queue to use if running on NCAR Cheyenne, options are regular, '
90+
'premium, or shared')
7791

7892
def _make_sim(domain_dir,
93+
compiler,
7994
source_dir,
8095
configuration,
96+
option_suite,
8197
ncores,
8298
nnodes,
8399
scheduler,
84-
account):
100+
account,
101+
walltime,
102+
queue):
85103
# model
86104
model = Model(
105+
compiler=compiler,
87106
source_dir=source_dir,
88107
model_config=configuration
89108
)
90109

91110
# domain
92111
domain = Domain(
93112
domain_top_dir=domain_dir,
94-
domain_config=configuration)
113+
domain_config=configuration
114+
)
95115

96116
# Job
97117
# exe_command = ('mpirun -np {0} ./wrf_hydro.exe').format(str(ncores))
@@ -101,58 +121,118 @@ def _make_sim(domain_dir,
101121
sim = Simulation()
102122
sim.add(model)
103123
sim.add(domain)
104-
# sim.add(job)
105124

106-
if scheduler is not None and scheduler == 'pbscheyenne':
125+
# Update base namelists with option suite if specified
126+
if option_suite is not None:
127+
pass
128+
129+
if scheduler:
107130
sim.add(schedulers.PBSCheyenne(account=account,
108131
nproc=int(ncores),
109-
nnodes=nnodes))
110-
132+
nnodes=int(nnodes),
133+
walltime=walltime,
134+
queue=queue))
111135

112136
return sim
113137

138+
114139
@pytest.fixture(scope="session")
115140
def candidate_sim(request):
116141

117142
domain_dir = request.config.getoption("--domain_dir")
143+
compiler = request.config.getoption("--compiler")
118144
candidate_dir = request.config.getoption("--candidate_dir")
119145
configuration = request.config.getoption("--config")
146+
option_suite = request.config.getoption("--option_suite")
120147
ncores = request.config.getoption("--ncores")
121148
nnodes = request.config.getoption("--nnodes")
122-
scheduler = str(request.config.getoption("--scheduler")).lower()
149+
scheduler = request.config.getoption("--scheduler")
123150
account = request.config.getoption("--account")
124-
125-
candidate_sim = _make_sim(domain_dir = domain_dir,
126-
source_dir= candidate_dir,
127-
configuration=configuration,
128-
ncores = ncores,
129-
nnodes=nnodes,
130-
scheduler = scheduler,
131-
account = account)
151+
walltime = request.config.getoption("--walltime")
152+
queue = request.config.getoption("--queue")
153+
154+
candidate_sim = _make_sim(
155+
domain_dir=domain_dir,
156+
compiler=compiler,
157+
source_dir=candidate_dir,
158+
configuration=configuration,
159+
option_suite=option_suite,
160+
ncores=ncores,
161+
nnodes=nnodes,
162+
scheduler=scheduler,
163+
account=account,
164+
walltime=walltime,
165+
queue=queue
166+
)
132167

133168
return candidate_sim
134169

170+
@pytest.fixture(scope="session")
171+
def candidate_channel_only_sim(request):
172+
173+
domain_dir = request.config.getoption("--domain_dir")
174+
compiler = request.config.getoption("--compiler")
175+
candidate_dir = request.config.getoption("--candidate_dir")
176+
configuration = request.config.getoption("--config")
177+
option_suite = request.config.getoption("--option_suite")
178+
ncores = request.config.getoption("--ncores")
179+
nnodes = request.config.getoption("--nnodes")
180+
scheduler = request.config.getoption("--scheduler")
181+
account = request.config.getoption("--account")
182+
walltime = request.config.getoption("--walltime")
183+
queue = request.config.getoption("--queue")
184+
185+
candidate_channel_only_sim = _make_sim(
186+
domain_dir=domain_dir,
187+
compiler=compiler,
188+
source_dir=candidate_dir,
189+
configuration=configuration,
190+
option_suite=option_suite,
191+
ncores=ncores,
192+
nnodes=nnodes,
193+
scheduler=scheduler,
194+
account=account,
195+
walltime=walltime,
196+
queue=queue
197+
)
198+
199+
# Channel and bucket mode is forc_typ = 10.
200+
candidate_channel_only_sim.base_hrldas_namelist['wrf_hydro_offline']['forc_typ'] = 10
201+
return candidate_channel_only_sim
202+
203+
135204
@pytest.fixture(scope="session")
136205
def reference_sim(request):
137206

138207
domain_dir = request.config.getoption("--domain_dir")
208+
compiler = request.config.getoption("--compiler")
139209
reference_dir = request.config.getoption("--reference_dir")
140210
configuration = request.config.getoption("--config")
211+
option_suite = request.config.getoption("--option_suite")
141212
ncores = request.config.getoption("--ncores")
142213
nnodes = request.config.getoption("--nnodes")
143-
scheduler = str(request.config.getoption("--scheduler")).lower()
214+
scheduler = request.config.getoption("--scheduler")
144215
account = request.config.getoption("--account")
145-
146-
reference_sim = _make_sim(domain_dir = domain_dir,
147-
source_dir= reference_dir,
148-
configuration=configuration,
149-
ncores = ncores,
150-
nnodes=nnodes,
151-
scheduler = scheduler,
152-
account = account)
216+
walltime = request.config.getoption("--walltime")
217+
queue = request.config.getoption("--queue")
218+
219+
reference_sim = _make_sim(
220+
domain_dir=domain_dir,
221+
compiler=compiler,
222+
source_dir=reference_dir,
223+
configuration=configuration,
224+
option_suite=option_suite,
225+
ncores=ncores,
226+
nnodes=nnodes,
227+
scheduler=scheduler,
228+
account=account,
229+
walltime=walltime,
230+
queue=queue
231+
)
153232

154233
return reference_sim
155234

235+
156236
@pytest.fixture(scope="session")
157237
def output_dir(request):
158238
configuration = request.config.getoption("--config")
@@ -167,9 +247,9 @@ def output_dir(request):
167247
output_dir.mkdir(parents=True)
168248
return output_dir
169249

250+
170251
@pytest.fixture(scope="session")
171252
def ncores(request):
172253
ncores = request.config.getoption("--ncores")
173254

174-
return ncores
175-
255+
return ncores

tests/hrldas_option_suites.json

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
{
2+
"compound_channel_off":{
3+
"noahlsm_offline": {},
4+
"wrf_hydro_offline": {}
5+
}
6+
}

tests/hydro_option_suites.json

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
{
2+
"compound_channel_off":{
3+
"hydro_nlist": {
4+
"compound_channel": false
5+
},
6+
"nudging_nlist":{}
7+
}
8+
}

0 commit comments

Comments
 (0)