richqueue 1.1__tar.gz → 1.3__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.1
3
+ Version: 1.3
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.1"
6
+ version = "1.3"
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,67 @@ 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
+ max_rows = console_height - 2 * PANEL_PADDING
51
+
52
+ if n_rows > max_rows:
50
53
 
51
- # hide pending?
52
- elif n_rows - n_pending < max_rows:
53
- # running_df = running_df[running_df["job_state"]=="RUNNING"]
54
+ # hide history?
55
+ if n_running + n_pending + PANEL_PADDING + 1 < console_height:
56
+ history_limit = 0
57
+ running_limit = None
58
+
59
+ # hide pending?
60
+ elif n_rows - n_pending < max_rows:
61
+ # running_df = running_df[running_df["job_state"]=="RUNNING"]
62
+ running_limit = None
63
+ history_limit = None
64
+ hide_pending = n_pending
65
+
66
+ # fallback clip
67
+ else:
68
+ running_limit = 5
69
+ history_limit = 5
70
+
71
+ else:
54
72
  running_limit = None
55
73
  history_limit = None
56
- hide_pending = n_pending
57
74
 
58
- # fallback clip
59
- else:
60
- running_limit = 5
61
- history_limit = 5
75
+ running = Panel(
76
+ running_job_table(
77
+ running_df,
78
+ limit=running_limit,
79
+ hide_pending=hide_pending,
80
+ user=user,
81
+ **kwargs,
82
+ ),
83
+ expand=False,
84
+ )
62
85
 
63
86
  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
- )
87
+
88
+ history_limit = console_height - PANEL_PADDING - 3
89
+ running = Panel(Text("No active jobs", style="bold"), expand=False)
77
90
 
78
91
  if history_limit == 0:
79
- history = Text("history hidden, resize window or use --hist")
92
+ history = Panel(Text("history hidden, resize window or use smaller --hist value", style="bold"), expand=False)
80
93
  else:
81
94
  history = Panel(
82
95
  history_job_table(history_df, limit=history_limit, user=user, **kwargs),
@@ -177,6 +190,9 @@ def get_squeue(
177
190
  # filter columns
178
191
  columns = COLUMNS["squeue"]
179
192
 
193
+ if not len(df):
194
+ return DataFrame(columns=columns)
195
+
180
196
  try:
181
197
  df = df[columns]
182
198
  except KeyError:
@@ -342,7 +358,16 @@ def combined_df(**kwargs) -> "DataFrame":
342
358
  """Get combined DataFrame of SLURM job information"""
343
359
  df1 = get_squeue(**kwargs)
344
360
  df2 = get_sacct(**kwargs)
345
- df = concat([df1, df2], ignore_index=True)
361
+
362
+ if len(df1) and len(df2):
363
+ df = concat([df1, df2], ignore_index=True)
364
+ elif len(df1):
365
+ df = df1
366
+ elif len(df2):
367
+ df = df2
368
+ else:
369
+ return None
370
+
346
371
  df["run_time"] = add_run_time(df)
347
372
  df = df.sort_values(by="submit_time", ascending=True)
348
373
  return df
@@ -332,5 +332,8 @@ QUOTES = [
332
332
  "THE WORLD IS YOUR HOSTAGE", #
333
333
  ]
334
334
 
335
+ def main():
336
+ app()
337
+
335
338
  if __name__ == "__main__":
336
339
  app()
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes