philippds commited on
Commit
83a14ab
·
verified ·
1 Parent(s): e833533

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +27 -10
app.py CHANGED
@@ -110,7 +110,8 @@ def update_leaderboard_dataset_parallel(hivex_env, path):
110
  row["User"] = user_id
111
  row["Model"] = model_id
112
  results = meta["model-index"][0]["results"][0]
113
- row["Task"] = results["task"]["task-id"]
 
114
 
115
  results_metrics = results["metrics"]
116
 
@@ -148,19 +149,19 @@ def run_update_dataset():
148
  )
149
 
150
 
151
- def get_data(rl_env, task, path) -> pd.DataFrame:
152
  """
153
- Get data from rl_env, filter by the given task, and drop the Task column.
154
- :return: filtered data as a pandas DataFrame without the Task column
155
  """
156
  csv_path = path + "/" + rl_env + ".csv"
157
  data = pd.read_csv(csv_path)
158
 
159
- # Filter the data to only include rows where the "Task" column matches the given task
160
- filtered_data = data[data["Task"] == task]
161
 
162
- # Drop the "Task" column
163
- filtered_data = filtered_data.drop(columns=["Task"])
164
 
165
  # Convert User and Model columns to clickable links
166
  for index, row in filtered_data.iterrows():
@@ -171,6 +172,23 @@ def get_data(rl_env, task, path) -> pd.DataFrame:
171
 
172
  return filtered_data
173
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
174
 
175
  run_update_dataset()
176
 
@@ -204,8 +222,7 @@ with block:
204
  with gr.Tab(hivex_env["title"]) as env_tabs:
205
  # TASK TABS
206
  for j in range(0, hivex_env["task_count"]):
207
- task = "Task " + str(j + 1)
208
- with gr.TabItem(f"Task {j}"):
209
  with gr.Row():
210
  gr_dataframe = gr.components.Dataframe(value=get_data(hivex_env["hivex_env"], j, path_), headers=["User", "Model"], datatype=["markdown", "markdown"], row_count=(100, 'fixed'))
211
 
 
110
  row["User"] = user_id
111
  row["Model"] = model_id
112
  results = meta["model-index"][0]["results"][0]
113
+ row["Task-ID"] = results["task"]["task-id"]
114
+ row["Task"] = results["task"]["name"]
115
 
116
  results_metrics = results["metrics"]
117
 
 
149
  )
150
 
151
 
152
+ def get_data(rl_env, task_id, path) -> pd.DataFrame:
153
  """
154
+ Get data from rl_env, filter by the given task_id, and drop the Task-ID column.
155
+ :return: filtered data as a pandas DataFrame without the Task-ID column
156
  """
157
  csv_path = path + "/" + rl_env + ".csv"
158
  data = pd.read_csv(csv_path)
159
 
160
+ # Filter the data to only include rows where the "Task-ID" column matches the given task_id
161
+ filtered_data = data[data["Task-ID"] == task_id]
162
 
163
+ # Drop the "Task-ID" column
164
+ filtered_data = filtered_data.drop(columns=["Task-ID"])
165
 
166
  # Convert User and Model columns to clickable links
167
  for index, row in filtered_data.iterrows():
 
172
 
173
  return filtered_data
174
 
175
+ def get_task(rl_env, task_id, path) -> str:
176
+ """
177
+ Get the task name from the leaderboard dataset based on the rl_env and task_id.
178
+ :return: The task name as a string
179
+ """
180
+ csv_path = path + "/" + rl_env + ".csv"
181
+ data = pd.read_csv(csv_path)
182
+
183
+ # Filter the data to find the row with the matching task_id
184
+ task_row = data[data["Task-ID"] == task_id]
185
+
186
+ # Check if the task exists and return the task name
187
+ if not task_row.empty:
188
+ task_name = task_row.iloc[0]["Task"]
189
+ return task_name
190
+ else:
191
+ return "Task not found"
192
 
193
  run_update_dataset()
194
 
 
222
  with gr.Tab(hivex_env["title"]) as env_tabs:
223
  # TASK TABS
224
  for j in range(0, hivex_env["task_count"]):
225
+ with gr.TabItem(f"Task {j}: {get_task(hivex_env["hivex_env"], j, path_)}"):
 
226
  with gr.Row():
227
  gr_dataframe = gr.components.Dataframe(value=get_data(hivex_env["hivex_env"], j, path_), headers=["User", "Model"], datatype=["markdown", "markdown"], row_count=(100, 'fixed'))
228