Skip to content

Commit ca707f9

Browse files
authored
[bug] SLURM: Fix CPUs per task (#569)
* [bug] SLURM: Fix CPUs per task * extend test
1 parent 2fe5ba1 commit ca707f9

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

executorlib/interactive/slurm.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ def generate_slurm_command(
9999
if cwd is not None:
100100
command_prepend_lst += ["-D", cwd]
101101
if threads_per_core > 1:
102-
command_prepend_lst += ["--cpus-per-task" + str(threads_per_core)]
102+
command_prepend_lst += ["--cpus-per-task=" + str(threads_per_core)]
103103
if gpus_per_core > 0:
104104
command_prepend_lst += ["--gpus-per-task=" + str(gpus_per_core)]
105105
if openmpi_oversubscribe:

tests/test_pysqa_subprocess.py

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import unittest
2+
from executorlib.interactive.slurm import generate_slurm_command
23

34
try:
45
from executorlib.cache.queue_spawner import _pysqa_execute_command
@@ -43,3 +44,16 @@ def test_pysqa_execute_command_fail(self):
4344
shell=False,
4445
error_filename="pysqa.err",
4546
)
47+
48+
def test_generate_slurm_command(self):
49+
command_lst = generate_slurm_command(
50+
cores=1,
51+
cwd="/tmp/test",
52+
threads_per_core=2,
53+
gpus_per_core=1,
54+
openmpi_oversubscribe=True,
55+
slurm_cmd_args=["--help"],
56+
)
57+
self.assertEqual(len(command_lst), 9)
58+
reply_lst = ['srun', '-n', '1', '-D', '/tmp/test', '--cpus-per-task=2', '--gpus-per-task=1', '--oversubscribe', '--help']
59+
self.assertEqual(command_lst, reply_lst)

0 commit comments

Comments
 (0)