From 15cfd1534c20ae67a6c27e17ce9ba539502280ec Mon Sep 17 00:00:00 2001 From: Jonathan Karlsen Date: Tue, 21 Jan 2025 12:49:06 +0100 Subject: [PATCH] Fix unable to have path object in argslist for localdriver --- src/ert/scheduler/local_driver.py | 6 +++--- tests/ert/unit_tests/scheduler/test_local_driver.py | 12 ++++++++++++ 2 files changed, 15 insertions(+), 3 deletions(-) diff --git a/src/ert/scheduler/local_driver.py b/src/ert/scheduler/local_driver.py index 6db0bd838f8..4fbb532b053 100644 --- a/src/ert/scheduler/local_driver.py +++ b/src/ert/scheduler/local_driver.py @@ -63,9 +63,9 @@ async def finish(self) -> None: raise result logger.info("All realization tasks finished") - async def _run(self, iens: int, executable: str, /, *args: str) -> None: + async def _run(self, iens: int, executable: str, /, *args: str | Path) -> None: logger.debug( - f"Submitting realization {iens} as command '{executable} {' '.join(args)}'" + f"Submitting realization {iens} as command '{executable} {' '.join(str(arg) for arg in args)}'" ) try: proc = await self._init( @@ -100,7 +100,7 @@ async def _dispatch_finished_event(self, iens: int, returncode: int) -> None: self._sent_finished_events.add(iens) @staticmethod - async def _init(iens: int, executable: str, /, *args: str) -> Process: + async def _init(iens: int, executable: str, /, *args: str | Path) -> Process: """This method exists to allow for mocking it in tests""" return await asyncio.create_subprocess_exec( executable, diff --git a/tests/ert/unit_tests/scheduler/test_local_driver.py b/tests/ert/unit_tests/scheduler/test_local_driver.py index 473e8e24c76..40c947e97d5 100644 --- a/tests/ert/unit_tests/scheduler/test_local_driver.py +++ b/tests/ert/unit_tests/scheduler/test_local_driver.py @@ -129,3 +129,15 @@ async def test_that_killing_killed_job_does_not_raise(): await driver.kill(23) await driver.kill(23) assert driver.event_queue.empty() + + +@pytest.mark.timeout(10) +async def test_path_as_argument_is_valid(tmp_path): + driver = LocalDriver() + os.chdir(tmp_path) + + await driver.submit(42, "/usr/bin/env", "touch", Path(tmp_path) / "testfile") + assert await driver.event_queue.get() == StartedEvent(iens=42) + assert await driver.event_queue.get() == FinishedEvent(iens=42, returncode=0) + + assert Path("testfile").exists()