albertvillanova HF staff commited on
Commit
bd858f5
1 Parent(s): eec78c0

Update sample_idx component

Browse files
Files changed (1) hide show
  1. app.py +23 -1
app.py CHANGED
@@ -220,6 +220,18 @@ def display_details(sample_idx, *dfs):
220
  )
221
 
222
 
 
 
 
 
 
 
 
 
 
 
 
 
223
  # if __name__ == "__main__":
224
  latest_result_path_per_model = filter_latest_result_path_per_model(fetch_result_paths())
225
 
@@ -264,8 +276,14 @@ with gr.Blocks(fill_height=True) as demo:
264
  label="Subtasks",
265
  info="Evaluation subtasks to be displayed (choose one of the Tasks above)",
266
  )
267
- sample_idx = gr.Number(value=0, label="Sample Index", info="Index of the sample to be displayed", minimum=0)
268
  load_details_btn = gr.Button("Load Details", interactive=False)
 
 
 
 
 
 
 
269
  details = gr.HTML()
270
  details_dataframe_1 = gr.Dataframe(visible=False)
271
  details_dataframe_2 = gr.Dataframe(visible=False)
@@ -312,6 +330,10 @@ with gr.Blocks(fill_height=True) as demo:
312
  fn=display_details,
313
  inputs=[sample_idx, details_dataframe_1, details_dataframe_2],
314
  outputs=details,
 
 
 
 
315
  )
316
  sample_idx.change(
317
  fn=display_details,
 
220
  )
221
 
222
 
223
+ def update_sample_idx_component(*dfs):
224
+ maximum = max([len(df) - 1 for df in dfs])
225
+ return gr.Number(
226
+ label="Sample Index",
227
+ info="Index of the sample to be displayed",
228
+ value=0,
229
+ minimum=0,
230
+ maximum=maximum,
231
+ visible=True,
232
+ )
233
+
234
+
235
  # if __name__ == "__main__":
236
  latest_result_path_per_model = filter_latest_result_path_per_model(fetch_result_paths())
237
 
 
276
  label="Subtasks",
277
  info="Evaluation subtasks to be displayed (choose one of the Tasks above)",
278
  )
 
279
  load_details_btn = gr.Button("Load Details", interactive=False)
280
+ sample_idx = gr.Number(
281
+ label="Sample Index",
282
+ info="Index of the sample to be displayed",
283
+ value=0,
284
+ minimum=0,
285
+ visible=False
286
+ )
287
  details = gr.HTML()
288
  details_dataframe_1 = gr.Dataframe(visible=False)
289
  details_dataframe_2 = gr.Dataframe(visible=False)
 
330
  fn=display_details,
331
  inputs=[sample_idx, details_dataframe_1, details_dataframe_2],
332
  outputs=details,
333
+ ).then(
334
+ fn=update_sample_idx_component,
335
+ inputs=[details_dataframe_1, details_dataframe_2],
336
+ outputs=sample_idx,
337
  )
338
  sample_idx.change(
339
  fn=display_details,