philippds commited on
Commit
02dd1a2
Β·
verified Β·
1 Parent(s): 841009c

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -34
app.py CHANGED
@@ -168,9 +168,11 @@ def run_update_dataset():
168
  )
169
 
170
 
171
- def get_data(rl_env, task_id, path, selected_filters: List[str] = None) -> pd.DataFrame:
172
  """
173
- Get data from rl_env, filter by the given task_id and selected filters, and drop the Task-ID column.
 
 
174
  """
175
  csv_path = path + "/" + rl_env + ".csv"
176
  data = pd.read_csv(csv_path)
@@ -178,22 +180,16 @@ def get_data(rl_env, task_id, path, selected_filters: List[str] = None) -> pd.Da
178
  # Filter the data to only include rows where the "Task-ID" column matches the given task_id
179
  filtered_data = data[data["Task-ID"] == task_id]
180
 
181
- # Apply selected filters for difficulty or pattern if provided
182
- if selected_filters:
183
- if 'Pattern' in filtered_data.columns and 'Difficulty' in filtered_data.columns:
184
- filtered_data = filtered_data[
185
- filtered_data['Pattern'].isin(selected_filters) | filtered_data['Difficulty'].isin(selected_filters)
186
- ]
187
- elif 'Pattern' in filtered_data.columns:
188
- filtered_data = filtered_data[filtered_data['Pattern'].isin(selected_filters)]
189
- elif 'Difficulty' in filtered_data.columns:
190
- filtered_data = filtered_data[filtered_data['Difficulty'].isin(selected_filters)]
191
-
192
- # Drop the "Task-ID" and "Task" columns
193
- filtered_data = filtered_data.drop(columns=["Task-ID", "Task"])
194
-
195
- # Drop columns that have no data (all values are NaN) or where all values are 0.0
196
  filtered_data = filtered_data.dropna(axis=1, how='all')
 
 
197
  filtered_data = filtered_data.loc[:, (filtered_data != 0.0).any(axis=0)]
198
 
199
  # Convert User and Model columns to clickable links
@@ -258,24 +254,20 @@ with block:
258
  gr.HTML(f"<p style='text-align: center;'>Get started πŸš€ on our <a href='https://github.com/hivex-research/hivex'>GitHub repository</a>!</p>")
259
 
260
  path_ = download_leaderboard_dataset()
 
261
  # ENVIRONMENT TABS
262
- with gr.Tabs() as tabs: # elem_classes="tab-buttons"
263
  for env_index in range(0, len(hivex_envs)):
264
  hivex_env = hivex_envs[env_index]
265
  with gr.Tab(f"{hivex_env['title']}") as env_tabs:
 
 
 
266
  for task_id in range(0, hivex_env["task_count"]):
267
  task_title = convert_to_title_case(get_task(hivex_env["hivex_env"], task_id, path_))
268
  with gr.TabItem(f"Task {task_id}: {task_title}"):
269
  with gr.Row():
270
- # CheckboxGroup for Difficulty/Pattern
271
- selected_filters = gr.CheckboxGroup(
272
- choices=list(pattern_map.values()),
273
- label="Select Difficulty/Pattern",
274
- value=list(pattern_map.values()) # Default to all selected
275
- )
276
-
277
- with gr.Row():
278
- data = get_data(hivex_env["hivex_env"], task_id, path_, selected_filters=selected_filters.value)
279
  row_count = len(data) # Number of rows in the data
280
 
281
  gr_dataframe = gr.components.Dataframe(
@@ -284,13 +276,6 @@ with block:
284
  datatype=["markdown", "markdown"],
285
  row_count=(row_count, 'fixed') # Set to the exact number of rows in the data
286
  )
287
-
288
- # Update data based on checkbox selection
289
- selected_filters.change(
290
- lambda filters: get_data(hivex_env["hivex_env"], task_id, path_, filters),
291
- inputs=[selected_filters],
292
- outputs=[gr_dataframe]
293
- )
294
 
295
 
296
  scheduler = BackgroundScheduler()
 
168
  )
169
 
170
 
171
+ def get_data(rl_env, task_id, path) -> pd.DataFrame:
172
  """
173
+ Get data from rl_env, filter by the given task_id, and drop the Task-ID column.
174
+ Also drops any columns that have no data (all values are NaN) or all values are 0.0.
175
+ :return: filtered data as a pandas DataFrame without the Task-ID column
176
  """
177
  csv_path = path + "/" + rl_env + ".csv"
178
  data = pd.read_csv(csv_path)
 
180
  # Filter the data to only include rows where the "Task-ID" column matches the given task_id
181
  filtered_data = data[data["Task-ID"] == task_id]
182
 
183
+ # Drop the "Task-ID" column
184
+ filtered_data = filtered_data.drop(columns=["Task-ID"])
185
+
186
+ # Drop the "Task" column
187
+ filtered_data = filtered_data.drop(columns=["Task"])
188
+
189
+ # Drop columns that have no data (all values are NaN)
 
 
 
 
 
 
 
 
190
  filtered_data = filtered_data.dropna(axis=1, how='all')
191
+
192
+ # Drop columns where all values are 0.0
193
  filtered_data = filtered_data.loc[:, (filtered_data != 0.0).any(axis=0)]
194
 
195
  # Convert User and Model columns to clickable links
 
254
  gr.HTML(f"<p style='text-align: center;'>Get started πŸš€ on our <a href='https://github.com/hivex-research/hivex'>GitHub repository</a>!</p>")
255
 
256
  path_ = download_leaderboard_dataset()
257
+ # gr.Markdown(INTRODUCTION_TEXT, elem_classes="markdown-text")
258
  # ENVIRONMENT TABS
259
+ with gr.Tabs() as tabs: # elem_classes="tab-buttons"
260
  for env_index in range(0, len(hivex_envs)):
261
  hivex_env = hivex_envs[env_index]
262
  with gr.Tab(f"{hivex_env['title']}") as env_tabs:
263
+ # ADD CHECK BOX GROUP TO SELECT DIFFICULTY / PATTERN IDs
264
+
265
+ # TASK TABS
266
  for task_id in range(0, hivex_env["task_count"]):
267
  task_title = convert_to_title_case(get_task(hivex_env["hivex_env"], task_id, path_))
268
  with gr.TabItem(f"Task {task_id}: {task_title}"):
269
  with gr.Row():
270
+ data = get_data(hivex_env["hivex_env"], task_id, path_)
 
 
 
 
 
 
 
 
271
  row_count = len(data) # Number of rows in the data
272
 
273
  gr_dataframe = gr.components.Dataframe(
 
276
  datatype=["markdown", "markdown"],
277
  row_count=(row_count, 'fixed') # Set to the exact number of rows in the data
278
  )
 
 
 
 
 
 
 
279
 
280
 
281
  scheduler = BackgroundScheduler()