Skip to content

Commit

Permalink
Allow bkill to silently fail
Browse files Browse the repository at this point in the history
  • Loading branch information
mbhall88 committed Jun 15, 2022
1 parent 1e0df9a commit b74cabf
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions tests/test_lsf_cancel.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ def test_kill_jobs_one_job(

kill_jobs(jobids)

run_process_mock.assert_called_once_with(expected_kill_cmd)
run_process_mock.assert_called_once_with(expected_kill_cmd, check=False)

@patch.object(
OSLayer,
Expand All @@ -92,7 +92,7 @@ def test_kill_jobs_two_jobs(

kill_jobs(jobids)

run_process_mock.assert_called_once_with(expected_kill_cmd)
run_process_mock.assert_called_once_with(expected_kill_cmd, check=False)

@patch.object(
OSLayer,
Expand Down Expand Up @@ -133,4 +133,4 @@ def test_kill_jobs_empty_job_and_non_empty_job(self, run_process_mock):

kill_jobs(jobids)

run_process_mock.assert_called_once_with(expected_kill_cmd)
run_process_mock.assert_called_once_with(expected_kill_cmd, check=False)
4 changes: 2 additions & 2 deletions {{cookiecutter.profile_name}}/OSLayer.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,9 +36,9 @@ def remove_file(file: Path):
file.unlink()

@staticmethod
def run_process(cmd: str) -> Tuple[stdout, stderr]:
def run_process(cmd: str, check: bool = True) -> Tuple[stdout, stderr]:
completed_process = subprocess.run(
cmd, check=True, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE
cmd, check=check, shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE
)
return (
completed_process.stdout.decode().strip(),
Expand Down
2 changes: 1 addition & 1 deletion {{cookiecutter.profile_name}}/lsf_cancel.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def kill_jobs(ids_to_kill: List[str]):
# we don't want to run bkill with no argument as this will kill the last job
if any(ids_to_kill):
cmd = "{} {}".format(KILL, " ".join(ids_to_kill))
_ = OSLayer.run_process(cmd)
_ = OSLayer.run_process(cmd, check=False)


def parse_input() -> List[str]:
Expand Down

0 comments on commit b74cabf

Please sign in to comment.