@@ -181,6 +181,10 @@ def export_csv(df):
181
181
return tmp_path
182
182
183
183
184
+ def format_df (df ):
185
+ return df .style .format (precision = 3 , thousands = "," , decimal = "." )
186
+
187
+
184
188
def build_app (df ):
185
189
with gr .Blocks (theme = gr .themes .Soft ()) as demo :
186
190
gr .Markdown ("# PEFT method comparison" )
@@ -202,7 +206,20 @@ def build_app(df):
202
206
label = "Select Model ID" , choices = get_model_ids (sorted (df ["task_name" ].unique ())[0 ], df )
203
207
)
204
208
205
- data_table = gr .DataFrame (label = "Results" , value = df , interactive = False )
209
+ # Make dataframe columns all equal in width so that they are good enough for numbers but don't
210
+ # get hugely extended by columns like `train_config`.
211
+ column_widths = ["150px" for _ in df .columns ]
212
+ column2index = dict (zip (df .columns , range (len (df .columns ))))
213
+ column_widths [column2index ['experiment_name' ]] = '300px'
214
+
215
+ data_table = gr .DataFrame (
216
+ label = "Results" ,
217
+ value = format_df (df ),
218
+ interactive = False ,
219
+ max_chars = 100 ,
220
+ wrap = False ,
221
+ column_widths = column_widths ,
222
+ )
206
223
207
224
with gr .Row ():
208
225
filter_textbox = gr .Textbox (
@@ -256,7 +273,7 @@ def update_on_task(task_name, current_filter):
256
273
except Exception :
257
274
# invalid filter query
258
275
pass
259
- return gr .update (choices = new_models , value = new_models [0 ] if new_models else None ), filtered
276
+ return gr .update (choices = new_models , value = new_models [0 ] if new_models else None ), format_df ( filtered )
260
277
261
278
task_dropdown .change (
262
279
fn = update_on_task , inputs = [task_dropdown , filter_state ], outputs = [model_dropdown , data_table ]
@@ -270,7 +287,7 @@ def update_on_model(task_name, model_id, current_filter):
270
287
filtered = filtered [mask ]
271
288
except Exception :
272
289
pass
273
- return filtered
290
+ return format_df ( filtered )
274
291
275
292
model_dropdown .change (
276
293
fn = update_on_model , inputs = [task_dropdown , model_dropdown , filter_state ], outputs = data_table
@@ -315,7 +332,7 @@ def apply_filter(filter_query, task_name, model_id, metric_x, metric_y):
315
332
pareto_df = compute_pareto_frontier (filtered , metric_x , metric_y )
316
333
fig = generate_pareto_plot (filtered , metric_x , metric_y )
317
334
summary = compute_pareto_summary (filtered , pareto_df , metric_x , metric_y )
318
- return filter_query , filtered , fig , summary
335
+ return filter_query , format_df ( filtered ) , fig , summary
319
336
320
337
apply_filter_button .click (
321
338
fn = apply_filter ,
@@ -329,7 +346,7 @@ def reset_filter(task_name, model_id, metric_x, metric_y):
329
346
fig = generate_pareto_plot (filtered , metric_x , metric_y )
330
347
summary = compute_pareto_summary (filtered , pareto_df , metric_x , metric_y )
331
348
# Return empty strings to clear the filter state and textbox.
332
- return "" , "" , filtered , fig , summary
349
+ return "" , "" , format_df ( filtered ) , fig , summary
333
350
334
351
reset_filter_button .click (
335
352
fn = reset_filter ,
0 commit comments