Skip to content

Commit

Permalink
Use runpath as Path always
Browse files Browse the repository at this point in the history
  • Loading branch information
berland committed Mar 11, 2024
1 parent 3a192a2 commit ab861f8
Show file tree
Hide file tree
Showing 5 changed files with 14 additions and 19 deletions.
4 changes: 2 additions & 2 deletions src/ert/scheduler/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
import asyncio
from abc import ABC, abstractmethod
from pathlib import Path
from typing import Dict, Optional, Union
from typing import Dict, Optional

from ert.scheduler.event import Event

Expand All @@ -28,7 +28,7 @@ async def submit(
/,
*args: str,
name: str = "dummy",
runpath: Optional[Union[str, Path]] = None,
runpath: Optional[Path] = None,
) -> None:
"""Submit a program to execute on the cluster.
Expand Down
2 changes: 1 addition & 1 deletion src/ert/scheduler/job.py
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ async def _submit_and_run_once(self, sem: asyncio.BoundedSemaphore) -> None:
self.real.job_script,
self.real.run_arg.runpath,
name=self.real.run_arg.job_name,
runpath=self.real.run_arg.runpath,
runpath=Path(self.real.run_arg.runpath),
)

await self._send(State.PENDING)
Expand Down
4 changes: 2 additions & 2 deletions src/ert/scheduler/local_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import os
from asyncio.subprocess import Process
from pathlib import Path
from typing import MutableMapping, Optional, Union
from typing import MutableMapping, Optional

from ert.scheduler.driver import Driver
from ert.scheduler.event import FinishedEvent, StartedEvent
Expand All @@ -24,7 +24,7 @@ async def submit(
/,
*args: str,
name: str = "dummy",
runpath: Optional[Union[str, Path]] = None,
runpath: Optional[Path] = None,
) -> None:
await self.kill(iens)
self._tasks[iens] = asyncio.create_task(self._run(iens, executable, *args))
Expand Down
14 changes: 6 additions & 8 deletions src/ert/scheduler/lsf_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import asyncio
import json
import logging
import os
import re
import shlex
import shutil
Expand Down Expand Up @@ -106,10 +105,10 @@ async def submit(
/,
*args: str,
name: str = "dummy",
runpath: Optional[Union[str, Path]] = None,
runpath: Optional[Path] = None,
) -> None:
if runpath is None:
runpath = os.getcwd()
runpath = Path.cwd()

arg_queue_name = ["-q", self._queue_name] if self._queue_name else []

Expand All @@ -119,7 +118,7 @@ async def submit(
f"exec -a {shlex.quote(executable)} {executable} {shlex.join(args)}\n"
# f"{executable} {shlex.join(args)}\n"
)
script_path = Path(runpath) / "job_script.sh"
script_path = runpath / "job_script.sh"
script_path.write_text(script, encoding="utf-8")
script_path.chmod(script_path.stat().st_mode | stat.S_IEXEC)

Expand Down Expand Up @@ -151,10 +150,9 @@ async def submit(
job_id = match[1]
logger.info(f"Realization {iens} accepted by LSF, got id {job_id}")

if runpath is not None:
(Path(runpath) / LSF_INFO_JSON_FILENAME).write_text(
json.dumps({"job_id": job_id}), encoding="utf-8"
)
(runpath / LSF_INFO_JSON_FILENAME).write_text(
json.dumps({"job_id": job_id}), encoding="utf-8"
)
self._jobs[job_id] = (iens, "PEND")
self._iens2jobid[iens] = job_id

Expand Down
9 changes: 3 additions & 6 deletions src/ert/scheduler/openpbs_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

import asyncio
import logging
import os
import shlex
import stat
from pathlib import Path
Expand Down Expand Up @@ -205,12 +204,10 @@ async def submit(
/,
*args: str,
name: str = "dummy",
runpath: Optional[Union[Path, str]] = None,
runpath: Optional[Path] = None,
) -> None:
if runpath is None:
runpath = os.getcwd()

print(f"{runpath=}")
runpath = Path.cwd()

arg_queue_name = ["-q", self._queue_name] if self._queue_name else []
arg_keep_qsub_output = (
Expand All @@ -223,7 +220,7 @@ async def submit(
f"exec -a {shlex.quote(executable)} {executable} {shlex.join(args)}\n"
# f"{executable} {shlex.join(args)}\n"
)
script_path = Path(runpath) / "job_script.sh"
script_path = runpath / "job_script.sh"
script_path.write_text(script, encoding="utf-8")
script_path.chmod(script_path.stat().st_mode | stat.S_IEXEC)
name_prefix = self._job_prefix or ""
Expand Down

0 comments on commit ab861f8

Please sign in to comment.