Skip to content

Commit

Permalink
Enable support for spaces in project names by enclosing in quotes (#495)
Browse files Browse the repository at this point in the history
  • Loading branch information
hristog committed May 2, 2021
1 parent 58e0ce2 commit 1f9ae1e
Show file tree
Hide file tree
Showing 2 changed files with 45 additions and 3 deletions.
2 changes: 1 addition & 1 deletion dask_jobqueue/lsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ def __init__(
if queue is not None:
header_lines.append("#BSUB -q %s" % queue)
if project is not None:
header_lines.append("#BSUB -P %s" % project)
header_lines.append('#BSUB -P "%s"' % project)
if ncpus is None:
# Compute default cores specifications
ncpus = self.worker_cores
Expand Down
46 changes: 44 additions & 2 deletions dask_jobqueue/tests/test_lsf.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,26 @@ def test_header():
assert "#BSUB -M 100000" in cluster.job_header
assert "#BSUB -M 28000" not in cluster.job_header
assert "#BSUB -W" in cluster.job_header
assert "#BSUB -P DaskOnLSF" in cluster.job_header
assert '#BSUB -P "DaskOnLSF"' in cluster.job_header

with LSFCluster(
queue="general",
project="Dask On LSF",
processes=4,
cores=8,
memory="28GB",
ncpus=24,
mem=100000000000,
) as cluster:

assert "#BSUB -q general" in cluster.job_header
assert "#BSUB -J dask-worker" in cluster.job_header
assert "#BSUB -n 24" in cluster.job_header
assert "#BSUB -n 8" not in cluster.job_header
assert "#BSUB -M 100000" in cluster.job_header
assert "#BSUB -M 28000" not in cluster.job_header
assert "#BSUB -W" in cluster.job_header
assert '#BSUB -P "Dask On LSF"' in cluster.job_header

with LSFCluster(cores=4, memory="8GB") as cluster:

Expand Down Expand Up @@ -101,14 +120,37 @@ def test_job_script():
assert "#BSUB -M 100000" in cluster.job_header
assert "#BSUB -M 28000" not in cluster.job_header
assert "#BSUB -W" in cluster.job_header
assert "#BSUB -P DaskOnLSF" in cluster.job_header
assert '#BSUB -P "DaskOnLSF"' in cluster.job_header

assert (
"{} -m distributed.cli.dask_worker tcp://".format(sys.executable)
in job_script
)
assert "--nthreads 2 --nprocs 4 --memory-limit 7.00GB" in job_script

with LSFCluster(
walltime="1:00",
cores=1,
memory="16GB",
project="Dask On LSF",
job_extra=["-R rusage[mem=16GB]"],
) as cluster:

job_script = cluster.job_script()

assert "#BSUB -J dask-worker" in cluster.job_header
assert "#BSUB -n 1" in cluster.job_header
assert "#BSUB -R rusage[mem=16GB]" in cluster.job_header
assert "#BSUB -M 16000000" in cluster.job_header
assert "#BSUB -W 1:00" in cluster.job_header
assert '#BSUB -P "Dask On LSF"' in cluster.job_header

assert (
"{} -m distributed.cli.dask_worker tcp://".format(sys.executable)
in job_script
)
assert "--nthreads 1 --memory-limit 16.00GB" in job_script


@pytest.mark.env("lsf")
def test_basic(loop):
Expand Down

0 comments on commit 1f9ae1e

Please sign in to comment.