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

fix: quote jobid passed to status script to support multi-cluster Slurm setup #1459

Merged
merged 3 commits into from Mar 7, 2022
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion snakemake/executors/__init__.py
Expand Up @@ -1215,7 +1215,7 @@ def job_status(job, valid_returns=["running", "success", "failed"]):
if self.sidecar_vars:
env["SNAKEMAKE_CLUSTER_SIDECAR_VARS"] = self.sidecar_vars
ret = subprocess.check_output(
"{statuscmd} {jobid}".format(
"{statuscmd} '{jobid}'".format(
jobid=job.jobid, statuscmd=self.statuscmd
),
shell=True,
Expand Down
13 changes: 13 additions & 0 deletions tests/test_cluster_statusscript_multi/Snakefile.nonstandard
@@ -0,0 +1,13 @@
from snakemake import shell

envvars:
"TESTVAR"



rule all:
input: 'output.txt'

rule compute:
output: 'output.txt'
shell: 'touch {output}'
Empty file.
8 changes: 8 additions & 0 deletions tests/test_cluster_statusscript_multi/sbatch
@@ -0,0 +1,8 @@
#!/bin/bash
echo `date` >> sbatch.log
tail -n1 $1 >> sbatch.log
# simulate printing of job id by a random number plus the name
# of the cluster
echo "$RANDOM;name-of-cluster"
cat $1 >> sbatch.log
sh $1
9 changes: 9 additions & 0 deletions tests/test_cluster_statusscript_multi/status.sh
@@ -0,0 +1,9 @@
#!/bin/bash

# The argument passed from sbatch is "jobid;cluster_name"

arg="$1"
jobid="${arg%%;*}"
cluster="${arg##*;}"

echo success
11 changes: 11 additions & 0 deletions tests/tests.py
Expand Up @@ -166,6 +166,17 @@ def test_cluster_cancelscript_nargs1():
assert len(scancel_lines[1].split(" ")) == 2


@skip_on_windows
def test_cluster_statusscript_multi():
os.environ["TESTVAR"] = "test"
run(
dpath("test_cluster_statusscript_multi"),
snakefile="Snakefile.nonstandard",
cluster="./sbatch",
cluster_status="./status.sh",
)


def test15():
run(dpath("test15"))

Expand Down