richqueue 0.5__py3-none-any.whl → 0.7__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- richqueue/console.py +3 -0
- richqueue/layout.py +29 -0
- richqueue/main.py +90 -0
- richqueue/slurm.py +235 -262
- richqueue/table.py +368 -0
- richqueue/tools.py +7 -0
- richqueue-0.7.dist-info/METADATA +57 -0
- richqueue-0.7.dist-info/RECORD +12 -0
- richqueue-0.5.dist-info/METADATA +0 -19
- richqueue-0.5.dist-info/RECORD +0 -8
- {richqueue-0.5.dist-info → richqueue-0.7.dist-info}/WHEEL +0 -0
- {richqueue-0.5.dist-info → richqueue-0.7.dist-info}/entry_points.txt +0 -0
- {richqueue-0.5.dist-info → richqueue-0.7.dist-info}/licenses/LICENSE +0 -0
richqueue/console.py
ADDED
richqueue/layout.py
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from rich.layout import Layout
|
|
2
|
+
from rich.panel import Panel
|
|
3
|
+
from .slurm import PANEL_PADDING
|
|
4
|
+
from rich.text import Text
|
|
5
|
+
|
|
6
|
+
|
|
7
|
+
def dual_layout(function, **kwargs):
|
|
8
|
+
|
|
9
|
+
layout = Layout()
|
|
10
|
+
|
|
11
|
+
upper, lower = function(**kwargs)
|
|
12
|
+
|
|
13
|
+
upper = Layout(renderable=upper, name="upper")
|
|
14
|
+
lower = Layout(renderable=lower, name="lower")
|
|
15
|
+
|
|
16
|
+
upper.size = upper.renderable.renderable.row_count + PANEL_PADDING
|
|
17
|
+
lower.size = lower.renderable.renderable.row_count + PANEL_PADDING
|
|
18
|
+
|
|
19
|
+
layout.split_column(
|
|
20
|
+
upper,
|
|
21
|
+
lower,
|
|
22
|
+
)
|
|
23
|
+
|
|
24
|
+
return layout
|
|
25
|
+
|
|
26
|
+
|
|
27
|
+
def simple_layout():
|
|
28
|
+
|
|
29
|
+
raise NotImplementedError
|
richqueue/main.py
ADDED
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
from typer import Typer
|
|
2
|
+
from .layout import dual_layout
|
|
3
|
+
from rich.live import Live
|
|
4
|
+
import time
|
|
5
|
+
from .console import console
|
|
6
|
+
from .tools import curry
|
|
7
|
+
from .slurm import get_layout_pair, get_node_layout, get_hist_layout
|
|
8
|
+
|
|
9
|
+
# set up singletons
|
|
10
|
+
app = Typer()
|
|
11
|
+
|
|
12
|
+
# main CLI command
|
|
13
|
+
|
|
14
|
+
|
|
15
|
+
@app.command()
|
|
16
|
+
def show(
|
|
17
|
+
user: None | str = None,
|
|
18
|
+
long: bool = False,
|
|
19
|
+
idle: bool = False,
|
|
20
|
+
loop: bool = True,
|
|
21
|
+
hist: int | None = None,
|
|
22
|
+
hist_unit: str = "weeks",
|
|
23
|
+
# screen: bool = True,
|
|
24
|
+
# disappear: bool = True,
|
|
25
|
+
):
|
|
26
|
+
|
|
27
|
+
screen = True
|
|
28
|
+
disappear = not screen
|
|
29
|
+
|
|
30
|
+
kwargs = {
|
|
31
|
+
"user": user,
|
|
32
|
+
"long": long,
|
|
33
|
+
"idle": idle,
|
|
34
|
+
"loop": loop,
|
|
35
|
+
"hist": hist,
|
|
36
|
+
"hist_unit": hist_unit,
|
|
37
|
+
"screen": screen,
|
|
38
|
+
"disappear": disappear,
|
|
39
|
+
}
|
|
40
|
+
|
|
41
|
+
# console.print(kwargs)
|
|
42
|
+
|
|
43
|
+
match (bool(idle), bool(hist)):
|
|
44
|
+
case (True, False):
|
|
45
|
+
loop = False
|
|
46
|
+
layout_func = get_node_layout
|
|
47
|
+
case (False, True):
|
|
48
|
+
loop = False
|
|
49
|
+
layout_func = get_hist_layout
|
|
50
|
+
case (False, False):
|
|
51
|
+
layout_func = curry(dual_layout, get_layout_pair)
|
|
52
|
+
case _:
|
|
53
|
+
raise Exception("Unsupported CLI options")
|
|
54
|
+
|
|
55
|
+
# live updating layout
|
|
56
|
+
if loop:
|
|
57
|
+
|
|
58
|
+
layout = layout_func(**kwargs)
|
|
59
|
+
|
|
60
|
+
with Live(
|
|
61
|
+
layout,
|
|
62
|
+
refresh_per_second=4,
|
|
63
|
+
screen=screen,
|
|
64
|
+
transient=disappear,
|
|
65
|
+
vertical_overflow="visible",
|
|
66
|
+
) as live:
|
|
67
|
+
|
|
68
|
+
try:
|
|
69
|
+
while True:
|
|
70
|
+
layout = layout_func(**kwargs)
|
|
71
|
+
live.update(layout)
|
|
72
|
+
time.sleep(1)
|
|
73
|
+
except KeyboardInterrupt:
|
|
74
|
+
live.stop()
|
|
75
|
+
|
|
76
|
+
# static layout
|
|
77
|
+
else:
|
|
78
|
+
|
|
79
|
+
layout = layout_func(**kwargs)
|
|
80
|
+
console.print(layout)
|
|
81
|
+
|
|
82
|
+
|
|
83
|
+
# start Typer app
|
|
84
|
+
def main():
|
|
85
|
+
app()
|
|
86
|
+
|
|
87
|
+
|
|
88
|
+
# start Typer app
|
|
89
|
+
if __name__ == "__main__":
|
|
90
|
+
app()
|
richqueue/slurm.py
CHANGED
|
@@ -1,207 +1,147 @@
|
|
|
1
|
-
from
|
|
1
|
+
from pandas import concat, DataFrame, isnull
|
|
2
|
+
from rich.panel import Panel
|
|
3
|
+
from rich.text import Text
|
|
4
|
+
import subprocess
|
|
2
5
|
import json
|
|
6
|
+
from .console import console
|
|
7
|
+
from pathlib import Path
|
|
3
8
|
import datetime
|
|
4
|
-
from
|
|
5
|
-
from
|
|
6
|
-
from rich.layout import Layout
|
|
7
|
-
from pandas import DataFrame
|
|
9
|
+
from .table import running_job_table, history_job_table, node_table
|
|
10
|
+
from .tools import human_timedelta
|
|
8
11
|
|
|
9
|
-
|
|
12
|
+
# from numpy import isnat
|
|
10
13
|
|
|
11
14
|
METADATA = {}
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
PANEL_PADDING = 4
|
|
14
17
|
|
|
18
|
+
### CONSTRUCT LAYOUT
|
|
15
19
|
|
|
16
|
-
def color_by_state(state):
|
|
17
20
|
|
|
18
|
-
|
|
19
|
-
return "[bold bright_green]Running"
|
|
20
|
-
elif state == "PENDING":
|
|
21
|
-
return "[bright_yellow]Pending"
|
|
22
|
-
elif state == "CANCELLED":
|
|
23
|
-
return "[orange3]Cancelled"
|
|
24
|
-
elif state == "FAILED":
|
|
25
|
-
return "[bold bright_red]Failed"
|
|
26
|
-
elif state == "COMPLETED":
|
|
27
|
-
return "[bold bright_green]Completed"
|
|
28
|
-
else:
|
|
29
|
-
return state
|
|
21
|
+
def get_layout_pair(user: str | None, **kwargs):
|
|
30
22
|
|
|
23
|
+
if user == "all":
|
|
24
|
+
user = None
|
|
25
|
+
elif user is None:
|
|
26
|
+
x = subprocess.Popen(["whoami"], shell=True, stdout=subprocess.PIPE)
|
|
27
|
+
output = x.communicate()
|
|
28
|
+
user = output[0].strip().decode("utf-8")
|
|
31
29
|
|
|
32
|
-
|
|
30
|
+
df = combined_df(user=user, **kwargs)
|
|
33
31
|
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
if d["set"]:
|
|
38
|
-
return d[inner]
|
|
39
|
-
else:
|
|
40
|
-
return None
|
|
41
|
-
else:
|
|
42
|
-
return d[inner]
|
|
32
|
+
n_rows = len(df)
|
|
33
|
+
n_running = len(df[df["job_state"] == "RUNNING"])
|
|
34
|
+
n_pending = len(df[df["job_state"] == "PENDING"])
|
|
43
35
|
|
|
44
|
-
|
|
36
|
+
hide_pending = False
|
|
45
37
|
|
|
38
|
+
running_df = df[df["job_state"].isin(["RUNNING", "PENDING"])]
|
|
39
|
+
history_df = df[~df["job_state"].isin(["RUNNING", "PENDING"])]
|
|
46
40
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
lambda x: datetime.datetime.fromtimestamp(x[key]["number"]), axis=1
|
|
50
|
-
)
|
|
41
|
+
console_height = console.size.height
|
|
42
|
+
max_rows = console_height - 2 * PANEL_PADDING
|
|
51
43
|
|
|
44
|
+
if n_rows > max_rows:
|
|
52
45
|
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
df["end_time"] = df.apply(
|
|
58
|
-
lambda x: datetime.datetime.fromtimestamp(x["time"]["end"]), axis=1
|
|
59
|
-
)
|
|
60
|
-
df["submit_time"] = df.apply(
|
|
61
|
-
lambda x: datetime.datetime.fromtimestamp(x["time"]["submission"]), axis=1
|
|
62
|
-
)
|
|
46
|
+
# hide history?
|
|
47
|
+
if n_running + n_pending + PANEL_PADDING + 1 < console_height:
|
|
48
|
+
history_limit = 0
|
|
49
|
+
running_limit = None
|
|
63
50
|
|
|
51
|
+
# hide pending?
|
|
52
|
+
elif n_rows - n_pending < max_rows:
|
|
53
|
+
# running_df = running_df[running_df["job_state"]=="RUNNING"]
|
|
54
|
+
running_limit = None
|
|
55
|
+
history_limit = None
|
|
56
|
+
hide_pending = n_pending
|
|
64
57
|
|
|
65
|
-
|
|
66
|
-
def inner(x):
|
|
67
|
-
if len(x[key]) == 1:
|
|
68
|
-
return x[key][0]
|
|
58
|
+
# fallback clip
|
|
69
59
|
else:
|
|
70
|
-
|
|
60
|
+
running_limit = 5
|
|
61
|
+
history_limit = 5
|
|
71
62
|
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
)
|
|
84
|
-
|
|
85
|
-
from rich.table import Table
|
|
86
|
-
|
|
87
|
-
if box:
|
|
88
|
-
from rich.box import SIMPLE
|
|
89
|
-
|
|
90
|
-
box = SIMPLE
|
|
91
|
-
|
|
92
|
-
from .tools import human_timedelta, human_datetime
|
|
93
|
-
|
|
94
|
-
num_nodes = "node_count" in df.columns
|
|
95
|
-
num_cores = "cpus" in df.columns
|
|
96
|
-
start_time = "start_time" in df.columns
|
|
97
|
-
end_time = "end_time" in df.columns
|
|
98
|
-
submit_time = "submit_time" in df.columns
|
|
99
|
-
|
|
100
|
-
table = Table(title=title, box=box, header_style="")
|
|
101
|
-
|
|
102
|
-
table.add_column(
|
|
103
|
-
"[bold underline]Job Id", justify="right", style="bold", no_wrap=True
|
|
104
|
-
)
|
|
105
|
-
table.add_column(
|
|
106
|
-
"[underline cyan]Job Name", justify="left", style="cyan", no_wrap=False
|
|
63
|
+
else:
|
|
64
|
+
running_limit = None
|
|
65
|
+
history_limit = None
|
|
66
|
+
|
|
67
|
+
running = Panel(
|
|
68
|
+
running_job_table(
|
|
69
|
+
running_df,
|
|
70
|
+
limit=running_limit,
|
|
71
|
+
hide_pending=hide_pending,
|
|
72
|
+
user=user,
|
|
73
|
+
**kwargs,
|
|
74
|
+
),
|
|
75
|
+
expand=False,
|
|
107
76
|
)
|
|
108
|
-
if num_nodes:
|
|
109
|
-
table.add_column(
|
|
110
|
-
"[underline magenta]#N", justify="right", style="magenta", no_wrap=True
|
|
111
|
-
)
|
|
112
|
-
if num_cores:
|
|
113
|
-
table.add_column(
|
|
114
|
-
"[underline magenta]#C", justify="right", style="magenta", no_wrap=True
|
|
115
|
-
)
|
|
116
77
|
|
|
117
|
-
if
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
)
|
|
124
|
-
|
|
125
|
-
if long and start_time:
|
|
126
|
-
table.add_column(
|
|
127
|
-
"[underline dodger_blue2]Started",
|
|
128
|
-
justify="right",
|
|
129
|
-
style="dodger_blue2",
|
|
130
|
-
no_wrap=True,
|
|
131
|
-
)
|
|
132
|
-
|
|
133
|
-
if start_time:
|
|
134
|
-
table.add_column(
|
|
135
|
-
"[underline dodger_blue2]Run Time",
|
|
136
|
-
justify="right",
|
|
137
|
-
style="dodger_blue2",
|
|
138
|
-
no_wrap=True,
|
|
78
|
+
if history_limit == 0:
|
|
79
|
+
history = Text("history hidden, resize window or use --hist")
|
|
80
|
+
else:
|
|
81
|
+
history = Panel(
|
|
82
|
+
history_job_table(history_df, limit=history_limit, user=user, **kwargs),
|
|
83
|
+
expand=False,
|
|
139
84
|
)
|
|
140
85
|
|
|
141
|
-
|
|
142
|
-
table.add_column(
|
|
143
|
-
"[underline green_yellow]Partition",
|
|
144
|
-
justify="right",
|
|
145
|
-
style="green_yellow",
|
|
146
|
-
no_wrap=True,
|
|
147
|
-
)
|
|
148
|
-
table.add_column(
|
|
149
|
-
"[underline green_yellow]Nodes",
|
|
150
|
-
justify="left",
|
|
151
|
-
style="green_yellow",
|
|
152
|
-
no_wrap=False,
|
|
153
|
-
)
|
|
86
|
+
return running, history
|
|
154
87
|
|
|
155
|
-
table.add_column("[underline bold]State", justify="left", style=None, no_wrap=True)
|
|
156
88
|
|
|
157
|
-
|
|
89
|
+
def get_hist_layout(user: str | None, **kwargs):
|
|
158
90
|
|
|
159
|
-
|
|
160
|
-
|
|
91
|
+
if user == "all":
|
|
92
|
+
user = None
|
|
93
|
+
elif user is None:
|
|
94
|
+
x = subprocess.Popen(["whoami"], shell=True, stdout=subprocess.PIPE)
|
|
95
|
+
output = x.communicate()
|
|
96
|
+
user = output[0].strip().decode("utf-8")
|
|
161
97
|
|
|
162
|
-
|
|
163
|
-
start_time = human_datetime(row.start_time)
|
|
98
|
+
df = combined_df(user=user, **kwargs)
|
|
164
99
|
|
|
165
|
-
|
|
166
|
-
run_time = human_timedelta(row.end_time - row.start_time)
|
|
167
|
-
else:
|
|
168
|
-
run_time = human_timedelta(datetime.datetime.now() - row.start_time)
|
|
100
|
+
history_df = df[~df["job_state"].isin(["RUNNING", "PENDING"])]
|
|
169
101
|
|
|
170
|
-
|
|
102
|
+
history = Panel(
|
|
103
|
+
history_job_table(history_df, limit=None, user=user, **kwargs),
|
|
104
|
+
expand=False,
|
|
105
|
+
)
|
|
171
106
|
|
|
172
|
-
|
|
173
|
-
values.append(row.node_count)
|
|
174
|
-
if num_cores:
|
|
175
|
-
values.append(row.cpus)
|
|
107
|
+
return history
|
|
176
108
|
|
|
177
|
-
if force_submit_time or long and submit_time:
|
|
178
|
-
values.append(submit_time)
|
|
179
109
|
|
|
180
|
-
|
|
181
|
-
values.append(start_time)
|
|
110
|
+
def get_node_layout(idle: bool = True, **kwargs):
|
|
182
111
|
|
|
183
|
-
|
|
184
|
-
values.append(run_time)
|
|
112
|
+
df = get_sinfo(**kwargs)
|
|
185
113
|
|
|
186
|
-
|
|
187
|
-
|
|
114
|
+
if idle:
|
|
115
|
+
df = df[df["node_state"].isin(["IDLE", "MIXED"])]
|
|
188
116
|
|
|
189
|
-
|
|
117
|
+
table = node_table(df, **kwargs)
|
|
190
118
|
|
|
191
|
-
|
|
119
|
+
return Panel(table, expand=False)
|
|
192
120
|
|
|
193
|
-
if panel:
|
|
194
|
-
table = Panel(table, expand=False)
|
|
195
121
|
|
|
196
|
-
|
|
197
|
-
return table
|
|
122
|
+
### GET QUEUE DFs
|
|
198
123
|
|
|
199
|
-
console.print(table)
|
|
200
124
|
|
|
125
|
+
def get_squeue(user: str | None = None, **kwargs) -> "pandas.DataFrame":
|
|
201
126
|
|
|
202
|
-
|
|
127
|
+
if user:
|
|
128
|
+
command = f"squeue -u {user} --json"
|
|
129
|
+
else:
|
|
130
|
+
command = f"squeue --json"
|
|
203
131
|
|
|
204
|
-
|
|
132
|
+
try:
|
|
133
|
+
process = subprocess.Popen(
|
|
134
|
+
[command], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
|
135
|
+
)
|
|
136
|
+
output = process.communicate()
|
|
137
|
+
payload = json.loads(output[0])
|
|
138
|
+
except json.JSONDecodeError:
|
|
139
|
+
# console.print('[orange1 bold]Warning: using example data')
|
|
140
|
+
payload = json.load(
|
|
141
|
+
open(
|
|
142
|
+
Path(__file__).parent.parent / "example_data" / "squeue_long.json", "rt"
|
|
143
|
+
)
|
|
144
|
+
)
|
|
205
145
|
|
|
206
146
|
global METADATA
|
|
207
147
|
|
|
@@ -215,14 +155,11 @@ def parse_squeue_json(payload: dict) -> "DataFrame":
|
|
|
215
155
|
df = DataFrame(payload["jobs"])
|
|
216
156
|
|
|
217
157
|
# filter columns
|
|
218
|
-
|
|
219
|
-
columns = COLUMNS[command]
|
|
158
|
+
columns = COLUMNS["squeue"]
|
|
220
159
|
|
|
221
160
|
try:
|
|
222
161
|
df = df[columns]
|
|
223
|
-
|
|
224
162
|
except KeyError:
|
|
225
|
-
|
|
226
163
|
for key in columns:
|
|
227
164
|
if key not in df.columns:
|
|
228
165
|
raise KeyError(key)
|
|
@@ -241,32 +178,48 @@ def parse_squeue_json(payload: dict) -> "DataFrame":
|
|
|
241
178
|
return df
|
|
242
179
|
|
|
243
180
|
|
|
244
|
-
def
|
|
181
|
+
def get_sacct(
|
|
182
|
+
user: str | None = None, hist: int | None = 4, hist_unit: str = "weeks", **kwargs
|
|
183
|
+
) -> "pandas.DataFrame":
|
|
245
184
|
|
|
246
|
-
|
|
185
|
+
hist = hist or 4
|
|
186
|
+
|
|
187
|
+
if user:
|
|
188
|
+
command = f"sacct -u {user} --json -S now-{hist}{hist_unit}"
|
|
189
|
+
else:
|
|
190
|
+
command = f"sacct --json -S now-{hist}{hist_unit}"
|
|
191
|
+
|
|
192
|
+
try:
|
|
193
|
+
process = subprocess.Popen(
|
|
194
|
+
[command], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
|
195
|
+
)
|
|
196
|
+
output = process.communicate()
|
|
197
|
+
payload = json.loads(output[0])
|
|
198
|
+
except json.JSONDecodeError:
|
|
199
|
+
# console.print('[orange1 bold]Warning: using example data')
|
|
200
|
+
payload = json.load(
|
|
201
|
+
open(Path(__file__).parent.parent / "example_data" / "sacct.json", "rt")
|
|
202
|
+
)
|
|
247
203
|
|
|
248
204
|
global METADATA
|
|
249
205
|
|
|
250
|
-
METADATA
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
206
|
+
METADATA = {
|
|
207
|
+
"cluster_name": payload["meta"]["slurm"]["cluster"],
|
|
208
|
+
"user": payload["meta"]["client"]["user"],
|
|
209
|
+
"group": payload["meta"]["client"]["group"],
|
|
210
|
+
"hist": hist,
|
|
211
|
+
"hist_unit": hist_unit,
|
|
212
|
+
}
|
|
257
213
|
|
|
258
214
|
# parse payload
|
|
259
215
|
df = DataFrame(payload["jobs"])
|
|
260
216
|
|
|
261
217
|
# filter columns
|
|
262
|
-
|
|
263
|
-
columns = COLUMNS[command]
|
|
218
|
+
columns = COLUMNS["sacct"]
|
|
264
219
|
|
|
265
220
|
try:
|
|
266
221
|
df = df[columns]
|
|
267
|
-
|
|
268
222
|
except KeyError:
|
|
269
|
-
|
|
270
223
|
for key in columns:
|
|
271
224
|
if key not in df.columns:
|
|
272
225
|
raise KeyError(key)
|
|
@@ -280,124 +233,148 @@ def parse_sacct_json(payload: dict) -> "DataFrame":
|
|
|
280
233
|
extract_list(df, "job_state")
|
|
281
234
|
|
|
282
235
|
df = df[df["job_state"] != "RUNNING"]
|
|
236
|
+
df = df[df["job_state"] != "PENDING"]
|
|
283
237
|
|
|
284
238
|
return df
|
|
285
239
|
|
|
286
240
|
|
|
287
|
-
def
|
|
288
|
-
command: str,
|
|
289
|
-
user: None | str = None,
|
|
290
|
-
long: bool = False,
|
|
291
|
-
return_table: bool = False,
|
|
292
|
-
box: bool = False,
|
|
293
|
-
):
|
|
241
|
+
def get_sinfo(**kwargs) -> "pandas.DataFrame":
|
|
294
242
|
|
|
295
|
-
|
|
243
|
+
command = "sinfo -N --json"
|
|
296
244
|
|
|
297
|
-
|
|
298
|
-
|
|
299
|
-
|
|
300
|
-
|
|
301
|
-
output =
|
|
302
|
-
|
|
245
|
+
try:
|
|
246
|
+
process = subprocess.Popen(
|
|
247
|
+
[command], shell=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE
|
|
248
|
+
)
|
|
249
|
+
output = process.communicate()
|
|
250
|
+
payload = json.loads(output[0])
|
|
251
|
+
except json.JSONDecodeError:
|
|
252
|
+
payload = json.load(
|
|
253
|
+
open(Path(__file__).parent.parent / "example_data" / "sinfo_N.json", "rt")
|
|
254
|
+
)
|
|
303
255
|
|
|
304
|
-
|
|
305
|
-
s_command = f"{command} -u {user} --json"
|
|
306
|
-
else:
|
|
307
|
-
s_command = f"{command} --json"
|
|
256
|
+
global METADATA
|
|
308
257
|
|
|
309
|
-
|
|
310
|
-
|
|
258
|
+
METADATA = {
|
|
259
|
+
"cluster_name": payload["meta"]["slurm"]["cluster"],
|
|
260
|
+
"user": payload["meta"]["client"]["user"],
|
|
261
|
+
"group": payload["meta"]["client"]["group"],
|
|
262
|
+
}
|
|
311
263
|
|
|
312
|
-
|
|
264
|
+
df = DataFrame(payload["sinfo"])
|
|
265
|
+
|
|
266
|
+
df.drop(
|
|
267
|
+
columns=[
|
|
268
|
+
"port",
|
|
269
|
+
"weight",
|
|
270
|
+
"disk",
|
|
271
|
+
"sockets",
|
|
272
|
+
"threads",
|
|
273
|
+
"cluster",
|
|
274
|
+
"comment",
|
|
275
|
+
"extra",
|
|
276
|
+
"gres",
|
|
277
|
+
"reason",
|
|
278
|
+
"cores",
|
|
279
|
+
],
|
|
280
|
+
inplace=True,
|
|
281
|
+
)
|
|
313
282
|
|
|
314
|
-
|
|
283
|
+
df["node"] = df.apply(lambda x: x["node"]["state"][0], axis=1)
|
|
284
|
+
df["nodes"] = df.apply(lambda x: x["nodes"]["nodes"][0], axis=1)
|
|
285
|
+
df["cpus_max"] = df.apply(lambda x: x["cpus"]["maximum"], axis=1)
|
|
286
|
+
df["cpus_idle"] = df.apply(lambda x: x["cpus"]["idle"], axis=1)
|
|
287
|
+
df["cpus_allocated"] = df.apply(lambda x: x["cpus"]["allocated"], axis=1)
|
|
288
|
+
df["cpu_string"] = df.apply(lambda x: f"{x.cpus_idle}/{x.cpus_max}", axis=1)
|
|
289
|
+
df["memory_max"] = df.apply(lambda x: x["memory"]["maximum"], axis=1)
|
|
290
|
+
df["memory_free"] = df.apply(
|
|
291
|
+
lambda x: x["memory"]["free"]["maximum"]["number"], axis=1
|
|
292
|
+
)
|
|
293
|
+
df["memory_allocated"] = df.apply(lambda x: x["memory"]["allocated"], axis=1)
|
|
294
|
+
df["features"] = df.apply(lambda x: x["features"]["total"], axis=1)
|
|
295
|
+
df["partition"] = df.apply(lambda x: x["partition"]["name"], axis=1)
|
|
315
296
|
|
|
316
|
-
df =
|
|
297
|
+
df.drop(columns=["cpus", "memory"], inplace=True)
|
|
317
298
|
|
|
318
|
-
|
|
299
|
+
df.rename(columns={"node": "node_state", "nodes": "node_name"}, inplace=True)
|
|
319
300
|
|
|
320
|
-
|
|
321
|
-
title = f"[bold]{user}'s history on {cluster}"
|
|
301
|
+
return df
|
|
322
302
|
|
|
323
|
-
elif user:
|
|
324
|
-
df = df[df["user_name"] == user]
|
|
325
|
-
title = f"[bold]{user}'s jobs on {cluster}"
|
|
326
|
-
else:
|
|
327
|
-
title = f"[bold]jobs on {cluster}"
|
|
328
303
|
|
|
329
|
-
|
|
304
|
+
def combined_df(**kwargs) -> "DataFrame":
|
|
305
|
+
"""Get combined DataFrame of SLURM job information"""
|
|
306
|
+
df1 = get_squeue(**kwargs)
|
|
307
|
+
df2 = get_sacct(**kwargs)
|
|
308
|
+
df = concat([df1, df2], ignore_index=True)
|
|
309
|
+
df["run_time"] = add_run_time(df)
|
|
310
|
+
df = df.sort_values(by="submit_time", ascending=True)
|
|
311
|
+
return df
|
|
330
312
|
|
|
331
|
-
return job_table(
|
|
332
|
-
df,
|
|
333
|
-
title=title,
|
|
334
|
-
long=long,
|
|
335
|
-
force_submit_time=force_submit_time,
|
|
336
|
-
return_table=return_table,
|
|
337
|
-
box=box,
|
|
338
|
-
)
|
|
339
313
|
|
|
314
|
+
### ADD COLUMNS
|
|
340
315
|
|
|
341
|
-
def dual_layout(
|
|
342
|
-
user: None | str = None,
|
|
343
|
-
long: bool = False,
|
|
344
|
-
return_table: bool = True,
|
|
345
|
-
box: bool = False,
|
|
346
|
-
):
|
|
347
316
|
|
|
348
|
-
|
|
317
|
+
def add_run_time(df):
|
|
349
318
|
|
|
350
|
-
|
|
351
|
-
|
|
319
|
+
def inner(row):
|
|
320
|
+
# print(f'{row.end_time=} {type(row.end_time)=}')
|
|
352
321
|
|
|
353
|
-
|
|
354
|
-
|
|
322
|
+
if row.job_state == "PENDING":
|
|
323
|
+
return ""
|
|
355
324
|
|
|
356
|
-
|
|
357
|
-
|
|
325
|
+
if isnull(row.end_time):
|
|
326
|
+
return human_timedelta(datetime.datetime.now() - row.start_time)
|
|
327
|
+
else:
|
|
328
|
+
return human_timedelta(row.end_time - row.start_time)
|
|
358
329
|
|
|
359
|
-
|
|
360
|
-
upper,
|
|
361
|
-
lower,
|
|
362
|
-
)
|
|
330
|
+
return df.apply(inner, axis=1)
|
|
363
331
|
|
|
364
|
-
if not return_table:
|
|
365
|
-
console.print(layout)
|
|
366
|
-
else:
|
|
367
|
-
return layout
|
|
368
332
|
|
|
333
|
+
### EXTRACTORS
|
|
369
334
|
|
|
370
|
-
@app.command()
|
|
371
|
-
def show(user: None | str = None, long: bool = False):
|
|
372
335
|
|
|
373
|
-
|
|
336
|
+
def extract_inner(df, key, inner):
|
|
374
337
|
|
|
375
|
-
|
|
338
|
+
def _inner(x):
|
|
339
|
+
d = x[key]
|
|
340
|
+
if "set" in d:
|
|
341
|
+
if d["set"]:
|
|
342
|
+
return d[inner]
|
|
343
|
+
else:
|
|
344
|
+
return None
|
|
345
|
+
else:
|
|
346
|
+
return d[inner]
|
|
376
347
|
|
|
377
|
-
|
|
378
|
-
import time
|
|
348
|
+
df[key] = df.apply(_inner, axis=1)
|
|
379
349
|
|
|
380
|
-
layout = dual_layout(user=user, long=long)
|
|
381
350
|
|
|
382
|
-
|
|
383
|
-
|
|
351
|
+
def extract_time(df, key):
|
|
352
|
+
df[key] = df.apply(
|
|
353
|
+
lambda x: datetime.datetime.fromtimestamp(x[key]["number"]), axis=1
|
|
354
|
+
)
|
|
384
355
|
|
|
385
|
-
layout = dual_layout(user=user, long=long)
|
|
386
|
-
live.update(layout)
|
|
387
356
|
|
|
388
|
-
|
|
357
|
+
def extract_sacct_times(df):
|
|
358
|
+
df["start_time"] = df.apply(
|
|
359
|
+
lambda x: datetime.datetime.fromtimestamp(x["time"]["start"]), axis=1
|
|
360
|
+
)
|
|
361
|
+
df["end_time"] = df.apply(
|
|
362
|
+
lambda x: datetime.datetime.fromtimestamp(x["time"]["end"]), axis=1
|
|
363
|
+
)
|
|
364
|
+
df["submit_time"] = df.apply(
|
|
365
|
+
lambda x: datetime.datetime.fromtimestamp(x["time"]["submission"]), axis=1
|
|
366
|
+
)
|
|
389
367
|
|
|
390
|
-
else:
|
|
391
|
-
layout = dual_layout(user=user, long=long)
|
|
392
|
-
console.print(layout)
|
|
393
|
-
# show_queue(command="squeue", user=user, long=long)
|
|
394
|
-
# show_queue(command="sacct", user=user, long=long)
|
|
395
368
|
|
|
369
|
+
def extract_list(df, key):
|
|
370
|
+
def inner(x):
|
|
371
|
+
if len(x[key]) == 1:
|
|
372
|
+
return x[key][0]
|
|
373
|
+
else:
|
|
374
|
+
return x[key]
|
|
396
375
|
|
|
397
|
-
|
|
398
|
-
app()
|
|
376
|
+
df[key] = df.apply(inner, axis=1)
|
|
399
377
|
|
|
400
|
-
PARSERS = {"squeue": parse_squeue_json, "sacct": parse_sacct_json}
|
|
401
378
|
|
|
402
379
|
COLUMNS = {
|
|
403
380
|
"sacct": [
|
|
@@ -439,7 +416,3 @@ COLUMNS = {
|
|
|
439
416
|
"current_working_directory",
|
|
440
417
|
],
|
|
441
418
|
}
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
if __name__ == "__main__":
|
|
445
|
-
app()
|
richqueue/table.py
ADDED
|
@@ -0,0 +1,368 @@
|
|
|
1
|
+
from rich.table import Table
|
|
2
|
+
from .tools import human_datetime
|
|
3
|
+
from pandas import isnull
|
|
4
|
+
from .console import console
|
|
5
|
+
|
|
6
|
+
### TABLES
|
|
7
|
+
|
|
8
|
+
|
|
9
|
+
def running_job_table(
|
|
10
|
+
df: "DataFrame",
|
|
11
|
+
long: bool = False,
|
|
12
|
+
limit: int | None = None,
|
|
13
|
+
hide_pending: bool | int = False,
|
|
14
|
+
user: str | None = None,
|
|
15
|
+
**kwargs,
|
|
16
|
+
):
|
|
17
|
+
|
|
18
|
+
if hide_pending:
|
|
19
|
+
pending_df = df[df["job_state"] == "PENDING"]
|
|
20
|
+
df = df[df["job_state"] == "RUNNING"]
|
|
21
|
+
|
|
22
|
+
if limit:
|
|
23
|
+
df = df[-limit:]
|
|
24
|
+
|
|
25
|
+
from .slurm import METADATA
|
|
26
|
+
|
|
27
|
+
if not user:
|
|
28
|
+
title = f"[bold]all running jobs on {METADATA['cluster_name']}"
|
|
29
|
+
else:
|
|
30
|
+
title = f"[bold]{user}'s running jobs on {METADATA['cluster_name']}"
|
|
31
|
+
|
|
32
|
+
table = Table(title=title, box=None, header_style="")
|
|
33
|
+
|
|
34
|
+
columns = RUNNING_JOB_COLUMNS[long]
|
|
35
|
+
|
|
36
|
+
for col in columns:
|
|
37
|
+
col_data = COLUMNS[col]
|
|
38
|
+
table.add_column(**col_data)
|
|
39
|
+
|
|
40
|
+
for i, row in df.iterrows():
|
|
41
|
+
row_values = []
|
|
42
|
+
for col in columns:
|
|
43
|
+
value = row[col]
|
|
44
|
+
formatter = FORMATTERS.get(col, str)
|
|
45
|
+
value = formatter(value)
|
|
46
|
+
row_values.append(value)
|
|
47
|
+
table.add_row(*row_values)
|
|
48
|
+
|
|
49
|
+
if hide_pending:
|
|
50
|
+
row = {
|
|
51
|
+
"job_id": f"(x{hide_pending})",
|
|
52
|
+
"name": "",
|
|
53
|
+
"node_count": f"{int(sum(pending_df['node_count'].values))}",
|
|
54
|
+
"cpus": f"{int(sum(pending_df['cpus'].values))}",
|
|
55
|
+
"submit_time": "",
|
|
56
|
+
"start_time": "",
|
|
57
|
+
"run_time": "",
|
|
58
|
+
"partition": "",
|
|
59
|
+
"nodes": "",
|
|
60
|
+
"job_state": "[bright_yellow bold]Pending",
|
|
61
|
+
}
|
|
62
|
+
row_values = []
|
|
63
|
+
for col in columns:
|
|
64
|
+
value = row[col]
|
|
65
|
+
row_values.append(value)
|
|
66
|
+
table.add_row(*row_values)
|
|
67
|
+
|
|
68
|
+
return table
|
|
69
|
+
|
|
70
|
+
|
|
71
|
+
def history_job_table(
|
|
72
|
+
df: "DataFrame",
|
|
73
|
+
long: bool = False,
|
|
74
|
+
limit: int | None = None,
|
|
75
|
+
user: str | None = None,
|
|
76
|
+
**kwargs,
|
|
77
|
+
):
|
|
78
|
+
|
|
79
|
+
if limit:
|
|
80
|
+
df = df[-limit:]
|
|
81
|
+
|
|
82
|
+
from .slurm import METADATA
|
|
83
|
+
|
|
84
|
+
hist = METADATA["hist"]
|
|
85
|
+
hist_unit = METADATA["hist_unit"]
|
|
86
|
+
if hist == 1:
|
|
87
|
+
hist_unit = hist_unit.removesuffix("s")
|
|
88
|
+
hist_string = f"last {hist_unit}"
|
|
89
|
+
else:
|
|
90
|
+
hist_string = f"last {hist} {hist_unit}"
|
|
91
|
+
|
|
92
|
+
if not user:
|
|
93
|
+
title = f"[bold]all previous jobs on {METADATA['cluster_name']} ({hist_string})"
|
|
94
|
+
else:
|
|
95
|
+
title = f"[bold]{user}'s previous jobs on {METADATA['cluster_name']} ({hist_string})"
|
|
96
|
+
|
|
97
|
+
table = Table(title=title, box=None, header_style="")
|
|
98
|
+
|
|
99
|
+
columns = HISTORY_JOB_COLUMNS[long]
|
|
100
|
+
|
|
101
|
+
for col in columns:
|
|
102
|
+
col_data = COLUMNS[col]
|
|
103
|
+
table.add_column(**col_data)
|
|
104
|
+
|
|
105
|
+
for i, row in df.iterrows():
|
|
106
|
+
row_values = []
|
|
107
|
+
for col in columns:
|
|
108
|
+
value = row[col]
|
|
109
|
+
formatter = FORMATTERS.get(col, str)
|
|
110
|
+
value = formatter(value)
|
|
111
|
+
row_values.append(value)
|
|
112
|
+
table.add_row(*row_values)
|
|
113
|
+
|
|
114
|
+
return table
|
|
115
|
+
|
|
116
|
+
|
|
117
|
+
def node_table(df, long: bool = False, **kwargs):
|
|
118
|
+
|
|
119
|
+
from .slurm import METADATA
|
|
120
|
+
|
|
121
|
+
title = f"[bold]available nodes on {METADATA['cluster_name']}"
|
|
122
|
+
|
|
123
|
+
table = Table(title=title, box=None, header_style="")
|
|
124
|
+
|
|
125
|
+
columns = NODE_COLUMNS[long]
|
|
126
|
+
|
|
127
|
+
df.sort_values(by=["partition", "node_name"], inplace=True)
|
|
128
|
+
|
|
129
|
+
if not df["reservation"].any():
|
|
130
|
+
columns = [c for c in columns if c != "reservation"]
|
|
131
|
+
|
|
132
|
+
for col in columns:
|
|
133
|
+
col_data = COLUMNS[col]
|
|
134
|
+
table.add_column(**col_data)
|
|
135
|
+
|
|
136
|
+
for i, row in df.iterrows():
|
|
137
|
+
row_values = []
|
|
138
|
+
for col in columns:
|
|
139
|
+
value = row[col]
|
|
140
|
+
formatter = FORMATTERS.get(col, str)
|
|
141
|
+
value = formatter(value)
|
|
142
|
+
row_values.append(value)
|
|
143
|
+
table.add_row(*row_values)
|
|
144
|
+
|
|
145
|
+
return table
|
|
146
|
+
|
|
147
|
+
|
|
148
|
+
### FORMATTERS
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
def color_by_state(state):
|
|
152
|
+
|
|
153
|
+
if state == "RUNNING":
|
|
154
|
+
return "[bold bright_green]Running"
|
|
155
|
+
elif state == "IDLE":
|
|
156
|
+
return "[bold bright_green]Idle"
|
|
157
|
+
elif state == "PENDING":
|
|
158
|
+
return "[bright_yellow]Pending"
|
|
159
|
+
elif state == "MIXED":
|
|
160
|
+
return "[bright_yellow]Mixed"
|
|
161
|
+
elif state == "CANCELLED":
|
|
162
|
+
return "[orange3]Cancelled"
|
|
163
|
+
elif state == "FAILED":
|
|
164
|
+
return "[bold bright_red]Failed"
|
|
165
|
+
elif state == "COMPLETED":
|
|
166
|
+
return "[bold bright_green]Completed"
|
|
167
|
+
else:
|
|
168
|
+
return state
|
|
169
|
+
|
|
170
|
+
|
|
171
|
+
def int_if_not_nan(value):
|
|
172
|
+
if isnull(value):
|
|
173
|
+
return ""
|
|
174
|
+
else:
|
|
175
|
+
return str(int(value))
|
|
176
|
+
|
|
177
|
+
|
|
178
|
+
def mem_string(mb):
|
|
179
|
+
return f"{mb/1024:.0f} GB"
|
|
180
|
+
|
|
181
|
+
|
|
182
|
+
### SPECIFICATION
|
|
183
|
+
|
|
184
|
+
RUNNING_JOB_COLUMNS = {
|
|
185
|
+
True: [
|
|
186
|
+
"job_id",
|
|
187
|
+
"name",
|
|
188
|
+
"node_count",
|
|
189
|
+
"cpus",
|
|
190
|
+
"submit_time",
|
|
191
|
+
"start_time",
|
|
192
|
+
"run_time",
|
|
193
|
+
"partition",
|
|
194
|
+
"nodes",
|
|
195
|
+
"job_state",
|
|
196
|
+
],
|
|
197
|
+
False: [
|
|
198
|
+
"job_id",
|
|
199
|
+
"name",
|
|
200
|
+
"node_count",
|
|
201
|
+
"cpus",
|
|
202
|
+
"start_time",
|
|
203
|
+
"run_time",
|
|
204
|
+
"job_state",
|
|
205
|
+
],
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
HISTORY_JOB_COLUMNS = {
|
|
209
|
+
True: [
|
|
210
|
+
"job_id",
|
|
211
|
+
"name",
|
|
212
|
+
# "node_count",
|
|
213
|
+
# "cpus",
|
|
214
|
+
"submit_time",
|
|
215
|
+
"start_time",
|
|
216
|
+
"run_time",
|
|
217
|
+
"partition",
|
|
218
|
+
"nodes",
|
|
219
|
+
"job_state",
|
|
220
|
+
],
|
|
221
|
+
False: [
|
|
222
|
+
"job_id",
|
|
223
|
+
"name",
|
|
224
|
+
# "node_count",
|
|
225
|
+
# "cpus",
|
|
226
|
+
"start_time",
|
|
227
|
+
"run_time",
|
|
228
|
+
"job_state",
|
|
229
|
+
],
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
NODE_COLUMNS = {
|
|
233
|
+
True: [
|
|
234
|
+
"node_state",
|
|
235
|
+
"node_name",
|
|
236
|
+
"partition",
|
|
237
|
+
# "cpu_string",
|
|
238
|
+
# "cpus_max",
|
|
239
|
+
"cpus_idle",
|
|
240
|
+
# "memory_max",
|
|
241
|
+
"memory_free",
|
|
242
|
+
# "memory_allocated",
|
|
243
|
+
"features",
|
|
244
|
+
"reservation",
|
|
245
|
+
],
|
|
246
|
+
False: [
|
|
247
|
+
"node_state",
|
|
248
|
+
"node_name",
|
|
249
|
+
"partition",
|
|
250
|
+
# "cpu_string",
|
|
251
|
+
# "cpus_max",
|
|
252
|
+
"cpus_idle",
|
|
253
|
+
# "memory_max",
|
|
254
|
+
"memory_free",
|
|
255
|
+
# "memory_allocated",
|
|
256
|
+
"features",
|
|
257
|
+
"reservation",
|
|
258
|
+
],
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
COLUMNS = {
|
|
262
|
+
"job_id": {
|
|
263
|
+
"header": "[bold underline]Job Id",
|
|
264
|
+
"justify": "right",
|
|
265
|
+
"style": "bold",
|
|
266
|
+
"no_wrap": True,
|
|
267
|
+
},
|
|
268
|
+
"name": {
|
|
269
|
+
"header": "[underline cyan]Job Name",
|
|
270
|
+
"justify": "left",
|
|
271
|
+
"style": "cyan",
|
|
272
|
+
"no_wrap": False,
|
|
273
|
+
},
|
|
274
|
+
"node_count": {
|
|
275
|
+
"header": "[underline magenta]#N",
|
|
276
|
+
"justify": "right",
|
|
277
|
+
"style": "magenta",
|
|
278
|
+
"no_wrap": True,
|
|
279
|
+
},
|
|
280
|
+
"cpus": {
|
|
281
|
+
"header": "[underline magenta]#C",
|
|
282
|
+
"justify": "right",
|
|
283
|
+
"style": "magenta",
|
|
284
|
+
"no_wrap": True,
|
|
285
|
+
},
|
|
286
|
+
"job_state": {
|
|
287
|
+
"header": "[bold underline]State",
|
|
288
|
+
"justify": "left",
|
|
289
|
+
"style": None,
|
|
290
|
+
"no_wrap": True,
|
|
291
|
+
},
|
|
292
|
+
"submit_time": {
|
|
293
|
+
"header": "[underline dodger_blue2]Submitted",
|
|
294
|
+
"justify": "right",
|
|
295
|
+
"style": "dodger_blue2",
|
|
296
|
+
"no_wrap": True,
|
|
297
|
+
},
|
|
298
|
+
"start_time": {
|
|
299
|
+
"header": "[underline dodger_blue2]Started",
|
|
300
|
+
"justify": "right",
|
|
301
|
+
"style": "dodger_blue2",
|
|
302
|
+
"no_wrap": True,
|
|
303
|
+
},
|
|
304
|
+
"run_time": {
|
|
305
|
+
"header": "[underline dodger_blue2]Run Time",
|
|
306
|
+
"justify": "right",
|
|
307
|
+
"style": "dodger_blue2",
|
|
308
|
+
"no_wrap": True,
|
|
309
|
+
},
|
|
310
|
+
"partition": {
|
|
311
|
+
"header": "[underline green_yellow]Partition",
|
|
312
|
+
"justify": "right",
|
|
313
|
+
"style": "green_yellow",
|
|
314
|
+
"no_wrap": True,
|
|
315
|
+
},
|
|
316
|
+
"features": {
|
|
317
|
+
"header": "[underline cyan]Features",
|
|
318
|
+
"justify": "left",
|
|
319
|
+
"style": "cyan",
|
|
320
|
+
"no_wrap": False,
|
|
321
|
+
},
|
|
322
|
+
"reservation": {
|
|
323
|
+
"header": "[underline cyan]Reservation",
|
|
324
|
+
"justify": "left",
|
|
325
|
+
"style": "cyan",
|
|
326
|
+
"no_wrap": True,
|
|
327
|
+
},
|
|
328
|
+
"nodes": {
|
|
329
|
+
"header": "[underline green_yellow]Nodes",
|
|
330
|
+
"justify": "left",
|
|
331
|
+
"style": "green_yellow",
|
|
332
|
+
"no_wrap": False,
|
|
333
|
+
},
|
|
334
|
+
"node_state": {
|
|
335
|
+
"header": "[bold underline]State",
|
|
336
|
+
"justify": "left",
|
|
337
|
+
"style": None,
|
|
338
|
+
"no_wrap": True,
|
|
339
|
+
},
|
|
340
|
+
"node_name": {
|
|
341
|
+
"header": "[underline cyan]Node Name",
|
|
342
|
+
"justify": "left",
|
|
343
|
+
"style": "cyan",
|
|
344
|
+
"no_wrap": False,
|
|
345
|
+
},
|
|
346
|
+
"cpus_idle": {
|
|
347
|
+
"header": "[underline dodger_blue2]Idle #C",
|
|
348
|
+
"justify": "right",
|
|
349
|
+
"style": "dodger_blue2",
|
|
350
|
+
"no_wrap": True,
|
|
351
|
+
},
|
|
352
|
+
"memory_free": {
|
|
353
|
+
"header": "[underline magenta]RAM Free",
|
|
354
|
+
"justify": "right",
|
|
355
|
+
"style": "magenta",
|
|
356
|
+
"no_wrap": True,
|
|
357
|
+
},
|
|
358
|
+
}
|
|
359
|
+
|
|
360
|
+
FORMATTERS = {
|
|
361
|
+
"node_count": int_if_not_nan,
|
|
362
|
+
"cpus": int_if_not_nan,
|
|
363
|
+
"job_state": color_by_state,
|
|
364
|
+
"node_state": color_by_state,
|
|
365
|
+
"submit_time": human_datetime,
|
|
366
|
+
"start_time": human_datetime,
|
|
367
|
+
"memory_free": mem_string,
|
|
368
|
+
}
|
richqueue/tools.py
CHANGED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
Metadata-Version: 2.3
|
|
2
|
+
Name: richqueue
|
|
3
|
+
Version: 0.7
|
|
4
|
+
Summary: RichQueue
|
|
5
|
+
Project-URL: Homepage, https://github.com/mwinokan/RichQueue/issues
|
|
6
|
+
Project-URL: Bug Tracker, https://github.com/mwinokan/RichQueue/issues
|
|
7
|
+
Author-email: Max Winokan <max@winokan.com>
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Requires-Python: >=3.10
|
|
13
|
+
Requires-Dist: pandas
|
|
14
|
+
Requires-Dist: rich
|
|
15
|
+
Requires-Dist: typer
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
# RichQueue
|
|
19
|
+
|
|
20
|
+
> 💰 RichQueue: A colourful and pythonic SLURM queue viewer
|
|
21
|
+
|
|
22
|
+
Installation from a modern python environment (>3.10) should be as simple as:
|
|
23
|
+
|
|
24
|
+
```shell
|
|
25
|
+
|
|
26
|
+
pip install --upgrade richqueue
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
To see your live-updating SLURM queue:
|
|
30
|
+
|
|
31
|
+
```shell
|
|
32
|
+
rq
|
|
33
|
+
```
|
|
34
|
+
|
|
35
|
+

|
|
36
|
+
|
|
37
|
+
## Other options
|
|
38
|
+
|
|
39
|
+
To see more detail:
|
|
40
|
+
|
|
41
|
+
```rq --long```
|
|
42
|
+
|
|
43
|
+
To see someone else's queue:
|
|
44
|
+
|
|
45
|
+
```rq --user USER```
|
|
46
|
+
|
|
47
|
+
To see the last `X` weeks history:
|
|
48
|
+
|
|
49
|
+
```rq --hist X```
|
|
50
|
+
|
|
51
|
+
To list available nodes on the cluster:
|
|
52
|
+
|
|
53
|
+
```rq --idle```
|
|
54
|
+
|
|
55
|
+
To show a static view:
|
|
56
|
+
|
|
57
|
+
```rq --no-loop```
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
richqueue/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
+
richqueue/console.py,sha256=UpMqeJ0C8i0pkue1AHnnyyX0bFJ9zZeJ7HBR6yhuA8A,54
|
|
3
|
+
richqueue/layout.py,sha256=qD3RRNvKYQSCDZpWLRvP6eGDxIu96b5hBn1Vx-V50WM,602
|
|
4
|
+
richqueue/main.py,sha256=jiXg2CwH6xmJhLNbK47hUBSFW2lPC3deXAEs7KjlEWE,1917
|
|
5
|
+
richqueue/slurm.py,sha256=q_gmqY1zfL24u3ElsPeXH5aKN1P7kC2GU8UWcusbcJ4,10551
|
|
6
|
+
richqueue/table.py,sha256=pJ29lSUchiFHxfpLwz7b6FpSMcOsahUTSNZzBZ1Fees,8567
|
|
7
|
+
richqueue/tools.py,sha256=64sd7IOd8uYSVAqMP-UOBZLiyh22LGMP-RAr-OrIA8o,965
|
|
8
|
+
richqueue-0.7.dist-info/METADATA,sha256=O-oLQn2PtedlfK7a4zidx1GuzDJsMzd_Cqlgqdky-5Q,1171
|
|
9
|
+
richqueue-0.7.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
10
|
+
richqueue-0.7.dist-info/entry_points.txt,sha256=cm1tyoTGLAm9f_QYm0ieGnY82HE4IFiKD1KjlXRgFkU,44
|
|
11
|
+
richqueue-0.7.dist-info/licenses/LICENSE,sha256=IeuPfRcqKv1nyCnVVwJaO9Uratg-K2dnkuOROLgQ4qw,1068
|
|
12
|
+
richqueue-0.7.dist-info/RECORD,,
|
richqueue-0.5.dist-info/METADATA
DELETED
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
Metadata-Version: 2.3
|
|
2
|
-
Name: richqueue
|
|
3
|
-
Version: 0.5
|
|
4
|
-
Summary: RichQueue
|
|
5
|
-
Project-URL: Homepage, https://github.com/mwinokan/RichQueue/issues
|
|
6
|
-
Project-URL: Bug Tracker, https://github.com/mwinokan/RichQueue/issues
|
|
7
|
-
Author-email: Max Winokan <max@winokan.com>
|
|
8
|
-
License-File: LICENSE
|
|
9
|
-
Classifier: License :: OSI Approved :: MIT License
|
|
10
|
-
Classifier: Operating System :: OS Independent
|
|
11
|
-
Classifier: Programming Language :: Python :: 3
|
|
12
|
-
Requires-Python: >=3.10
|
|
13
|
-
Requires-Dist: pandas
|
|
14
|
-
Requires-Dist: rich
|
|
15
|
-
Requires-Dist: typer
|
|
16
|
-
Description-Content-Type: text/markdown
|
|
17
|
-
|
|
18
|
-
# RichQueue
|
|
19
|
-
💰 RichQueue: A colourful and pythonic SLURM queue viewer
|
richqueue-0.5.dist-info/RECORD
DELETED
|
@@ -1,8 +0,0 @@
|
|
|
1
|
-
richqueue/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
|
|
2
|
-
richqueue/slurm.py,sha256=b_kBN8YN_3hwFq0VVYrTDGu5qSnAbye4ea5HUr_Se58,10083
|
|
3
|
-
richqueue/tools.py,sha256=n2MOQWgBykaY3wnhJYqvHsJDKavnyJWx8Pq1SkSTiPU,841
|
|
4
|
-
richqueue-0.5.dist-info/METADATA,sha256=0rHbasbRZy1EoyhUDDRgmXklSUnDBRhaJrWvL3Rq0ZA,621
|
|
5
|
-
richqueue-0.5.dist-info/WHEEL,sha256=1yFddiXMmvYK7QYTqtRNtX66WJ0Mz8PYEiEUoOUUxRY,87
|
|
6
|
-
richqueue-0.5.dist-info/entry_points.txt,sha256=cm1tyoTGLAm9f_QYm0ieGnY82HE4IFiKD1KjlXRgFkU,44
|
|
7
|
-
richqueue-0.5.dist-info/licenses/LICENSE,sha256=IeuPfRcqKv1nyCnVVwJaO9Uratg-K2dnkuOROLgQ4qw,1068
|
|
8
|
-
richqueue-0.5.dist-info/RECORD,,
|
|
File without changes
|
|
File without changes
|
|
File without changes
|