Skip to content

Commit

Permalink
Name job after its executable when not specified
Browse files Browse the repository at this point in the history
cmrqs authored and berland committed Dec 16, 2024
1 parent f96d3ce commit 0e19012
Showing 8 changed files with 34 additions and 5 deletions.
2 changes: 1 addition & 1 deletion src/ert/scheduler/driver.py
Original file line number Diff line number Diff line change
@@ -49,7 +49,7 @@ async def submit(
executable: str,
/,
*args: str,
name: str = "dummy",
name: str | None = None,
runpath: Path | None = None,
num_cpu: int | None = 1,
realization_memory: int | None = 0,
2 changes: 1 addition & 1 deletion src/ert/scheduler/local_driver.py
Original file line number Diff line number Diff line change
@@ -29,7 +29,7 @@ async def submit(
executable: str,
/,
*args: str,
name: str = "dummy",
name: str | None = None,
runpath: Path | None = None,
num_cpu: int | None = 1,
realization_memory: int | None = 0,
4 changes: 3 additions & 1 deletion src/ert/scheduler/lsf_driver.py
Original file line number Diff line number Diff line change
@@ -292,13 +292,15 @@ async def submit(
executable: str,
/,
*args: str,
name: str = "dummy",
name: str | None = None,
runpath: Path | None = None,
num_cpu: int | None = 1,
realization_memory: int | None = 0,
) -> None:
if runpath is None:
runpath = Path.cwd()
if name is None:
name = Path(executable).name

arg_queue_name = ["-q", self._queue_name] if self._queue_name else []
arg_project_code = ["-P", self._project_code] if self._project_code else []
4 changes: 3 additions & 1 deletion src/ert/scheduler/openpbs_driver.py
Original file line number Diff line number Diff line change
@@ -215,13 +215,15 @@ async def submit(
executable: str,
/,
*args: str,
name: str = "dummy",
name: str | None = None,
runpath: Path | None = None,
num_cpu: int | None = 1,
realization_memory: int | None = 0,
) -> None:
if runpath is None:
runpath = Path.cwd()
if name is None:
name = Path(executable).name

arg_queue_name = ["-q", self._queue_name] if self._queue_name else []
arg_project_code = ["-A", self._project_code] if self._project_code else []
4 changes: 3 additions & 1 deletion src/ert/scheduler/slurm_driver.py
Original file line number Diff line number Diff line change
@@ -155,13 +155,15 @@ async def submit(
executable: str,
/,
*args: str,
name: str = "dummy",
name: str | None = None,
runpath: Path | None = None,
num_cpu: int | None = 1,
realization_memory: int | None = 0,
) -> None:
if runpath is None:
runpath = Path.cwd()
if name is None:
name = Path(executable).name

script = create_submit_script(runpath, executable, args, self.activate_script)
script_path: Path | None = None
7 changes: 7 additions & 0 deletions tests/ert/unit_tests/scheduler/test_lsf_driver.py
Original file line number Diff line number Diff line change
@@ -1167,6 +1167,13 @@ async def test_submit_with_resource_requirement_with_bsub_capture():
assert "hname" not in Path("captured_bsub_args").read_text(encoding="utf-8")


@pytest.mark.usefixtures("capturing_bsub")
async def test_empty_job_name():
driver = LsfDriver()
await driver.submit(0, "/bin/sleep")
assert " -J sleep " in Path("captured_bsub_args").read_text(encoding="utf-8")


@pytest.mark.integration_test
@pytest.mark.usefixtures("use_tmpdir")
async def test_submit_with_num_cpu(pytestconfig, job_name):
7 changes: 7 additions & 0 deletions tests/ert/unit_tests/scheduler/test_openpbs_driver.py
Original file line number Diff line number Diff line change
@@ -165,6 +165,13 @@ async def test_job_name():
assert " -Nsleepy " in Path("captured_qsub_args").read_text(encoding="utf-8")


@pytest.mark.usefixtures("capturing_qsub")
async def test_empty_job_name():
driver = OpenPBSDriver()
await driver.submit(0, "/bin/sleep")
assert " -Nsleep " in Path("captured_qsub_args").read_text(encoding="utf-8")


@pytest.mark.usefixtures("capturing_qsub")
async def test_job_name_with_prefix():
driver = OpenPBSDriver(job_prefix="pre_")
9 changes: 9 additions & 0 deletions tests/ert/unit_tests/scheduler/test_slurm_driver.py
Original file line number Diff line number Diff line change
@@ -144,6 +144,15 @@ async def test_project_code_is_set(project_code):
)


@pytest.mark.usefixtures("capturing_sbatch")
async def test_empty_job_name():
driver = SlurmDriver()
await driver.submit(0, "/bin/sleep")
assert "--job-name=sleep" in Path("captured_sbatch_args").read_text(
encoding="utf-8"
)


@pytest.mark.usefixtures("capturing_sbatch")
@given(max_runtime=st.floats(min_value=1, max_value=999999999))
async def test_max_runtime_is_properly_formatted(max_runtime):

0 comments on commit 0e19012

Please sign in to comment.