Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix unable to have path object in argslist for localdriver #9825

Merged
merged 1 commit into from
Jan 22, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/ert/scheduler/local_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down Expand Up @@ -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,
Expand Down
12 changes: 12 additions & 0 deletions tests/ert/unit_tests/scheduler/test_local_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
xjules marked this conversation as resolved.
Show resolved Hide resolved
assert await driver.event_queue.get() == StartedEvent(iens=42)
assert await driver.event_queue.get() == FinishedEvent(iens=42, returncode=0)

assert Path("testfile").exists()
Loading