Skip to content

Commit

Permalink
Updates for Coastal App coupled driver (#560)
Browse files Browse the repository at this point in the history
  • Loading branch information
maddenp-noaa authored Aug 7, 2024
1 parent 3fdafb3 commit 35cee0b
Show file tree
Hide file tree
Showing 68 changed files with 412 additions and 295 deletions.
2 changes: 1 addition & 1 deletion src/uwtools/api/cdeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
_driver = CDEPS
execute = _make_execute(_driver, with_cycle=True)
tasks = partial(tasks, _driver)
__all__ = [_driver.__name__, "execute", "graph", "tasks"]
__all__ = ["CDEPS", "execute", "graph", "tasks"]
2 changes: 1 addition & 1 deletion src/uwtools/api/chgres_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
_driver = ChgresCube
execute = _make_execute(_driver, with_cycle=True)
tasks = partial(tasks, _driver)
__all__ = [_driver.__name__, "execute", "graph", "tasks"]
__all__ = ["ChgresCube", "execute", "graph", "tasks"]
25 changes: 11 additions & 14 deletions src/uwtools/api/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -152,18 +152,15 @@ def _get_driver_module_implicit(module: str) -> Optional[ModuleType]:


__all__ = [
getattr(x, "__name__")
for x in (
Assets,
AssetsCycleBased,
AssetsCycleLeadtimeBased,
AssetsTimeInvariant,
Driver,
DriverCycleBased,
DriverCycleLeadtimeBased,
DriverTimeInvariant,
execute,
graph,
tasks,
)
"Assets",
"AssetsCycleBased",
"AssetsCycleLeadtimeBased",
"AssetsTimeInvariant",
"Driver",
"DriverCycleBased",
"DriverCycleLeadtimeBased",
"DriverTimeInvariant",
"execute",
"graph",
"tasks",
]
2 changes: 1 addition & 1 deletion src/uwtools/api/esg_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
_driver = ESGGrid
execute = _make_execute(_driver)
tasks = partial(tasks, _driver)
__all__ = [_driver.__name__, "execute", "graph", "tasks"]
__all__ = ["ESGGrid", "execute", "graph", "tasks"]
2 changes: 1 addition & 1 deletion src/uwtools/api/filter_topo.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
_driver = FilterTopo
execute = _make_execute(_driver)
tasks = partial(tasks, _driver)
__all__ = [_driver.__name__, "execute", "graph", "tasks"]
__all__ = ["FilterTopo", "execute", "graph", "tasks"]
2 changes: 1 addition & 1 deletion src/uwtools/api/fv3.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
_driver = FV3
execute = _make_execute(_driver, with_cycle=True)
tasks = partial(tasks, _driver)
__all__ = [_driver.__name__, "execute", "graph", "tasks"]
__all__ = ["FV3", "execute", "graph", "tasks"]
2 changes: 1 addition & 1 deletion src/uwtools/api/global_equiv_resol.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
_driver = GlobalEquivResol
execute = _make_execute(_driver)
tasks = partial(tasks, _driver)
__all__ = [_driver.__name__, "execute", "graph", "tasks"]
__all__ = ["GlobalEquivResol", "execute", "graph", "tasks"]
2 changes: 1 addition & 1 deletion src/uwtools/api/ioda.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
_driver = IODA
execute = _make_execute(_driver, with_cycle=True)
tasks = partial(tasks, _driver)
__all__ = [_driver.__name__, "execute", "graph", "tasks"]
__all__ = ["IODA", "execute", "graph", "tasks"]
2 changes: 1 addition & 1 deletion src/uwtools/api/jedi.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
_driver = JEDI
execute = _make_execute(_driver, with_cycle=True)
tasks = partial(tasks, _driver)
__all__ = [_driver.__name__, "execute", "graph", "tasks"]
__all__ = ["JEDI", "execute", "graph", "tasks"]
2 changes: 1 addition & 1 deletion src/uwtools/api/make_hgrid.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
_driver = MakeHgrid
execute = _make_execute(_driver)
tasks = partial(tasks, _driver)
__all__ = [_driver.__name__, "execute", "graph", "tasks"]
__all__ = ["MakeHgrid", "execute", "graph", "tasks"]
2 changes: 1 addition & 1 deletion src/uwtools/api/make_solo_mosaic.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
_driver = MakeSoloMosaic
execute = _make_execute(_driver)
tasks = partial(tasks, _driver)
__all__ = [_driver.__name__, "execute", "graph", "tasks"]
__all__ = ["MakeSoloMosaic", "execute", "graph", "tasks"]
2 changes: 1 addition & 1 deletion src/uwtools/api/mpas.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
_driver = MPAS
execute = _make_execute(_driver, with_cycle=True)
tasks = partial(tasks, _driver)
__all__ = [_driver.__name__, "execute", "graph", "tasks"]
__all__ = ["MPAS", "execute", "graph", "tasks"]
2 changes: 1 addition & 1 deletion src/uwtools/api/mpas_init.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
_driver = MPASInit
execute = _make_execute(_driver, with_cycle=True)
tasks = partial(tasks, _driver)
__all__ = [_driver.__name__, "execute", "graph", "tasks"]
__all__ = ["MPASInit", "execute", "graph", "tasks"]
2 changes: 1 addition & 1 deletion src/uwtools/api/orog_gsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
_driver = OrogGSL
execute = _make_execute(_driver)
tasks = partial(tasks, _driver)
__all__ = [_driver.__name__, "execute", "graph", "tasks"]
__all__ = ["OrogGSL", "execute", "graph", "tasks"]
2 changes: 1 addition & 1 deletion src/uwtools/api/schism.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
_driver = SCHISM
execute = _make_execute(_driver, with_cycle=True)
tasks = partial(tasks, _driver)
__all__ = [_driver.__name__, "execute", "graph", "tasks"]
__all__ = ["SCHISM", "execute", "graph", "tasks"]
2 changes: 1 addition & 1 deletion src/uwtools/api/sfc_climo_gen.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
_driver = SfcClimoGen
execute = _make_execute(_driver)
tasks = partial(tasks, _driver)
__all__ = [_driver.__name__, "execute", "graph", "tasks"]
__all__ = ["SfcClimoGen", "execute", "graph", "tasks"]
2 changes: 1 addition & 1 deletion src/uwtools/api/shave.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
_driver = Shave
execute = _make_execute(_driver)
tasks = partial(tasks, _driver)
__all__ = [_driver.__name__, "execute", "graph", "tasks"]
__all__ = ["Shave", "execute", "graph", "tasks"]
2 changes: 1 addition & 1 deletion src/uwtools/api/ungrib.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
_driver = Ungrib
execute = _make_execute(_driver, with_cycle=True)
tasks = partial(tasks, _driver)
__all__ = [_driver.__name__, "execute", "graph", "tasks"]
__all__ = ["Ungrib", "execute", "graph", "tasks"]
2 changes: 1 addition & 1 deletion src/uwtools/api/upp.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
_driver = UPP
execute = _make_execute(_driver, with_cycle=True, with_leadtime=True)
tasks = partial(tasks, _driver)
__all__ = [_driver.__name__, "execute", "graph", "tasks"]
__all__ = ["UPP", "execute", "graph", "tasks"]
2 changes: 1 addition & 1 deletion src/uwtools/api/ww3.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,4 +11,4 @@
_driver = WaveWatchIII
execute = _make_execute(_driver, with_cycle=True)
tasks = partial(tasks, _driver)
__all__ = [_driver.__name__, "execute", "graph", "tasks"]
__all__ = ["WaveWatchIII", "execute", "graph", "tasks"]
12 changes: 6 additions & 6 deletions src/uwtools/drivers/cdeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def atm(self):
"""
Create data atmosphere configuration with all required content.
"""
yield self._taskname("data atmosphere configuration")
yield self.taskname("data atmosphere configuration")
yield [
self.atm_nml(),
self.atm_stream(),
Expand All @@ -38,7 +38,7 @@ def atm_nml(self):
Create data atmosphere Fortran namelist file (datm_in).
"""
fn = "datm_in"
yield self._taskname(f"namelist file {fn}")
yield self.taskname(f"namelist file {fn}")
path = self.rundir / fn
yield asset(path, path.is_file)
yield None
Expand All @@ -50,7 +50,7 @@ def atm_stream(self):
Create data atmosphere stream config file (datm.streams).
"""
fn = "datm.streams"
yield self._taskname(f"stream file {fn}")
yield self.taskname(f"stream file {fn}")
path = self.rundir / fn
yield asset(path, path.is_file)
template_file = self.config["atm_streams"]["template_file"]
Expand All @@ -62,7 +62,7 @@ def ocn(self):
"""
Create data ocean configuration with all required content.
"""
yield self._taskname("data atmosphere configuration")
yield self.taskname("data atmosphere configuration")
yield [
self.ocn_nml(),
self.ocn_stream(),
Expand All @@ -74,7 +74,7 @@ def ocn_nml(self):
Create data ocean Fortran namelist file (docn_in).
"""
fn = "docn_in"
yield self._taskname(f"namelist file {fn}")
yield self.taskname(f"namelist file {fn}")
path = self.rundir / fn
yield asset(path, path.is_file)
yield None
Expand All @@ -86,7 +86,7 @@ def ocn_stream(self):
Create data ocean stream config file (docn.streams).
"""
fn = "docn.streams"
yield self._taskname(f"stream file {fn}")
yield self.taskname(f"stream file {fn}")
path = self.rundir / fn
yield asset(path, path.is_file)
template_file = self.config["ocn_streams"]["template_file"]
Expand Down
6 changes: 3 additions & 3 deletions src/uwtools/drivers/chgres_cube.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def namelist_file(self):
The namelist file.
"""
fn = "fort.41"
yield self._taskname(f"namelist file {fn}")
yield self.taskname(f"namelist file {fn}")
path = self.rundir / fn
yield asset(path, path.is_file)
input_files = []
Expand Down Expand Up @@ -67,7 +67,7 @@ def provisioned_rundir(self):
"""
Run directory provisioned with all required content.
"""
yield self._taskname("provisioned run directory")
yield self.taskname("provisioned run directory")
yield [
self.namelist_file(),
self.runscript(),
Expand All @@ -79,7 +79,7 @@ def runscript(self):
The runscript.
"""
path = self._runscript_path
yield self._taskname(path.name)
yield self.taskname(path.name)
yield asset(path, path.is_file)
yield None
envvars = {
Expand Down
40 changes: 20 additions & 20 deletions src/uwtools/drivers/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,14 +98,29 @@ def rundir(self) -> Path:
"""
return Path(self.config[STR.rundir])

def taskname(self, suffix: str) -> str:
"""
Returns a common tag for graph-task log messages.
:param suffix: Log-string suffix.
"""
cycle = getattr(self, "_cycle", None)
leadtime = getattr(self, "_leadtime", None)
timestr = (
(cycle + leadtime).strftime("%Y%m%d %H:%M:%S")
if cycle and leadtime is not None
else cycle.strftime("%Y%m%d %HZ") if cycle else None
)
return " ".join(filter(None, [timestr, self._driver_name, suffix]))

# Workflow tasks

@external
def validate(self):
"""
Validate the UW driver config.
"""
yield self._taskname("valid schema")
yield self.taskname("valid schema")
yield asset(None, lambda: True)

# Private helper methods
Expand Down Expand Up @@ -173,21 +188,6 @@ def _namelist_schema(
schema = schema[schema_key]
return schema

def _taskname(self, suffix: str) -> str:
"""
Returns a common tag for graph-task log messages.
:param suffix: Log-string suffix.
"""
cycle = getattr(self, "_cycle", None)
leadtime = getattr(self, "_leadtime", None)
timestr = (
(cycle + leadtime).strftime("%Y%m%d %H:%M:%S")
if cycle and leadtime is not None
else cycle.strftime("%Y%m%d %HZ") if cycle else None
)
return " ".join(filter(None, [timestr, self._driver_name, suffix]))

def _validate(self, schema_file: Optional[Path] = None) -> None:
"""
Perform all necessary schema validation.
Expand Down Expand Up @@ -342,7 +342,7 @@ def run(self):
"""
A run.
"""
yield self._taskname(STR.run)
yield self.taskname(STR.run)
yield (self._run_via_batch_submission() if self._batch else self._run_via_local_execution())

@task
Expand All @@ -351,7 +351,7 @@ def runscript(self):
The runscript.
"""
path = self._runscript_path
yield self._taskname(path.name)
yield self.taskname(path.name)
yield asset(path, path.is_file)
yield None
self._write_runscript(path)
Expand All @@ -361,7 +361,7 @@ def _run_via_batch_submission(self):
"""
A run executed via the batch system.
"""
yield self._taskname("run via batch submission")
yield self.taskname("run via batch submission")
path = Path("%s.submit" % self._runscript_path)
yield asset(path, path.is_file)
yield self.provisioned_rundir()
Expand All @@ -372,7 +372,7 @@ def _run_via_local_execution(self):
"""
A run executed directly on the local system.
"""
yield self._taskname("run via local execution")
yield self.taskname("run via local execution")
path = self.rundir / self._runscript_done_file
yield asset(path, path.is_file)
yield self.provisioned_rundir()
Expand Down
4 changes: 2 additions & 2 deletions src/uwtools/drivers/esg_grid.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ def namelist_file(self):
The namelist file.
"""
fn = "regional_grid.nml"
yield self._taskname(fn)
yield self.taskname(fn)
path = self.rundir / fn
yield asset(path, path.is_file)
base_file = self.config[STR.namelist].get(STR.basefile)
Expand All @@ -43,7 +43,7 @@ def provisioned_rundir(self):
"""
Run directory provisioned with all required content.
"""
yield self._taskname("provisioned run directory")
yield self.taskname("provisioned run directory")
yield [
self.namelist_file(),
self.runscript(),
Expand Down
6 changes: 3 additions & 3 deletions src/uwtools/drivers/filter_topo.py
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ def input_grid_file(self):
"""
src = Path(self.config["config"]["input_grid_file"])
dst = Path(self.config[STR.rundir], src.name)
yield self._taskname("Input grid")
yield self.taskname("Input grid")
yield asset(dst, dst.is_file)
yield symlink(target=src, linkname=dst)

Expand All @@ -38,7 +38,7 @@ def namelist_file(self):
"""
fn = "input.nml"
path = self.rundir / fn
yield self._taskname(f"namelist file {fn}")
yield self.taskname(f"namelist file {fn}")
yield asset(path, path.is_file)
yield None
self._create_user_updated_config(
Expand All @@ -53,7 +53,7 @@ def provisioned_rundir(self):
"""
Run directory provisioned with all required content.
"""
yield self._taskname("provisioned run directory")
yield self.taskname("provisioned run directory")
yield [
self.input_grid_file(),
self.namelist_file(),
Expand Down
Loading

0 comments on commit 35cee0b

Please sign in to comment.