Skip to content

Commit

Permalink
Assert sbatch script
Browse files Browse the repository at this point in the history
  • Loading branch information
sverhoeven committed Oct 22, 2024
1 parent 15707da commit 9b4214f
Show file tree
Hide file tree
Showing 4 changed files with 13 additions and 4 deletions.
1 change: 1 addition & 0 deletions src/bartender/schedulers/slurm.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,7 @@ async def submit(self, description: JobDescription) -> str: # noqa: D102):
# must be on a shared filesystem or remote filesystem
script = self._submit_script(description)
command = "sbatch"
logger.debug(f"Submitting job with stdin: \n{script}")
(returncode, stdout, stderr) = await self.runner.run(
command,
args=[],
Expand Down
4 changes: 2 additions & 2 deletions src/bartender/web/api/applications/submit.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,8 @@ async def submit( # noqa: WPS211
job_dir,
payload,
context.applications[application],
application,
submitter.username,
application=application,
submitter=submitter.username,
)

destination_name = context.destination_picker(
Expand Down
2 changes: 1 addition & 1 deletion tests/schedulers/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ def prepare_input(job_dir: Path) -> JobDescription:
return JobDescription(
command="echo -n hello && wc input > output",
job_dir=job_dir,
submitter="test",
submitter="testsubmitter",
application="hellowc",
)

Expand Down
10 changes: 9 additions & 1 deletion tests/schedulers/test_slurm.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import logging
from asyncio import new_event_loop
from pathlib import Path
from typing import Generator
Expand Down Expand Up @@ -69,11 +70,15 @@ def slurm_server() -> Generator[SlurmContainer, None, None]:
async def test_ok_running_job_with_input_and_output_file(
tmp_path: Path,
slurm_server: SlurmContainer,
caplog: pytest.LogCaptureFixture,
) -> None:
caplog.set_level(logging.DEBUG, "bartender.schedulers.slurm")
job_dir = tmp_path
try:
ssh_config = slurm_server.get_config()
scheduler = SlurmScheduler(SlurmSchedulerConfig(ssh_config=ssh_config))
scheduler = SlurmScheduler(
SlurmSchedulerConfig(ssh_config=ssh_config, submitter_as_account=True),
)
description = prepare_input(job_dir)
fs = slurm_server.get_filesystem()
localized_description = fs.localize_description(description, job_dir.parent)
Expand All @@ -87,6 +92,8 @@ async def test_ok_running_job_with_input_and_output_file(
await fs.download(localized_description, description)

assert_output(job_dir)
assert "--job-name=hellowc" in caplog.text
assert "--account=testsubmitter" in caplog.text
finally:
await scheduler.close()

Expand All @@ -113,6 +120,7 @@ async def test_ok_running_job_without_iofiles(
await fs.download(localized_description, description)

assert_output_without_iofiles(job_dir)

finally:
await scheduler.close()

Expand Down

0 comments on commit 9b4214f

Please sign in to comment.