huph22 commited on
Commit
68d9876
·
verified ·
1 Parent(s): 80968a3
Files changed (1) hide show
  1. app.py +15 -20
app.py CHANGED
@@ -116,21 +116,33 @@ def update_leaderboard_dataset_parallel(rl_env, path):
116
  return row
117
 
118
  data = list(thread_map(process_model, model_ids, desc="Processing models"))
119
-
120
  # Filter out None results (models with no metadata)
121
  data = [row for row in data if row is not None]
122
-
123
  ranked_dataframe = rank_dataframe(pd.DataFrame.from_records(data))
124
  new_history = ranked_dataframe
125
  file_path = path + "/" + rl_env + ".csv"
126
  new_history.to_csv(file_path, index=False)
127
-
128
  return ranked_dataframe
129
 
130
  def download_leaderboard_dataset():
131
  path = snapshot_download(repo_id=DATASET_REPO_ID, repo_type="dataset")
132
  return path
133
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
134
  def get_data(rl_env, path) -> pd.DataFrame:
135
  """
136
  Get data from rl_env
@@ -144,7 +156,6 @@ def get_data(rl_env, path) -> pd.DataFrame:
144
  data.loc[index, "User"] = make_clickable_user(user_id)
145
  model_id = row["Model"]
146
  data.loc[index, "Model"] = make_clickable_model(model_id)
147
-
148
  return data
149
 
150
  def get_data_no_html(rl_env, path) -> pd.DataFrame:
@@ -154,7 +165,6 @@ def get_data_no_html(rl_env, path) -> pd.DataFrame:
154
  """
155
  csv_path = path + "/" + rl_env + ".csv"
156
  data = pd.read_csv(csv_path)
157
-
158
  return data
159
 
160
  def rank_dataframe(dataframe):
@@ -165,21 +175,6 @@ def rank_dataframe(dataframe):
165
  dataframe['Ranking'] = [i for i in range(1,len(dataframe)+1)]
166
  return dataframe
167
 
168
- path_ = None
169
-
170
- def run_update_dataset():
171
- global path_
172
- path_ = download_leaderboard_dataset()
173
- for i in range(0, len(rl_envs)):
174
- rl_env = rl_envs[i]
175
- update_leaderboard_dataset_parallel(rl_env["rl_env"], path_)
176
-
177
- api.upload_folder(
178
- folder_path=path_,
179
- repo_id="huph22/drlc-leaderboard-data",
180
- repo_type="dataset",
181
- commit_message="Update dataset")
182
-
183
  def filter_data(rl_env, path, user_id):
184
  data_df = get_data_no_html(rl_env, path)
185
  models = []
 
116
  return row
117
 
118
  data = list(thread_map(process_model, model_ids, desc="Processing models"))
 
119
  # Filter out None results (models with no metadata)
120
  data = [row for row in data if row is not None]
 
121
  ranked_dataframe = rank_dataframe(pd.DataFrame.from_records(data))
122
  new_history = ranked_dataframe
123
  file_path = path + "/" + rl_env + ".csv"
124
  new_history.to_csv(file_path, index=False)
 
125
  return ranked_dataframe
126
 
127
  def download_leaderboard_dataset():
128
  path = snapshot_download(repo_id=DATASET_REPO_ID, repo_type="dataset")
129
  return path
130
 
131
+ path_ = download_leaderboard_dataset()
132
+
133
+ def run_update_dataset():
134
+ global path_
135
+ for i in range(0, len(rl_envs)):
136
+ rl_env = rl_envs[i]
137
+ update_leaderboard_dataset_parallel(rl_env["rl_env"], path_)
138
+
139
+ api.upload_folder(
140
+ folder_path=path_,
141
+ repo_id="huph22/drlc-leaderboard-data",
142
+ repo_type="dataset",
143
+ commit_message="Update dataset")
144
+
145
+
146
  def get_data(rl_env, path) -> pd.DataFrame:
147
  """
148
  Get data from rl_env
 
156
  data.loc[index, "User"] = make_clickable_user(user_id)
157
  model_id = row["Model"]
158
  data.loc[index, "Model"] = make_clickable_model(model_id)
 
159
  return data
160
 
161
  def get_data_no_html(rl_env, path) -> pd.DataFrame:
 
165
  """
166
  csv_path = path + "/" + rl_env + ".csv"
167
  data = pd.read_csv(csv_path)
 
168
  return data
169
 
170
  def rank_dataframe(dataframe):
 
175
  dataframe['Ranking'] = [i for i in range(1,len(dataframe)+1)]
176
  return dataframe
177
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
178
  def filter_data(rl_env, path, user_id):
179
  data_df = get_data_no_html(rl_env, path)
180
  models = []