mohsenfayyaz commited on
Commit
7e0e5a4
·
verified ·
1 Parent(s): eac2f31

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +14 -3
app.py CHANGED
@@ -227,7 +227,7 @@ def plot_disks(alert_threshold_pct=99.0):
227
  return fig, df
228
 
229
 
230
- def plot_users_disks(topk_to_show=5, skip_drives=[""]):
231
  df = datasets.load_dataset(
232
  "pluslab/PLUS_Lab_GPUs_Data",
233
  data_files="users_disks.csv",
@@ -303,7 +303,18 @@ def plot_users_disks(topk_to_show=5, skip_drives=[""]):
303
  # -----------------------------------------------------
304
 
305
  # Text labels inside cells
306
- text_values = heatmap_df.round(1).astype(str)
 
 
 
 
 
 
 
 
 
 
 
307
 
308
  fig = go.Figure(
309
  data=go.Heatmap(
@@ -312,7 +323,7 @@ def plot_users_disks(topk_to_show=5, skip_drives=[""]):
312
  y=heatmap_df.index.tolist(),
313
  text=text_values.values,
314
  texttemplate="%{text}",
315
- textfont={"size": 12},
316
  hovertemplate="path=%{y}<br>user=%{x}<br>size_GB=%{z:.2f}<extra></extra>",
317
  colorscale="YlOrRd",
318
  )
 
227
  return fig, df
228
 
229
 
230
+ def plot_users_disks(topk_to_show=4, skip_drives=[""]):
231
  df = datasets.load_dataset(
232
  "pluslab/PLUS_Lab_GPUs_Data",
233
  data_files="users_disks.csv",
 
303
  # -----------------------------------------------------
304
 
305
  # Text labels inside cells
306
+ # text_values = heatmap_df.round(1).astype(str)
307
+
308
+ # Abbreviate large numbers (e.g., 14135 -> 14.1k)
309
+ def format_label(val):
310
+ if val >= 1000:
311
+ return f"{val / 1000:.1f}T"
312
+ elif val > 0:
313
+ return f"{val:.0f}"
314
+ return "0"
315
+
316
+ # Use .map() for newer pandas, or .applymap() if you are on an older version
317
+ text_values = heatmap_df.map(format_label)
318
 
319
  fig = go.Figure(
320
  data=go.Heatmap(
 
323
  y=heatmap_df.index.tolist(),
324
  text=text_values.values,
325
  texttemplate="%{text}",
326
+ textfont={"size": 11},
327
  hovertemplate="path=%{y}<br>user=%{x}<br>size_GB=%{z:.2f}<extra></extra>",
328
  colorscale="YlOrRd",
329
  )