-
Notifications
You must be signed in to change notification settings - Fork 6
Expand file tree
/
Copy pathtest_slurm_command.py
More file actions
61 lines (54 loc) · 1.96 KB
/
Copy pathtest_slurm_command.py
File metadata and controls
61 lines (54 loc) · 1.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
import unittest
from executorlib.standalone.command import generate_slurm_command
try:
from executorlib.standalone.scheduler import pysqa_execute_command
skip_pysqa_test = False
except ImportError:
skip_pysqa_test = True
@unittest.skipIf(
skip_pysqa_test, "pysqa is not installed, so the pysqa tests are skipped."
)
class TestPysqaExecuteCommand(unittest.TestCase):
def test_pysqa_execute_command_list(self):
out = pysqa_execute_command(
commands=["echo", "test"],
working_directory=None,
split_output=True,
shell=True,
error_filename="pysqa.err",
)
self.assertEqual(len(out), 2)
self.assertEqual("test", out[0])
def test_pysqa_execute_command_string(self):
out = pysqa_execute_command(
commands="echo test",
working_directory=None,
split_output=False,
shell=False,
error_filename="pysqa.err",
)
self.assertEqual(len(out), 5)
self.assertEqual("test\n", out)
def test_pysqa_execute_command_fail(self):
with self.assertRaises(FileNotFoundError):
pysqa_execute_command(
commands=["no/executable/available"],
working_directory=None,
split_output=True,
shell=False,
error_filename="pysqa.err",
)
def test_generate_slurm_command(self):
command_lst = generate_slurm_command(
cores=1,
cwd="/tmp/test",
threads_per_core=2,
gpus_per_core=1,
num_nodes=1,
exclusive=True,
openmpi_oversubscribe=True,
slurm_cmd_args=["--help"],
)
self.assertEqual(len(command_lst), 12)
reply_lst = ['srun', '-n', '1', '-D', '/tmp/test', '-N', '1', '--cpus-per-task=2', '--gpus-per-task=1', '--exact', '--oversubscribe', '--help']
self.assertEqual(command_lst, reply_lst)