Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -107,15 +107,15 @@ def get_metadata(model_id):
|
|
107 |
# return mean_reward, std_reward
|
108 |
|
109 |
|
110 |
-
def rank_dataframe(dataframe):
|
111 |
-
|
112 |
-
|
113 |
-
|
114 |
-
|
115 |
-
|
116 |
-
|
117 |
-
|
118 |
-
|
119 |
|
120 |
|
121 |
def update_leaderboard_dataset_parallel(hivex_env, path):
|
@@ -146,8 +146,9 @@ def update_leaderboard_dataset_parallel(hivex_env, path):
|
|
146 |
# Filter out None results (models with no metadata)
|
147 |
data = [row for row in data if row is not None]
|
148 |
|
149 |
-
ranked_dataframe = rank_dataframe(pd.DataFrame.from_records(data))
|
150 |
-
new_history = ranked_dataframe
|
|
|
151 |
file_path = path + "/" + hivex_env + ".csv"
|
152 |
new_history.to_csv(file_path, index=False)
|
153 |
|
@@ -170,8 +171,8 @@ def run_update_dataset():
|
|
170 |
|
171 |
def get_data(rl_env, task, path) -> pd.DataFrame:
|
172 |
"""
|
173 |
-
Get data from rl_env
|
174 |
-
:return: filtered data as a pandas DataFrame
|
175 |
"""
|
176 |
csv_path = path + "/" + rl_env + ".csv"
|
177 |
data = pd.read_csv(csv_path)
|
@@ -179,6 +180,9 @@ def get_data(rl_env, task, path) -> pd.DataFrame:
|
|
179 |
# Filter the data to only include rows where the "Task" column matches the given task
|
180 |
filtered_data = data[data["Task"] == task]
|
181 |
|
|
|
|
|
|
|
182 |
# Convert User and Model columns to clickable links
|
183 |
for index, row in filtered_data.iterrows():
|
184 |
user_id = row["User"]
|
@@ -189,17 +193,6 @@ def get_data(rl_env, task, path) -> pd.DataFrame:
|
|
189 |
return filtered_data
|
190 |
|
191 |
|
192 |
-
def get_data_no_html(rl_env, path) -> pd.DataFrame:
|
193 |
-
"""
|
194 |
-
Get data from rl_env
|
195 |
-
:return: data as a pandas DataFrame
|
196 |
-
"""
|
197 |
-
csv_path = path + "/" + rl_env + ".csv"
|
198 |
-
data = pd.read_csv(csv_path)
|
199 |
-
|
200 |
-
return data
|
201 |
-
|
202 |
-
|
203 |
run_update_dataset()
|
204 |
|
205 |
block = gr.Blocks()
|
@@ -220,8 +213,7 @@ with block:
|
|
220 |
task = "Task " + str(j + 1)
|
221 |
with gr.TabItem(f"Task {j}"):
|
222 |
with gr.Row():
|
223 |
-
|
224 |
-
gr_dataframe = gr.components.Dataframe(value=get_data(hivex_env["hivex_env"], j,path_), headers=["Ranking", "User", "Model"], datatype=["number", "markdown", "markdown"], row_count=(100, 'fixed'))
|
225 |
|
226 |
|
227 |
scheduler = BackgroundScheduler()
|
|
|
107 |
# return mean_reward, std_reward
|
108 |
|
109 |
|
110 |
+
# def rank_dataframe(dataframe):
|
111 |
+
# dataframe = dataframe.sort_values(
|
112 |
+
# by=["Cumulative Reward", "User", "Model"], ascending=False
|
113 |
+
# )
|
114 |
+
# if not "Ranking" in dataframe.columns:
|
115 |
+
# dataframe.insert(0, "Ranking", [i for i in range(1, len(dataframe) + 1)])
|
116 |
+
# else:
|
117 |
+
# dataframe["Ranking"] = [i for i in range(1, len(dataframe) + 1)]
|
118 |
+
# return dataframe
|
119 |
|
120 |
|
121 |
def update_leaderboard_dataset_parallel(hivex_env, path):
|
|
|
146 |
# Filter out None results (models with no metadata)
|
147 |
data = [row for row in data if row is not None]
|
148 |
|
149 |
+
# ranked_dataframe = rank_dataframe(pd.DataFrame.from_records(data))
|
150 |
+
# new_history = ranked_dataframe
|
151 |
+
new_history = pd.DataFrame.from_records(data)
|
152 |
file_path = path + "/" + hivex_env + ".csv"
|
153 |
new_history.to_csv(file_path, index=False)
|
154 |
|
|
|
171 |
|
172 |
def get_data(rl_env, task, path) -> pd.DataFrame:
|
173 |
"""
|
174 |
+
Get data from rl_env, filter by the given task, and drop the Task column.
|
175 |
+
:return: filtered data as a pandas DataFrame without the Task 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" column matches the given task
|
181 |
filtered_data = data[data["Task"] == task]
|
182 |
|
183 |
+
# Drop the "Task" column
|
184 |
+
filtered_data = filtered_data.drop(columns=["Task"])
|
185 |
+
|
186 |
# Convert User and Model columns to clickable links
|
187 |
for index, row in filtered_data.iterrows():
|
188 |
user_id = row["User"]
|
|
|
193 |
return filtered_data
|
194 |
|
195 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
196 |
run_update_dataset()
|
197 |
|
198 |
block = gr.Blocks()
|
|
|
213 |
task = "Task " + str(j + 1)
|
214 |
with gr.TabItem(f"Task {j}"):
|
215 |
with gr.Row():
|
216 |
+
gr_dataframe = gr.components.Dataframe(value=get_data(hivex_env["hivex_env"], j, path_), headers=["User", "Model"], datatype=["markdown", "markdown"], row_count=(100, 'fixed'))
|
|
|
217 |
|
218 |
|
219 |
scheduler = BackgroundScheduler()
|