textgeflecht commited on
Commit
8a3223a
·
verified ·
1 Parent(s): 51f2901

Update dashboard/app.py

Browse files
Files changed (1) hide show
  1. dashboard/app.py +20 -52
dashboard/app.py CHANGED
@@ -80,66 +80,34 @@ def run(from_results_dir, datasource, port):
80
  # data[metric] = data[metric].apply(lambda x: f"{x:.2f}")
81
  data = data.rename(
82
  columns=column_mappings)
83
-
84
- # This is the raw data with correct dtypes for sorting
85
- raw_data_for_sorting = data.copy()
86
 
87
- # Define columns that should be numeric for sorting and have specific formatting
88
- # These names must match the column names *after* renaming by column_mappings
 
 
89
  numeric_cols_to_ensure = [
90
- 'ITL P90 (ms)', 'TTFT P90 (ms)', 'E2E P90 (ms)',
91
  'Throughput (tokens/s)', 'QPS'
92
  ]
93
 
94
  for col in numeric_cols_to_ensure:
95
- if col in raw_data_for_sorting.columns:
96
- # Convert column to numeric, coercing errors to NaN
97
- # NaN values will be handled by the formatter's try-except or display as "nan"
98
- raw_data_for_sorting[col] = pd.to_numeric(raw_data_for_sorting[col], errors='coerce')
99
- # else:
100
- # Optionally, log a warning if a column expected to be numeric is missing
101
- # print(f"Warning: Column '{col}' not found for numeric conversion in summary_table.")
102
-
103
-
104
- headers = raw_data_for_sorting.columns.tolist()
105
-
106
- # Formatter for display purposes
107
- formatter = {
108
- 'ITL P90 (ms)': "{:.2f}",
109
- 'TTFT P90 (ms)': "{:.2f}",
110
- 'E2E P90 (ms)': "{:.2f}",
111
- 'Throughput (tokens/s)': "{:.2f}",
112
- 'QPS': "{:.0f}"
113
  }
114
 
115
- # Create the display_value array (list of lists)
116
- display_values_list = []
117
- for _, row in raw_data_for_sorting.iterrows():
118
- display_row = []
119
- for col_name in headers:
120
- val = row[col_name]
121
- if col_name in formatter:
122
- try:
123
- display_row.append(formatter[col_name].format(val))
124
- except (ValueError, TypeError): # Fallback for any unexpected non-numeric in formatted columns
125
- display_row.append(str(val))
126
- else:
127
- display_row.append(str(val)) # Default string conversion for other columns
128
- display_values_list.append(display_row)
129
-
130
- # Create a styling array (list of lists for CSS). Empty strings if no specific CSS.
131
- # Corrected the extra parenthesis at the end of this line
132
- styling_array = [["" for _ in headers] for _ in range(len(raw_data_for_sorting))]
133
-
134
- return {
135
- # Convert the DataFrame (with corrected numeric dtypes) to a list of lists for the "data" field
136
- "data": raw_data_for_sorting.values.tolist(),
137
- "headers": headers,
138
- "metadata": {
139
- "display_value": display_values_list,
140
- "styling": styling_array, # Optional: for cell-specific CSS
141
- },
142
- }
143
 
144
  def load_bench_results(source) -> pd.DataFrame:
145
  data = pd.read_parquet(source)
 
80
  # data[metric] = data[metric].apply(lambda x: f"{x:.2f}")
81
  data = data.rename(
82
  columns=column_mappings)
 
 
 
83
 
84
+ # uncomment the following line if you want to return the raw DataFrame without formatting
85
+ # return data
86
+
87
+ # Ensure numeric columns are properly typed for sorting
88
  numeric_cols_to_ensure = [
89
+ 'ITL P90 (ms)', 'TTFT P90 (ms)', 'E2E P90 (ms)',
90
  'Throughput (tokens/s)', 'QPS'
91
  ]
92
 
93
  for col in numeric_cols_to_ensure:
94
+ if col in data.columns:
95
+ data[col] = pd.to_numeric(data[col], errors='coerce')
96
+
97
+ # Round numeric columns to reduce decimal places while maintaining sorting
98
+ rounding_rules = {
99
+ 'ITL P90 (ms)': 2,
100
+ 'TTFT P90 (ms)': 2,
101
+ 'E2E P90 (ms)': 2,
102
+ 'Throughput (tokens/s)': 2,
103
+ 'QPS': 0 # Round to integers
 
 
 
 
 
 
 
 
104
  }
105
 
106
+ for col, decimals in rounding_rules.items():
107
+ if col in data.columns:
108
+ data[col] = data[col].round(decimals)
109
+
110
+ return data
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
111
 
112
  def load_bench_results(source) -> pd.DataFrame:
113
  data = pd.read_parquet(source)