philippds commited on
Commit
61cc380
·
verified ·
1 Parent(s): ebb3370

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -15
app.py CHANGED
@@ -260,19 +260,6 @@ def get_difficulty_pattern_ids_and_key(rl_env, path):
260
  difficulty_pattern_ids = []
261
 
262
  return key, difficulty_pattern_ids
263
-
264
- def filter_data(rl_env, task_id, selected_values, path):
265
- """
266
- Filters the data based on the selected difficulty/pattern values.
267
- """
268
- data = get_data(rl_env, task_id, path)
269
-
270
- # If there are selected values, filter the DataFrame
271
- if selected_values:
272
- filter_column = "Pattern" if "Pattern" in data.columns else "Difficulty"
273
- data = data[data[filter_column].isin(selected_values)]
274
-
275
- return data
276
 
277
 
278
  run_update_dataset()
@@ -280,6 +267,7 @@ run_update_dataset()
280
  block = gr.Blocks(css=custom_css) # Attach the custom CSS here
281
  with block:
282
  with gr.Row(elem_id="header-row"):
 
283
  gr.HTML(
284
  """
285
  <div style="width: 50%; margin: 0 auto; text-align: center;">
@@ -303,6 +291,24 @@ with block:
303
 
304
  path_ = download_leaderboard_dataset()
305
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
306
  # ENVIRONMENT TABS
307
  with gr.Tabs() as tabs:
308
  for env_index in range(0, len(hivex_envs)):
@@ -335,10 +341,15 @@ with block:
335
  row_count=(row_count, "fixed"),
336
  )
337
 
 
 
 
 
 
338
  # Add a callback to update the DataFrame when checkboxes are changed
339
  selected_checkboxes.change(
340
  fn=update_filtered_data,
341
- inputs=[selected_checkboxes, gr.Textbox(hivex_env["hivex_env"]), gr.Number(task_id), gr.Textbox(path_)],
342
  outputs=gr_dataframe,
343
  )
344
  else:
@@ -348,4 +359,4 @@ scheduler = BackgroundScheduler()
348
  scheduler.add_job(restart, "interval", seconds=86400)
349
  scheduler.start()
350
 
351
- block.launch()
 
260
  difficulty_pattern_ids = []
261
 
262
  return key, difficulty_pattern_ids
 
 
 
 
 
 
 
 
 
 
 
 
 
263
 
264
 
265
  run_update_dataset()
 
267
  block = gr.Blocks(css=custom_css) # Attach the custom CSS here
268
  with block:
269
  with gr.Row(elem_id="header-row"):
270
+ # TITLE IMAGE
271
  gr.HTML(
272
  """
273
  <div style="width: 50%; margin: 0 auto; text-align: center;">
 
291
 
292
  path_ = download_leaderboard_dataset()
293
 
294
+ def filter_data(rl_env, task_id, selected_values, path):
295
+ """
296
+ Filters the data based on the selected difficulty/pattern values.
297
+ """
298
+ data = get_data(rl_env, task_id, path)
299
+
300
+ # If there are selected values, filter the DataFrame
301
+ if selected_values:
302
+ filter_column = "Pattern" if "Pattern" in data.columns else "Difficulty"
303
+ if filter_column in data.columns:
304
+ data = data[data[filter_column].isin(selected_values)]
305
+
306
+ return data
307
+
308
+ def update_filtered_data(selected_values, rl_env, task_id, path):
309
+ filtered_data = filter_data(rl_env, task_id, selected_values, path)
310
+ return filtered_data
311
+
312
  # ENVIRONMENT TABS
313
  with gr.Tabs() as tabs:
314
  for env_index in range(0, len(hivex_envs)):
 
341
  row_count=(row_count, "fixed"),
342
  )
343
 
344
+ # Use gr.State to hold environment and task information
345
+ rl_env_state = gr.State(value=hivex_env["hivex_env"])
346
+ task_id_state = gr.State(value=task_id)
347
+ path_state = gr.State(value=path_)
348
+
349
  # Add a callback to update the DataFrame when checkboxes are changed
350
  selected_checkboxes.change(
351
  fn=update_filtered_data,
352
+ inputs=[selected_checkboxes, rl_env_state, task_id_state, path_state],
353
  outputs=gr_dataframe,
354
  )
355
  else:
 
359
  scheduler.add_job(restart, "interval", seconds=86400)
360
  scheduler.start()
361
 
362
+ block.launch()