Skip to content

Commit

Permalink
Fixes found during MPAS App Development (#555)
Browse files Browse the repository at this point in the history
2 bugs were reported as a result of MPAS App development.

MPAS needs an underscore between days and hours in duration namelist entry.
Rocoto allows native to be specified alongside cores/nodes entries.
  • Loading branch information
christinaholtNOAA authored Aug 1, 2024
1 parent b08be17 commit b4d37df
Show file tree
Hide file tree
Showing 8 changed files with 50 additions and 21 deletions.
1 change: 1 addition & 0 deletions docs/sections/user_guide/cli/tools/rocoto/rocoto.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ workflow:
account: "&ACCOUNT;"
command: "echo hello $person"
jobname: hello
native: --reservation my_reservation
nodes: 1:ppn=1
walltime: 00:01:00
envars:
Expand Down
2 changes: 1 addition & 1 deletion recipe/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
"pyyaml =6.0.*"
]
},
"version": "2.3.2"
"version": "2.3.3"
}
2 changes: 1 addition & 1 deletion src/uwtools/drivers/mpas.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ def namelist_file(self):
yield asset(path, path.is_file)
yield None
duration = timedelta(hours=self._driver_config["length"])
str_duration = str(duration).replace(" days, ", "")
str_duration = str(duration).replace(" days, ", "_")
try:
namelist = self._driver_config["namelist"]
except KeyError as e:
Expand Down
2 changes: 1 addition & 1 deletion src/uwtools/resources/info.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "2.3.2",
"version": "2.3.3",
"buildnum": "0"
}
34 changes: 17 additions & 17 deletions src/uwtools/resources/jsonschema/rocoto.jsonschema
Original file line number Diff line number Diff line change
Expand Up @@ -290,6 +290,23 @@
},
"task": {
"additionalProperties": false,
"anyOf": [
{
"required": [
"cores"
]
},
{
"required": [
"native"
]
},
{
"required": [
"nodes"
]
}
],
"dependentSchemas": {
"exclusive": {
"not": {
Expand Down Expand Up @@ -328,23 +345,6 @@
]
}
},
"oneOf": [
{
"required": [
"cores"
]
},
{
"required": [
"native"
]
},
{
"required": [
"nodes"
]
}
],
"properties": {
"account": {
"type": "string"
Expand Down
17 changes: 16 additions & 1 deletion src/uwtools/tests/drivers/test_mpas.py
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,22 @@ def test_MPAS_namelist_file(caplog, driverobj):
path = Path(refs(driverobj.namelist_file()))
assert dst.is_file()
assert logged(caplog, f"Wrote config to {path}")
assert isinstance(f90nml.read(dst), f90nml.Namelist)
nml = f90nml.read(dst)
assert isinstance(nml, f90nml.Namelist)


def test_MPAS_namelist_file_long_duration(caplog, config, cycle):
log.setLevel(logging.DEBUG)
config["mpas"]["length"] = 120
driverobj = mpas.MPAS(config=config, cycle=cycle)
dst = driverobj._rundir / "namelist.atmosphere"
assert not dst.is_file()
path = Path(refs(driverobj.namelist_file()))
assert dst.is_file()
assert logged(caplog, f"Wrote config to {path}")
nml = f90nml.read(dst)
assert isinstance(nml, f90nml.Namelist)
assert nml["nhyd_model"]["config_run_duration"] == "5_0:00:00"


def test_MPAS_namelist_file_fails_validation(caplog, driverobj):
Expand Down
1 change: 1 addition & 0 deletions src/uwtools/tests/fixtures/hello_workflow.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ workflow:
attrs:
offset: 01:00
value: hello-@Y@m@d@H
native: --reservation my_reservation
nodes: 1:ppn=1
walltime: 00:01:00
envars:
Expand Down
12 changes: 12 additions & 0 deletions src/uwtools/tests/test_schemas.py
Original file line number Diff line number Diff line change
Expand Up @@ -1021,6 +1021,18 @@ def test_schema_rocoto_workflow_cycledef():
assert "'foo' is not valid" in errors([{"attrs": {"activation_offset": "foo"}, "spec": spec}])


def test_schema_rocoto_task_resources():
errors = schema_validator("rocoto", "$defs", "task", "properties")
# Basic resource options
assert not errors([{"cores": 1}])
assert not errors([{"native": "abc"}])
assert not errors([{"native": {"cyclestr": {"value": "def"}}}])
assert not errors([{"nodes": "1:ppn=12"}])
# Combined valid resources
assert not errors([{"cores": 1, "native": "abc"}])
assert not errors([{"native": "abc", "nodes": "1:ppn=12"}])


# sfc-climo-gen


Expand Down

0 comments on commit b4d37df

Please sign in to comment.