philippds commited on
Commit
4b1f946
·
verified ·
1 Parent(s): a69cd28

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -7
app.py CHANGED
@@ -249,13 +249,21 @@ def get_difficulty_pattern_ids_and_key(rl_env, path):
249
  csv_path = path + "/" + rl_env + ".csv"
250
  data = pd.read_csv(csv_path)
251
 
252
- key = "Pattern" if "Pattern" in data.columns else "Difficulty"
253
- # Get the unique values in the "Difficulty" column
254
- difficulty_pattern_ids = data[key].unique()
 
 
 
 
 
 
 
255
 
256
  return key, difficulty_pattern_ids
257
 
258
 
 
259
  run_update_dataset()
260
 
261
  block = gr.Blocks(css=custom_css) # Attach the custom CSS here
@@ -291,10 +299,10 @@ with block:
291
  hivex_env = hivex_envs[env_index]
292
  with gr.Tab(f"{hivex_env['title']}") as env_tabs:
293
  # ADD CHECK BOX GROUP TO SELECT DIFFICULTY / PATTERN IDs
294
- dp_key, difficulty_pattern_ids = get_difficulty_pattern_ids_and_key(
295
- hivex_env["hivex_env"], path_
296
- )
297
- gr.CheckboxGroup([str(dp_id) for dp_id in difficulty_pattern_ids], label=dp_key)
298
 
299
  # TASK TABS
300
  for task_id in range(0, hivex_env["task_count"]):
 
249
  csv_path = path + "/" + rl_env + ".csv"
250
  data = pd.read_csv(csv_path)
251
 
252
+ if "Pattern" in data.columns:
253
+ key = "Pattern"
254
+ difficulty_pattern_ids = data[key].unique()
255
+ elif "Difficulty" in data.columns:
256
+ key = "Difficulty"
257
+ difficulty_pattern_ids = data[key].unique()
258
+ else:
259
+ # Handle the case where neither 'Pattern' nor 'Difficulty' columns exist
260
+ key = None
261
+ difficulty_pattern_ids = []
262
 
263
  return key, difficulty_pattern_ids
264
 
265
 
266
+
267
  run_update_dataset()
268
 
269
  block = gr.Blocks(css=custom_css) # Attach the custom CSS here
 
299
  hivex_env = hivex_envs[env_index]
300
  with gr.Tab(f"{hivex_env['title']}") as env_tabs:
301
  # ADD CHECK BOX GROUP TO SELECT DIFFICULTY / PATTERN IDs
302
+ if dp_key is not None:
303
+ gr.CheckboxGroup([str(dp_id) for dp_id in difficulty_pattern_ids], label=dp_key)
304
+ else:
305
+ gr.HTML("<p>No difficulty or pattern data available for this environment.</p>")
306
 
307
  # TASK TABS
308
  for task_id in range(0, hivex_env["task_count"]):