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

Name job after its executable when not specified #9438

Merged
merged 1 commit into from
Dec 16, 2024
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
2 changes: 1 addition & 1 deletion src/ert/scheduler/driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
2 changes: 1 addition & 1 deletion src/ert/scheduler/local_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down
4 changes: 3 additions & 1 deletion src/ert/scheduler/lsf_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This spurred this "bug": #9564 (but it does not have to be solved in this PR since the problem existed beforehand)


arg_queue_name = ["-q", self._queue_name] if self._queue_name else []
arg_project_code = ["-P", self._project_code] if self._project_code else []
Expand Down
4 changes: 3 additions & 1 deletion src/ert/scheduler/openpbs_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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 []
Expand Down
4 changes: 3 additions & 1 deletion src/ert/scheduler/slurm_driver.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
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
Expand Up @@ -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):
Expand Down
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
Expand Up @@ -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_")
Expand Down
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
Expand Up @@ -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):
Expand Down
Loading