Jae-Won Chung commited on
Commit
67dda77
1 Parent(s): 1138cdd

Fix table display and defaulting

Browse files
Files changed (1) hide show
  1. app.py +12 -7
app.py CHANGED
@@ -39,10 +39,9 @@ class TableManager:
39
 
40
  # The full table where all the data are.
41
  self.full_df = df
42
- # The currently visible table after filtering.
43
- self.cur_df = df
44
- # The current index of the visible table after filtering.
45
- self.cur_index = df.index.to_numpy()
46
 
47
  def _read_tables(self, data_dir: str) -> pd.DataFrame:
48
  """Read tables."""
@@ -150,7 +149,7 @@ class TableManager:
150
  """Set the current set of filters and return the filtered DataFrame."""
151
  # If the filter is empty, we default to the first choice for each key.
152
  if not filters:
153
- filters = [choices[0] for choices in self.schema.values()]
154
 
155
  index = np.full(len(self.full_df), True)
156
  for setup, choice in zip(self.schema, filters):
@@ -350,7 +349,13 @@ with block:
350
  plot_height_input = gr.Textbox("600", lines=1, label="Height (px)")
351
  with gr.Row():
352
  # By default show a plot of average model quality vs energy consumption.
353
- plot = gr.Plot(global_tbm.plot_scatter("600", "600", "gpu", "nlp_average", "energy")[0])
 
 
 
 
 
 
354
  with gr.Row():
355
  plot_message = gr.HTML("")
356
  add_col_btn.click(TableManager.update_dropdown, inputs=tbm, outputs=axis_dropdowns) # type: ignore
@@ -385,6 +390,6 @@ with block:
385
  gr.Markdown(open("LEADERBOARD.md").read())
386
 
387
  # Load the table on page load.
388
- block.load(TableManager.set_filter_get_df, input=tbm, outputs=dataframe)
389
 
390
  block.launch()
 
39
 
40
  # The full table where all the data are.
41
  self.full_df = df
42
+
43
+ # Default view of the table is to only show the first options.
44
+ self.set_filter_get_df()
 
45
 
46
  def _read_tables(self, data_dir: str) -> pd.DataFrame:
47
  """Read tables."""
 
149
  """Set the current set of filters and return the filtered DataFrame."""
150
  # If the filter is empty, we default to the first choice for each key.
151
  if not filters:
152
+ filters = [choices[:1] for choices in self.schema.values()]
153
 
154
  index = np.full(len(self.full_df), True)
155
  for setup, choice in zip(self.schema, filters):
 
349
  plot_height_input = gr.Textbox("600", lines=1, label="Height (px)")
350
  with gr.Row():
351
  # By default show a plot of average model quality vs energy consumption.
352
+ plot = gr.Plot(global_tbm.plot_scatter(
353
+ width=plot_width_input.value,
354
+ height=plot_height_input.value,
355
+ x=axis_dropdowns[0].value,
356
+ y=axis_dropdowns[1].value,
357
+ z=axis_dropdowns[2].value,
358
+ )[0])
359
  with gr.Row():
360
  plot_message = gr.HTML("")
361
  add_col_btn.click(TableManager.update_dropdown, inputs=tbm, outputs=axis_dropdowns) # type: ignore
 
390
  gr.Markdown(open("LEADERBOARD.md").read())
391
 
392
  # Load the table on page load.
393
+ block.load(lambda: global_tbm.set_filter_get_df(), outputs=dataframe)
394
 
395
  block.launch()