From c25ffef7b62616b35392fcbcc9ffb2f2ff2ce9a1 Mon Sep 17 00:00:00 2001 From: Travis Byrne Date: Thu, 12 Dec 2024 08:55:12 -0700 Subject: [PATCH 1/3] Add output method --- src/uwtools/drivers/chgres_cube.py | 9 +++++++++ src/uwtools/tests/drivers/test_chgres_cube.py | 10 ++++------ 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/src/uwtools/drivers/chgres_cube.py b/src/uwtools/drivers/chgres_cube.py index ddf408963..b6816c526 100644 --- a/src/uwtools/drivers/chgres_cube.py +++ b/src/uwtools/drivers/chgres_cube.py @@ -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) diff --git a/src/uwtools/tests/drivers/test_chgres_cube.py b/src/uwtools/tests/drivers/test_chgres_cube.py index d8385c47f..802b42b03 100644 --- a/src/uwtools/tests/drivers/test_chgres_cube.py +++ b/src/uwtools/tests/drivers/test_chgres_cube.py @@ -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 @@ -107,7 +106,6 @@ def leadtime(): "_scheduler", "_validate", "_write_runscript", - "output", "run", ], ) @@ -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): From 7d0c3657d0284504ccbd63b55ebf5e2923af375d Mon Sep 17 00:00:00 2001 From: Travis Byrne <42480803+Byrnetp@users.noreply.github.com> Date: Thu, 12 Dec 2024 09:49:09 -0700 Subject: [PATCH 2/3] Update src/uwtools/drivers/chgres_cube.py Use lowercase key Co-authored-by: Paul Madden <136389411+maddenp-noaa@users.noreply.github.com> --- src/uwtools/drivers/chgres_cube.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uwtools/drivers/chgres_cube.py b/src/uwtools/drivers/chgres_cube.py index b6816c526..41e4a202b 100644 --- a/src/uwtools/drivers/chgres_cube.py +++ b/src/uwtools/drivers/chgres_cube.py @@ -117,7 +117,7 @@ def output(self) -> dict[str, list[str]]: """ output_types = ["atm", "sfc"] paths = [f"{self.rundir}/out.{t}.tile7.nc" for t in output_types] - return {"NetCDFfiles": paths} + return {"netcdffiles": paths} set_driver_docstring(ChgresCube) From 5c4547bb47ea29337f1489f08a4a912bd515affe Mon Sep 17 00:00:00 2001 From: Travis Byrne Date: Thu, 12 Dec 2024 09:58:42 -0700 Subject: [PATCH 3/3] Change key to lowercase --- src/uwtools/tests/drivers/test_chgres_cube.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/uwtools/tests/drivers/test_chgres_cube.py b/src/uwtools/tests/drivers/test_chgres_cube.py index 802b42b03..5b8761058 100644 --- a/src/uwtools/tests/drivers/test_chgres_cube.py +++ b/src/uwtools/tests/drivers/test_chgres_cube.py @@ -149,7 +149,7 @@ def test_ChgresCube_namelist_file_missing_base_file(caplog, driverobj): def test_ChgresCube_output(driverobj): files = ["out.atm.tile7.nc", "out.sfc.tile7.nc"] - expected = {"NetCDFfiles": [str(driverobj.rundir / file) for file in files]} + expected = {"netcdffiles": [str(driverobj.rundir / file) for file in files]} assert driverobj.output == expected