From 9f272a950c7968f2fd8d02b04a2f6f234fcfb254 Mon Sep 17 00:00:00 2001 From: Christina Holt <56881914+christinaholtNOAA@users.noreply.github.com> Date: Wed, 5 Jun 2024 09:49:20 -0600 Subject: [PATCH] Factor out run script done file. (#503) The run script done file definition existed in two places and was out of sync. This fix DRYs the name of that file ensuring the task is responsible for writing the asset that it requires to be complete. --- recipe/meta.json | 2 +- src/uwtools/drivers/driver.py | 11 +++++++++-- src/uwtools/resources/info.json | 2 +- src/uwtools/tests/drivers/test_driver.py | 4 ++++ 4 files changed, 15 insertions(+), 4 deletions(-) diff --git a/recipe/meta.json b/recipe/meta.json index 38fe47447..09cf57924 100644 --- a/recipe/meta.json +++ b/recipe/meta.json @@ -32,5 +32,5 @@ "pyyaml =6.0.*" ] }, - "version": "2.3.0" + "version": "2.3.1" } diff --git a/src/uwtools/drivers/driver.py b/src/uwtools/drivers/driver.py index eca4cf8a5..5de6330a4 100644 --- a/src/uwtools/drivers/driver.py +++ b/src/uwtools/drivers/driver.py @@ -237,7 +237,7 @@ def _run_via_local_execution(self): A run executed directly on the local system. """ yield self._taskname("run via local execution") - path = self._rundir / f"done.{self._driver_name}" + path = self._rundir / self._runscript_done_file yield asset(path, path.is_file) yield self.provisioned_run_directory() cmd = "{x} >{x}.out 2>&1".format(x=self._runscript_path) @@ -312,6 +312,13 @@ def _runscript( ) return re.sub(r"\n\n\n+", "\n\n", rs.strip()) + @property + def _runscript_done_file(self): + """ + The path to the done file produced by the successful completion of a run script. + """ + return f"{self._runscript_path.name}.done" + @property def _runscript_path(self) -> Path: """ @@ -343,7 +350,7 @@ def _write_runscript(self, path: Path, envvars: Dict[str, str]) -> None: envvars=envvars, execution=[ "time %s" % self._runcmd, - "test $? -eq 0 && touch %s.done" % self._runscript_path.name, + "test $? -eq 0 && touch %s" % self._runscript_done_file, ], scheduler=self._scheduler if self._batch else None, ) diff --git a/src/uwtools/resources/info.json b/src/uwtools/resources/info.json index 674c8cbba..948e92c4d 100644 --- a/src/uwtools/resources/info.json +++ b/src/uwtools/resources/info.json @@ -1,4 +1,4 @@ { - "version": "2.3.0", + "version": "2.3.1", "buildnum": "0" } diff --git a/src/uwtools/tests/drivers/test_driver.py b/src/uwtools/tests/drivers/test_driver.py index 49c2cdd1a..eff8efa59 100644 --- a/src/uwtools/tests/drivers/test_driver.py +++ b/src/uwtools/tests/drivers/test_driver.py @@ -426,6 +426,10 @@ def test_Driver__runscript_execution_only(driverobj): assert driverobj._runscript(execution=["foo", "bar"]) == dedent(expected).strip() +def test_Driver__runscript_done_file(driverobj): + assert driverobj._runscript_done_file == "runscript.concrete.done" + + def test_Driver__runscript_path(driverobj): assert driverobj._runscript_path == Path("/path/to/2024032218/run/runscript.concrete")