Skip to content

Commit

Permalink
Factor out run script done file. (#503)
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
christinaholtNOAA authored Jun 5, 2024
1 parent bddcf4d commit 9f272a9
Show file tree
Hide file tree
Showing 4 changed files with 15 additions and 4 deletions.
2 changes: 1 addition & 1 deletion recipe/meta.json
Original file line number Diff line number Diff line change
Expand Up @@ -32,5 +32,5 @@
"pyyaml =6.0.*"
]
},
"version": "2.3.0"
"version": "2.3.1"
}
11 changes: 9 additions & 2 deletions src/uwtools/drivers/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down Expand Up @@ -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:
"""
Expand Down Expand Up @@ -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,
)
Expand Down
2 changes: 1 addition & 1 deletion src/uwtools/resources/info.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"version": "2.3.0",
"version": "2.3.1",
"buildnum": "0"
}
4 changes: 4 additions & 0 deletions src/uwtools/tests/drivers/test_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")

Expand Down

0 comments on commit 9f272a9

Please sign in to comment.