Skip to content

Commit fe4f2e7

Browse files
authored
Changes to support OM3 development branches in QA checks (#103)
* turn on module use/load check om3 configs * create dev_config marker
1 parent 1c1d77d commit fe4f2e7

File tree

3 files changed

+74
-55
lines changed

3 files changed

+74
-55
lines changed

src/model_config_tests/conftest.py

+5-1
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,11 @@ def pytest_configure(config):
115115
"markers", "checksum_slow: mark tests as slow reproducibility tests"
116116
)
117117
config.addinivalue_line(
118-
"markers", "config: mark as configuration tests in quick QA CI checks"
118+
"markers",
119+
"config: mark as configuration tests for release branches in quick QA CI checks",
120+
)
121+
config.addinivalue_line(
122+
"markers", "dev_config: mark as configuration tests in quick QA CI checks"
119123
)
120124
config.addinivalue_line(
121125
"markers", "access_om2: mark as ACCESS-OM2 specific tests in quick QA CI checks"

src/model_config_tests/qa/test_access_om3_config.py

+12-2
Original file line numberDiff line numberDiff line change
@@ -5,10 +5,20 @@
55

66
import pytest
77

8+
from model_config_tests.qa.test_config import check_manifest_exes_in_spack_location
9+
810

911
@pytest.mark.access_om3
1012
class TestAccessOM3:
1113
"""ACCESS-OM3 Specific configuration and metadata tests"""
1214

13-
def test_pass(self):
14-
pass
15+
def test_access_om3_manifest_exe_in_release_spack_location(
16+
self, config, control_path
17+
):
18+
19+
check_manifest_exes_in_spack_location(
20+
model_module_name="access-om3",
21+
model_repo_name="ACCESS-OM3",
22+
control_path=control_path,
23+
config=config,
24+
)

src/model_config_tests/qa/test_config.py

+57-52
Original file line numberDiff line numberDiff line change
@@ -65,32 +65,8 @@ def branch_type(control_path, target_branch):
6565

6666

6767
@pytest.mark.config
68-
class TestConfig:
69-
"""General configuration tests"""
70-
71-
@pytest.mark.parametrize("field", ["project", "shortpath"])
72-
def test_field_is_not_defined(self, config, field):
73-
assert (
74-
field not in config
75-
), f"{field} should not be defined: '{field}: {config[field]}'"
76-
77-
def test_absolute_input_paths(self, config):
78-
for path in insist_array(config.get("input", [])):
79-
assert Path(path).is_absolute(), f"Input path should be absolute: {path}"
80-
81-
def test_absolute_submodel_input_paths(self, config):
82-
for model in config.get("submodels", []):
83-
for path in insist_array(model.get("input", [])):
84-
assert Path(path).is_absolute(), (
85-
f"Input path for {model['name']} submodel should be "
86-
+ f" absolute: {path}"
87-
)
88-
89-
def test_no_storage_qsub_flags(self, config):
90-
qsub_flags = config.get("qsub_flags", "")
91-
assert (
92-
"storage" not in qsub_flags
93-
), "Storage flags defined in qsub_flags will be silently ignored"
68+
class TestRelConfig:
69+
"""General configuration tests for release branches"""
9470

9571
def test_runlog_is_on(self, config):
9672
runlog_config = config.get("runlog", {})
@@ -110,18 +86,6 @@ def test_restart_freq_is_date_based(self, config):
11086
"Restart frequency should be date-based: " + f"'restart_freq: {frequency}'"
11187
)
11288

113-
def test_sync_is_not_enabled(self, config):
114-
if "sync" in config and "enable" in config["sync"]:
115-
assert not config["sync"][
116-
"enable"
117-
], "Sync to remote archive should not be enabled"
118-
119-
def test_sync_path_is_not_set(self, config):
120-
if "sync" in config:
121-
assert not (
122-
"path" in config["sync"] and config["sync"]["path"] is not None
123-
), "Sync path to remote archive should not be set"
124-
12589
def test_manifest_reproduce_exe_is_on(self, config):
12690
manifest_reproduce = config.get("manifest", {}).get("reproduce", {})
12791
assert "exe" in manifest_reproduce and manifest_reproduce["exe"], (
@@ -137,13 +101,6 @@ def test_metadata_is_enabled(self, config):
137101
+ "branch and UUIDs are not used in the name used for archival."
138102
)
139103

140-
def test_experiment_name_is_not_defined(self, config):
141-
assert "experiment" not in config, (
142-
f"experiment: {config['experiment']} should not set, "
143-
+ "as this over-rides the experiment name used for archival. "
144-
+ "If set, branching in payu would not work."
145-
)
146-
147104
def test_no_scripts_in_top_level_directory(self, control_path):
148105
exts = {".py", ".sh"}
149106
scripts = [p for p in control_path.iterdir() if p.suffix in exts]
@@ -178,7 +135,6 @@ def test_validate_metadata(self, metadata):
178135
"keywords",
179136
"nominal_resolution",
180137
"version",
181-
"reference",
182138
"url",
183139
"model",
184140
"realm",
@@ -187,17 +143,41 @@ def test_validate_metadata(self, metadata):
187143
def test_metadata_contains_fields(self, field, metadata):
188144
assert field in metadata, f"{field} field shoud be defined in metadata"
189145

190-
def test_metadata_does_contain_UUID(self, metadata):
191-
assert "experiment_uuid" not in metadata, (
192-
"`experiment_uuid` should not be defined in metadata, "
193-
+ "as this is an configuration rather than an experiment. "
194-
)
195-
196146
def test_metadata_license(self, metadata):
197147
assert (
198148
"license" in metadata and metadata["license"] == LICENSE
199149
), f"The license should be set to {LICENSE}"
200150

151+
152+
@pytest.mark.config
153+
@pytest.mark.dev_config
154+
class TestConfig:
155+
"""General configuration tests"""
156+
157+
@pytest.mark.parametrize("field", ["project", "shortpath"])
158+
def test_field_is_not_defined(self, config, field):
159+
assert (
160+
field not in config
161+
), f"{field} should not be defined: '{field}: {config[field]}'"
162+
163+
def test_absolute_input_paths(self, config):
164+
for path in insist_array(config.get("input", [])):
165+
assert Path(path).is_absolute(), f"Input path should be absolute: {path}"
166+
167+
def test_absolute_submodel_input_paths(self, config):
168+
for model in config.get("submodels", []):
169+
for path in insist_array(model.get("input", [])):
170+
assert Path(path).is_absolute(), (
171+
f"Input path for {model['name']} submodel should be "
172+
+ f" absolute: {path}"
173+
)
174+
175+
def test_no_storage_qsub_flags(self, config):
176+
qsub_flags = config.get("qsub_flags", "")
177+
assert (
178+
"storage" not in qsub_flags
179+
), "Storage flags defined in qsub_flags will be silently ignored"
180+
201181
def test_license_file(self, control_path):
202182
license_path = control_path / "LICENSE"
203183
assert license_path.exists(), (
@@ -232,6 +212,31 @@ def test_model_module_path_is_defined(self, branch_type, config):
232212
"The target branch is a dev version and doesn't require a stable module location"
233213
)
234214

215+
def test_metadata_does_not_contain_UUID(self, metadata):
216+
assert "experiment_uuid" not in metadata, (
217+
"`experiment_uuid` should not be defined in metadata, "
218+
+ "as this is an configuration rather than an experiment. "
219+
)
220+
221+
def test_sync_is_not_enabled(self, config):
222+
if "sync" in config and "enable" in config["sync"]:
223+
assert not config["sync"][
224+
"enable"
225+
], "Sync to remote archive should not be enabled"
226+
227+
def test_sync_path_is_not_set(self, config):
228+
if "sync" in config:
229+
assert not (
230+
"path" in config["sync"] and config["sync"]["path"] is not None
231+
), "Sync path to remote archive should not be set"
232+
233+
def test_experiment_name_is_not_defined(self, config):
234+
assert "experiment" not in config, (
235+
f"experiment: {config['experiment']} should not set, "
236+
+ "as this over-rides the experiment name used for archival. "
237+
+ "If set, branching in payu would not work."
238+
)
239+
235240

236241
def read_exe_manifest_fullpaths(control_path: Path):
237242
"""Return the full paths to the executables in the executable manifest file"""

0 commit comments

Comments
 (0)