richqueue 1.2__tar.gz → 1.4__tar.gz

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.
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.3
2
2
  Name: richqueue
3
- Version: 1.2
3
+ Version: 1.4
4
4
  Summary: RichQueue
5
5
  Project-URL: Homepage, https://github.com/mwinokan/RichQueue/issues
6
6
  Project-URL: Bug Tracker, https://github.com/mwinokan/RichQueue/issues
@@ -3,7 +3,7 @@ requires = ["hatchling"]
3
3
  build-backend = "hatchling.build"
4
4
  [project]
5
5
  name = "richqueue"
6
- version = "1.2"
6
+ version = "1.4"
7
7
  authors = [
8
8
  { name = "Max Winokan", email = "max@winokan.com" },
9
9
  ]
@@ -13,8 +13,15 @@ def dual_layout(function, **kwargs):
13
13
  upper = Layout(renderable=upper, name="upper")
14
14
  lower = Layout(renderable=lower, name="lower")
15
15
 
16
- upper.size = upper.renderable.renderable.row_count + PANEL_PADDING
17
- lower.size = lower.renderable.renderable.row_count + PANEL_PADDING
16
+ try:
17
+ upper.size = upper.renderable.renderable.row_count + PANEL_PADDING
18
+ except AttributeError:
19
+ upper.size = 3 # + PANEL_PADDING
20
+
21
+ try:
22
+ lower.size = lower.renderable.renderable.row_count + PANEL_PADDING
23
+ except AttributeError:
24
+ lower.size = 3 # + PANEL_PADDING
18
25
 
19
26
  layout.split_column(
20
27
  upper,
@@ -29,54 +29,75 @@ def get_layout_pair(user: str | None, **kwargs):
29
29
 
30
30
  df = combined_df(user=user, **kwargs)
31
31
 
32
+ # if df is None:
33
+ # running = Panel(Text("[bold]No active jobs"), expand=False)
34
+ # else:
35
+
32
36
  n_rows = len(df)
33
37
  n_running = len(df[df["job_state"] == "RUNNING"])
34
38
  n_pending = len(df[df["job_state"] == "PENDING"])
35
39
 
36
40
  hide_pending = False
37
41
 
38
- running_df = df[df["job_state"].isin(["RUNNING", "PENDING"])]
42
+ console_height = console.size.height
43
+
39
44
  history_df = df[~df["job_state"].isin(["RUNNING", "PENDING"])]
40
45
 
41
- console_height = console.size.height
42
- max_rows = console_height - 2 * PANEL_PADDING
46
+ if n_running + n_pending > 0:
43
47
 
44
- if n_rows > max_rows:
48
+ running_df = df[df["job_state"].isin(["RUNNING", "PENDING"])]
45
49
 
46
- # hide history?
47
- if n_running + n_pending + PANEL_PADDING + 1 < console_height:
48
- history_limit = 0
49
- running_limit = None
50
+ active_height = n_running + n_pending + PANEL_PADDING
51
+
52
+ max_rows = console_height - 2 * PANEL_PADDING
53
+
54
+ if n_rows > max_rows:
50
55
 
51
- # hide pending?
52
- elif n_rows - n_pending < max_rows:
53
- # running_df = running_df[running_df["job_state"]=="RUNNING"]
56
+ # hide history?
57
+ if active_height < console_height - PANEL_PADDING:
58
+ history_limit = max(0, console_height - PANEL_PADDING - active_height)
59
+ running_limit = None
60
+
61
+ # hide pending?
62
+ elif n_rows - n_pending < max_rows:
63
+ # running_df = running_df[running_df["job_state"]=="RUNNING"]
64
+ running_limit = None
65
+ history_limit = None
66
+ hide_pending = n_pending
67
+
68
+ # fallback clip
69
+ else:
70
+ running_limit = 5
71
+ history_limit = 5
72
+
73
+ else:
54
74
  running_limit = None
55
75
  history_limit = None
56
- hide_pending = n_pending
57
76
 
58
- # fallback clip
59
- else:
60
- running_limit = 5
61
- history_limit = 5
77
+ running = Panel(
78
+ running_job_table(
79
+ running_df,
80
+ limit=running_limit,
81
+ hide_pending=hide_pending,
82
+ user=user,
83
+ **kwargs,
84
+ ),
85
+ expand=False,
86
+ )
62
87
 
63
88
  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,
76
- )
89
+
90
+ history_limit = console_height - PANEL_PADDING - 3
91
+ running = Panel(Text("No active jobs", style="bold"), expand=False)
77
92
 
78
93
  if history_limit == 0:
79
- history = Text("history hidden, resize window or use --hist")
94
+ history = Panel(
95
+ Text(
96
+ "history hidden, resize window or use smaller --hist value",
97
+ style="bold",
98
+ ),
99
+ expand=False,
100
+ )
80
101
  else:
81
102
  history = Panel(
82
103
  history_job_table(history_df, limit=history_limit, user=user, **kwargs),
@@ -177,6 +198,9 @@ def get_squeue(
177
198
  # filter columns
178
199
  columns = COLUMNS["squeue"]
179
200
 
201
+ if not len(df):
202
+ return DataFrame(columns=columns)
203
+
180
204
  try:
181
205
  df = df[columns]
182
206
  except KeyError:
@@ -342,7 +366,16 @@ def combined_df(**kwargs) -> "DataFrame":
342
366
  """Get combined DataFrame of SLURM job information"""
343
367
  df1 = get_squeue(**kwargs)
344
368
  df2 = get_sacct(**kwargs)
345
- df = concat([df1, df2], ignore_index=True)
369
+
370
+ if len(df1) and len(df2):
371
+ df = concat([df1, df2], ignore_index=True)
372
+ elif len(df1):
373
+ df = df1
374
+ elif len(df2):
375
+ df = df2
376
+ else:
377
+ return None
378
+
346
379
  df["run_time"] = add_run_time(df)
347
380
  df = df.sort_values(by="submit_time", ascending=True)
348
381
  return df
@@ -213,6 +213,8 @@ def color_by_state(state):
213
213
  return "[bright_yellow]Pending"
214
214
  elif state == "MIXED":
215
215
  return "[bright_yellow]Mixed"
216
+ elif state == "TIMEOUT":
217
+ return "[bold bright_yellow]Timed Out"
216
218
  elif state == "CANCELLED":
217
219
  return "[orange3]Cancelled"
218
220
  elif state == "FAILED":
@@ -332,8 +332,10 @@ QUOTES = [
332
332
  "THE WORLD IS YOUR HOSTAGE", #
333
333
  ]
334
334
 
335
+
335
336
  def main():
336
- app()
337
+ app()
338
+
337
339
 
338
340
  if __name__ == "__main__":
339
341
  app()
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes