Skip to content

Commit

Permalink
Extra schema test
Browse files Browse the repository at this point in the history
  • Loading branch information
maddenp-noaa committed Feb 7, 2024
1 parent 144e5fb commit fa7e5c4
Show file tree
Hide file tree
Showing 4 changed files with 32 additions and 4 deletions.
4 changes: 3 additions & 1 deletion src/uwtools/drivers/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,9 @@ def run_cmd(self) -> str:
"""
components = [
self._platform_config["mpicmd"], # MPI run program
*[str(x) for x in self._config["runtime_info"].get("mpi_args", [])], # MPI arguments
*[
str(x) for x in self._config.get("runtime_info", {}).get("mpi_args", [])
], # MPI arguments
self._config["executable"], # NWP tool executable name
]
return " ".join(filter(None, components))
Expand Down
2 changes: 1 addition & 1 deletion src/uwtools/drivers/forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -238,7 +238,7 @@ def _mpi_env_variables(self, delimiter: str = " ") -> str:
"""
envvars = {
"KMP_AFFINITY": "scatter",
"OMP_NUM_THREADS": self._config["runtime_info"].get("threads", 1),
"OMP_NUM_THREADS": self._config.get("runtime_info", {}).get("threads", 1),
"OMP_STACKSIZE": "512m",
"MPI_TYPE_DEPTH": 20,
"ESMF_RUNTIME_COMPLIANCECHECK": "OFF:depth=4",
Expand Down
3 changes: 1 addition & 2 deletions src/uwtools/resources/FV3Forecast.jsonschema
Original file line number Diff line number Diff line change
Expand Up @@ -220,8 +220,7 @@
"domain",
"executable",
"length",
"run_dir",
"runtime_info"
"run_dir"
],
"type": "object"
},
Expand Down
27 changes: 27 additions & 0 deletions src/uwtools/tests/drivers/test_forecast.py
Original file line number Diff line number Diff line change
Expand Up @@ -447,6 +447,33 @@ def test_FV3Forecast_schema_filesToStage():
assert "True is not of type 'string'" in errors({"file1": True})


def test_FV3Forecast_schema_forecast():
d = {"domain": "regional", "executable": "fv3", "length": 3, "run_dir": "/tmp"}
errors = validator("FV3Forecast.jsonschema", "properties", "forecast")
# Basic correctness:
assert not errors(d)
# Some top-level keys are required:
assert "'domain' is a required property" in errors(with_del(d, "domain"))
assert "'executable' is a required property" in errors(with_del(d, "executable"))
assert "'length' is a required property" in errors(with_del(d, "length"))
assert "'run_dir' is a required property" in errors(with_del(d, "run_dir"))
# Some top-level keys are optional:
assert not errors(
{
**d,
"diag_table": "/path",
"field_table": {"base_file": "/path"},
"files_to_copy": {"fn": "/path"},
"files_to_link": {"fn": "/path"},
"model_configure": {"base_file": "/path"},
"namelist": {"base_file": "/path"},
"runtime_info": {},
}
)
# Additional top-level keys are not allowed:
assert "Additional properties are not allowed" in errors({**d, "foo": "bar"})


def test_FV3Forecast_schema_forecast_diag_table(fcstprop):
errors = fcstprop("diag_table")
# String value is ok:
Expand Down

0 comments on commit fa7e5c4

Please sign in to comment.