Skip to content

Commit

Permalink
Add an output method for the chgres_cube driver (#674)
Browse files Browse the repository at this point in the history
* Add output method

* Update src/uwtools/drivers/chgres_cube.py

Use lowercase key

Co-authored-by: Paul Madden <136389411+maddenp-noaa@users.noreply.github.com>

* Change key to lowercase

---------

Co-authored-by: Paul Madden <136389411+maddenp-noaa@users.noreply.github.com>
  • Loading branch information
Byrnetp and maddenp-noaa authored Dec 13, 2024
1 parent 05dea64 commit 3cc9ab5
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
9 changes: 9 additions & 0 deletions src/uwtools/drivers/chgres_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,5 +110,14 @@ def driver_name(cls) -> str:
"""
return STR.chgrescube

@property
def output(self) -> dict[str, list[str]]:
"""
Returns a description of the file(s) created when this component runs.
"""
output_types = ["atm", "sfc"]
paths = [f"{self.rundir}/out.{t}.tile7.nc" for t in output_types]
return {"netcdffiles": paths}


set_driver_docstring(ChgresCube)
10 changes: 4 additions & 6 deletions src/uwtools/tests/drivers/test_chgres_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,11 +10,10 @@

import f90nml # type: ignore
from iotaa import refs
from pytest import fixture, mark, raises
from pytest import fixture, mark

from uwtools.drivers.chgres_cube import ChgresCube
from uwtools.drivers.driver import Driver
from uwtools.exceptions import UWNotImplementedError
from uwtools.logging import log
from uwtools.scheduler import Slurm
from uwtools.tests.support import logged, regex_logged
Expand Down Expand Up @@ -107,7 +106,6 @@ def leadtime():
"_scheduler",
"_validate",
"_write_runscript",
"output",
"run",
],
)
Expand Down Expand Up @@ -150,9 +148,9 @@ def test_ChgresCube_namelist_file_missing_base_file(caplog, driverobj):


def test_ChgresCube_output(driverobj):
with raises(UWNotImplementedError) as e:
assert driverobj.output
assert str(e.value) == "The output() method is not yet implemented for this driver"
files = ["out.atm.tile7.nc", "out.sfc.tile7.nc"]
expected = {"netcdffiles": [str(driverobj.rundir / file) for file in files]}
assert driverobj.output == expected


def test_ChgresCube_provisioned_rundir(driverobj):
Expand Down

0 comments on commit 3cc9ab5

Please sign in to comment.