Skip to content

Commit

Permalink
Add narval system batch job submission via sbatch
Browse files Browse the repository at this point in the history
Configured the system to submit batch jobs for the `narval` cluster using
"sbatch". Updated corresponding tests to include scenarios for `narval`,
ensuring job submissions and environment setups are properly handled. Also
replaced some more `mock.patch()` calls with `monkeypatch.setattr()`.
  • Loading branch information
douglatornell committed Nov 27, 2024
1 parent 402f7ba commit 12a2365
Show file tree
Hide file tree
Showing 2 changed files with 75 additions and 23 deletions.
1 change: 1 addition & 0 deletions salishsea_cmd/run.py
Original file line number Diff line number Diff line change
Expand Up @@ -273,6 +273,7 @@ def run(
"cedar": "sbatch",
"delta": "qsub -q mpi", # optimum.eoas.ubc.ca login node
"graham": "sbatch",
"narval": "sbatch",
"omega": "qsub -q mpi", # optimum.eoas.ubc.ca login node
"orcinus": "qsub",
"salish": "bash",
Expand Down
97 changes: 74 additions & 23 deletions tests/test_run.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,8 @@ class TestRun:
(True, 4, "delta", "qsub -q mpi", "43.admin.default.domain"),
(False, 0, "graham", "sbatch", "Submitted batch job 43"),
(True, 4, "graham", "sbatch", "Submitted batch job 43"),
(False, 0, "narval", "sbatch", "Submitted batch job 43"),
(True, 4, "narval", "sbatch", "Submitted batch job 43"),
(False, 0, "salish", "bash", "bash run_dir/SalishSeaNEMO.sh started"),
(True, 4, "salish", "bash", "bash run_dir/SalishSeaNEMO.sh started"),
(False, 0, "sigma", "qsub -q mpi", "43.admin.default.domain"),
Expand Down Expand Up @@ -224,6 +226,8 @@ def test_run_submit(
(True, 4, "delta", "qsub -q mpi", "43.admin.default.domain"),
(False, 0, "graham", "sbatch", "Submitted batch job 43"),
(True, 4, "graham", "sbatch", "Submitted batch job 43"),
(False, 0, "narval", "sbatch", "Submitted batch job 43"),
(True, 4, "narval", "sbatch", "Submitted batch job 43"),
(False, 0, "salish", "bash", "bash run_dir/SalishSeaNEMO.sh started"),
(True, 4, "salish", "bash", "bash run_dir/SalishSeaNEMO.sh started"),
(False, 0, "sigma", "qsub -q mpi", "43.admin.default.domain"),
Expand Down Expand Up @@ -257,6 +261,7 @@ def test_run_waitjob(
queue_job_cmd,
submit_job_msg,
tmpdir,
monkeypatch,
):
p_run_dir = tmpdir.ensure_dir("run_dir")
p_results_dir = tmpdir.ensure_dir("results_dir")
Expand All @@ -281,10 +286,12 @@ def test_run_waitjob(
Path(str(p_run_dir), "SalishSeaNEMO.sh"),
)
m_sj.return_value = submit_job_msg
with patch("salishsea_cmd.run.SYSTEM", system):
submit_job_msg = salishsea_cmd.run.run(
Path("SalishSea.yaml"), Path(str(p_results_dir)), waitjob="42"
)
monkeypatch.setattr(salishsea_cmd.run, "SYSTEM", system)

submit_job_msg = salishsea_cmd.run.run(
Path("SalishSea.yaml"), Path(str(p_results_dir)), waitjob="42"
)

m_sj.assert_called_once_with(
Path(str(p_run_dir), "SalishSeaNEMO.sh"), queue_job_cmd, waitjob="42"
)
Expand All @@ -303,6 +310,7 @@ def test_run_no_submit(
sep_xios_server,
xios_servers,
tmpdir,
monkeypatch,
):
p_run_dir = tmpdir.ensure_dir("run_dir")
p_results_dir = tmpdir.ensure_dir("results_dir")
Expand All @@ -326,10 +334,12 @@ def test_run_no_submit(
Path(str(p_run_dir)),
Path(str(p_run_dir), "SalishSeaNEMO.sh"),
)
with patch("salishsea_cmd.run.SYSTEM", "orcinus"):
submit_job_msg = salishsea_cmd.run.run(
Path("SalishSea.yaml"), Path(str(p_results_dir)), no_submit=True
)
monkeypatch.setattr(salishsea_cmd.run, "SYSTEM", "orcinus")

submit_job_msg = salishsea_cmd.run.run(
Path("SalishSea.yaml"), Path(str(p_results_dir)), no_submit=True
)

assert not m_sj.called
assert submit_job_msg is None

Expand All @@ -346,6 +356,7 @@ def test_run_no_submit_w_separate_deflate(
sep_xios_server,
xios_servers,
tmpdir,
monkeypatch,
):
p_run_dir = tmpdir.ensure_dir("run_dir")
p_results_dir = tmpdir.ensure_dir("results_dir")
Expand All @@ -369,13 +380,15 @@ def test_run_no_submit_w_separate_deflate(
Path(str(p_run_dir)),
Path(str(p_run_dir), "SalishSeaNEMO.sh"),
)
with patch("salishsea_cmd.run.SYSTEM", "orcinus"):
submit_job_msg = salishsea_cmd.run.run(
Path("SalishSea.yaml"),
Path(str(p_results_dir)),
no_submit=True,
separate_deflate=True,
)
monkeypatch.setattr(salishsea_cmd.run, "SYSTEM", "orcinus")

submit_job_msg = salishsea_cmd.run.run(
Path("SalishSea.yaml"),
Path(str(p_results_dir)),
no_submit=True,
separate_deflate=True,
)

assert not m_sj.called
assert submit_job_msg is None

Expand All @@ -390,6 +403,8 @@ def test_run_no_submit_w_separate_deflate(
(True, 4, "delta", "qsub -q mpi", "43.admin.default.domain"),
(False, 0, "graham", "sbatch", "Submitted batch job 43"),
(True, 4, "graham", "sbatch", "Submitted batch job 43"),
(False, 0, "narval", "sbatch", "Submitted batch job 43"),
(True, 4, "narval", "sbatch", "Submitted batch job 43"),
(False, 0, "salish", "bash", "bash run_dir/SalishSeaNEMO.sh started"),
(True, 4, "salish", "bash", "bash run_dir/SalishSeaNEMO.sh started"),
(False, 0, "sigma", "qsub -q mpi", "43.admin.default.domain"),
Expand Down Expand Up @@ -524,6 +539,22 @@ def test_run_separate_deflate(
("Submitted batch job 43", "Submitted batch job 44"),
"Submitted batch job 43",
),
(
False,
0,
"narval",
"sbatch",
("Submitted batch job 43", "Submitted batch job 44"),
"Submitted batch job 43",
),
(
True,
4,
"narval",
"sbatch",
("Submitted batch job 43", "Submitted batch job 44"),
"Submitted batch job 43",
),
(False, 0, "salish", "bash", ("43.master", "44.master"), "43.master"),
(True, 4, "salish", "bash", ("43.master", "44.master"), "43.master"),
(
Expand Down Expand Up @@ -608,6 +639,7 @@ def test_segmented_run_restart_dirs(
job_msgs,
submit_job_msg,
tmpdir,
monkeypatch,
):
p_run_dir = tmpdir.ensure_dir("run_dir")
p_results_dir = tmpdir.ensure_dir("results_dir")
Expand Down Expand Up @@ -679,10 +711,10 @@ def test_segmented_run_restart_dirs(
Path(str(p_run_dir), "SalishSeaNEMO.sh"),
)
m_sj.side_effect = job_msgs
with patch("salishsea_cmd.run.SYSTEM", system):
submit_job_msg = salishsea_cmd.run.run(
Path("SalishSea.yaml"), Path(str(p_results_dir))
)
monkeypatch.setattr(salishsea_cmd.run, "SYSTEM", system)

salishsea_cmd.run.run(Path("SalishSea.yaml"), Path(str(p_results_dir)))

assert m_wsdf.call_args_list[1][0][2] == Path("results_dir_1")

@pytest.mark.parametrize(
Expand Down Expand Up @@ -752,6 +784,22 @@ def test_segmented_run_restart_dirs(
("Submitted batch job 43", "Submitted batch job 44"),
"Submitted batch job 43",
),
(
False,
0,
"narval",
"sbatch",
("Submitted batch job 43", "Submitted batch job 44"),
"Submitted batch job 43",
),
(
True,
4,
"narval",
"sbatch",
("Submitted batch job 43", "Submitted batch job 44"),
"Submitted batch job 43",
),
(False, 0, "salish", "bash", ("43.master", "44.master"), "43.master"),
(True, 4, "salish", "bash", ("43.master", "44.master"), "43.master"),
(
Expand Down Expand Up @@ -836,6 +884,7 @@ def test_segmented_run_submits(
job_msgs,
submit_job_msg,
tmpdir,
monkeypatch,
):
p_run_dir = tmpdir.ensure_dir("run_dir")
p_results_dir = tmpdir.ensure_dir("results_dir")
Expand Down Expand Up @@ -907,10 +956,12 @@ def test_segmented_run_submits(
Path(str(p_run_dir), "SalishSeaNEMO.sh"),
)
m_sj.side_effect = job_msgs
with patch("salishsea_cmd.run.SYSTEM", system):
submit_job_msg = salishsea_cmd.run.run(
Path("SalishSea.yaml"), Path(str(p_results_dir))
)
monkeypatch.setattr(salishsea_cmd.run, "SYSTEM", system)

submit_job_msg = salishsea_cmd.run.run(
Path("SalishSea.yaml"), Path(str(p_results_dir))
)

assert m_sj.call_args_list == [
call(Path(str(p_run_dir), "SalishSeaNEMO.sh"), queue_job_cmd, waitjob="0"),
call(
Expand Down

0 comments on commit 12a2365

Please sign in to comment.