From bf01a968fb2adaaed5f6b987e242c8a9fed45a10 Mon Sep 17 00:00:00 2001 From: Christina Holt <56881914+christinaholtNOAA@users.noreply.github.com> Date: Fri, 1 Nov 2024 10:27:33 -0600 Subject: [PATCH] Add a leadtime argument to the chgres_cube driver. (#641) --- .../user_guide/cli/drivers/chgres_cube/run-help.out | 12 +++++++----- src/uwtools/cli.py | 2 +- src/uwtools/drivers/chgres_cube.py | 4 ++-- src/uwtools/tests/drivers/test_chgres_cube.py | 11 ++++++++--- 4 files changed, 18 insertions(+), 11 deletions(-) diff --git a/docs/sections/user_guide/cli/drivers/chgres_cube/run-help.out b/docs/sections/user_guide/cli/drivers/chgres_cube/run-help.out index 70c20c78a..3f0eca53e 100644 --- a/docs/sections/user_guide/cli/drivers/chgres_cube/run-help.out +++ b/docs/sections/user_guide/cli/drivers/chgres_cube/run-help.out @@ -1,13 +1,15 @@ -usage: uw chgres_cube run --cycle CYCLE [-h] [--version] [--config-file PATH] - [--batch] [--dry-run] [--graph-file PATH] - [--key-path KEY[.KEY...]] [--schema-file PATH] - [--quiet] [--verbose] +usage: uw chgres_cube run --cycle CYCLE --leadtime LEADTIME [-h] [--version] + [--config-file PATH] [--batch] [--dry-run] + [--graph-file PATH] [--key-path KEY[.KEY...]] + [--schema-file PATH] [--quiet] [--verbose] A run Required arguments: --cycle CYCLE - The cycle in ISO8601 format (e.g. 2024-05-23T18) + The cycle in ISO8601 format (e.g. 2024-10-31T18) + --leadtime LEADTIME + The leadtime as hours[:minutes[:seconds]] Optional arguments: -h, --help diff --git a/src/uwtools/cli.py b/src/uwtools/cli.py index 4cb3be55b..e268a2e9b 100644 --- a/src/uwtools/cli.py +++ b/src/uwtools/cli.py @@ -1206,7 +1206,6 @@ def _parse_args(raw_args: list[str]) -> tuple[Args, Checks]: _add_subparser_for_driver, component, subparsers, with_batch=True, with_cycle=True ) for component in [ - STR.chgrescube, STR.fv3, STR.ioda, STR.jedi, @@ -1225,6 +1224,7 @@ def _parse_args(raw_args: list[str]) -> tuple[Args, Checks]: with_leadtime=True, ) for component in [ + STR.chgrescube, STR.upp, ] } diff --git a/src/uwtools/drivers/chgres_cube.py b/src/uwtools/drivers/chgres_cube.py index 6dc9594d2..2a0acd0e4 100644 --- a/src/uwtools/drivers/chgres_cube.py +++ b/src/uwtools/drivers/chgres_cube.py @@ -7,13 +7,13 @@ from iotaa import asset, task, tasks from uwtools.config.formats.nml import NMLConfig -from uwtools.drivers.driver import DriverCycleBased +from uwtools.drivers.driver import DriverCycleLeadtimeBased from uwtools.drivers.support import set_driver_docstring from uwtools.strings import STR from uwtools.utils.tasks import file -class ChgresCube(DriverCycleBased): +class ChgresCube(DriverCycleLeadtimeBased): """ A driver for chgres_cube. """ diff --git a/src/uwtools/tests/drivers/test_chgres_cube.py b/src/uwtools/tests/drivers/test_chgres_cube.py index 3f5568b8c..f8494a28e 100644 --- a/src/uwtools/tests/drivers/test_chgres_cube.py +++ b/src/uwtools/tests/drivers/test_chgres_cube.py @@ -82,8 +82,13 @@ def config(tmp_path): @fixture -def driverobj(config, cycle): - return ChgresCube(config=config, cycle=cycle, batch=True) +def driverobj(config, cycle, leadtime): + return ChgresCube(config=config, cycle=cycle, leadtime=leadtime, batch=True) + + +@fixture +def leadtime(): + return dt.timedelta(hours=24) # Tests @@ -165,4 +170,4 @@ def test_ChgresCube_runscript(driverobj): def test_ChgresCube_taskname(driverobj): - assert driverobj.taskname("foo") == "20240201 18Z chgres_cube foo" + assert driverobj.taskname("foo") == "20240202 18:00:00 chgres_cube foo"