-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathqueues_and_nodes.py
100 lines (81 loc) · 3.39 KB
/
queues_and_nodes.py
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
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
"""
"""
from __future__ import print_function
from slurm_utils import get_nodes_dict, get_partitions_dict
import numpy as np
import datetime
def main():
node_dict = get_nodes_dict()
nodes = node_dict.keys()
nodes.sort()
partition_dict = get_partitions_dict()
partitions = partition_dict.keys()
partitions.sort()
output_file = open('queues_and_nodes.md', 'w')
output_file.write("# Queues & Nodes \n")
output_file.write("\n")
output_file.write("\n")
line = ("This page contains information on the current queues and nodes installed on the Coma cluster. \n")
output_file.write(line)
output_file.write("\n")
now = datetime.datetime.now()
date = str(now.month) + '/' + str(now.day) + '/' + str(now.year)
line = ("This page was last populated on: " + date )
output_file.write(line)
output_file.write("\n")
output_file.write("\n")
output_file.write("## Queues \n")
output_file.write("\n")
output_file.write("\n")
line = ("Below is a list of the current queues Coma, including the number of nodes,\
and the time limit for jobs. \n")
output_file.write(line)
output_file.write("\n")
output_file.write("\n")
output_file.write("Queue | Number of Nodes | Time Limit [days-hours:minutes:seconds] \n")
output_file.write("----- | --------------- | --------------------------------------- \n")
for queue in partitions:
n_nodes = partition_dict[queue]['NODES']
time_limit = partition_dict[queue]['TIMELIMIT']
line = " ".join([queue, "|", str(n_nodes), "|", time_limit, "\n"])
output_file.write(line)
output_file.write("\n")
output_file.write("\n")
output_file.write("## Nodes \n")
output_file.write("\n")
output_file.write("\n")
line = ("Below is a list of the current nodes installed on Coma, including the number of processors,\
amount of memory, CPU architecture, and queue(s) to which they belong. \n")
output_file.write(line)
line = ("More information on a specific node can be retrieved with the following command: \n")
output_file.write(line)
output_file.write("\n")
output_file.write("```console \n")
output_file.write("user@local:~$ scontrol show node [NODE_NAME] \n")
output_file.write("``` \n")
output_file.write("\n")
output_file.write("\n")
output_file.write("Node | Number of Processors | Total Memory | CPU Architecture | Queues \n")
output_file.write("---- | -------------------- | ------------ | ---------------- | ------ \n")
for node in nodes:
n = int(np.ceil(np.log10(int(node_dict[node]['RealMemory']))/np.log10(2)))
mem = (2**n)/1024
if 'amd' in node_dict[node]['AvailableFeatures']:
cpu = 'AMD'
elif 'intel' in node_dict[node]['AvailableFeatures'][0]:
cpu = 'Intel'
else:
print(node_dict[node]['AvailableFeatures'])
cpu = 'unknown'
try:
queues = ', '.join(node_dict[node]['Partitions'])
except KeyError:
queues = 'none'
line = " ".join([node, "|", node_dict[node]['CPUTot'], "|", str(mem), "|", cpu, "|", queues, "\n"])
output_file.write(line)
output_file.write("\n")
output_file.write("\n")
line = ("This page was created by running the `queues_and_nodes.py` script on Coma. \n")
output_file.write(line)
if __name__ == "__main__":
main()