Skip to content

Commit 6f31489

Browse files
committed
small update
1 parent 0a16243 commit 6f31489

File tree

3 files changed

+34
-57
lines changed

3 files changed

+34
-57
lines changed

array.pbs

Lines changed: 0 additions & 16 deletions
This file was deleted.

array.sbatch

Lines changed: 0 additions & 16 deletions
This file was deleted.

smartdispatch/tests/pbs_slurm_test.py

Lines changed: 34 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -42,10 +42,10 @@
4242
nvidia-smi
4343
"""
4444

45-
def test_param(self, param_array, command, flag, string=pbs_string):
45+
def test_param(param_array, com, flag, string=pbs_string):
4646
for param in param_array:
4747
command = pbs_string.format(
48-
string.format(command.format(param))
48+
string.format(com.format(param))
4949
)
5050
with open("test.pbs", "w") as text_file:
5151
text_file.write(command)
@@ -58,12 +58,13 @@ def test_param(self, param_array, command, flag, string=pbs_string):
5858
process = Popen("squeue -u $USER -j {} -O {}".format(job_id, flag), stdout=PIPE, stderr=PIPE, shell=True)
5959
stdout, stderr = process.communicate()
6060
job_params = [c.strip() for c in stdout.split("\n")[1:] if c != '']
61+
# import ipdb; ipdb.set_trace()
6162
assert_true(all(p == param for p in job_params))
6263

6364
class TestSlurm(unittest.TestCase):
6465

6566
def tearDown(self):
66-
process = Popen("rm *.out", stdout=PIPE, stderr=PIPE, shell=True)
67+
process = Popen("rm *.out test.pbs", stdout=PIPE, stderr=PIPE, shell=True)
6768
stdout, stderr = process.communicate()
6869

6970
def test_priority(self):
@@ -76,7 +77,7 @@ def test_priority(self):
7677

7778
def test_gres(self):
7879
test_param(
79-
['titanblack],
80+
['titanblack'],
8081
"#PBS -l naccelerators={}",
8182
"gres",
8283
pbs_string
@@ -94,31 +95,39 @@ def test_nb_cpus(self):
9495
test_param(
9596
["1", "2"],
9697
"PBS -l ncpus={}",
97-
"cpuspertask", # or numcpus
98+
"numcpus",
9899
pbs_string
99100
)
100101

102+
def test_constraint(self):
103+
test_param(
104+
["gpu6gb", "gpu8gb"],
105+
"PBS -l proc={}",
106+
"feature",
107+
pbs_string
108+
)
101109

102-
pbs_string2 = """\
103-
#!/usr/bin/env /bin/bash
104-
105-
#PBS -N arrayJob
106-
#PBS -o arrayJob_%A_%a.out
107-
#PBS -t 1-5
108-
#PBS -l walltime=01:00:00
109-
#PBS -l naccelerators=1
110-
#PBS -l proc={cons}
111-
#PBS -M {mail}
112-
#SBATCH --qos {priority}
113-
114-
######################
115-
# Begin work section #
116-
######################
117-
118-
echo "My SLURM_ARRAY_JOB_ID:" $SLURM_ARRAY_JOB_ID
119-
echo "My SLURM_ARRAY_TASK_ID: " $SLURM_ARRAY_TASK_ID
120-
nvidia-smi
121-
"""
110+
#
111+
# pbs_string2 = """\
112+
# #!/usr/bin/env /bin/bash
113+
#
114+
# #PBS -N arrayJob
115+
# #PBS -o arrayJob_%A_%a.out
116+
# #PBS -t 1-5
117+
# #PBS -l walltime=01:00:00
118+
# #PBS -l naccelerators=1
119+
# #PBS -l proc={cons}
120+
# #PBS -M {mail}
121+
# #SBATCH --qos {priority}
122+
#
123+
# ######################
124+
# # Begin work section #
125+
# ######################
126+
#
127+
# echo "My SLURM_ARRAY_JOB_ID:" $SLURM_ARRAY_JOB_ID
128+
# echo "My SLURM_ARRAY_TASK_ID: " $SLURM_ARRAY_TASK_ID
129+
# nvidia-smi
130+
# """
122131

123132
if __name__ == '__main__':
124133
unittest.main()

0 commit comments

Comments
 (0)