ThomasSimonini HF staff commited on
Commit
1347af3
β€’
1 Parent(s): 7d04350

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -11
app.py CHANGED
@@ -215,8 +215,8 @@ def update_leaderboard_dataset(rl_env, path):
215
  return ranked_dataframe
216
 
217
  def download_leaderboard_dataset():
218
- global path_
219
- path_ = snapshot_download(repo_id=DATASET_REPO_ID, repo_type="dataset")
220
 
221
  def get_data(rl_env, path) -> pd.DataFrame:
222
  """
@@ -254,7 +254,7 @@ def rank_dataframe(dataframe):
254
 
255
 
256
  def run_update_dataset():
257
- download_leaderboard_dataset()
258
  for i in range(0, len(rl_envs)):
259
  rl_env = rl_envs[i]
260
  update_leaderboard_dataset(rl_env["rl_env"], path_)
@@ -286,7 +286,6 @@ def filter_data(rl_env, path, user_id):
286
 
287
  run_update_dataset()
288
 
289
-
290
  with block:
291
  gr.Markdown(f"""
292
  # πŸ† The Deep Reinforcement Learning Course Leaderboard πŸ†
@@ -308,7 +307,7 @@ with block:
308
 
309
  πŸ”§ There is an **environment missing?** Please open an issue.
310
  """)
311
-
312
 
313
  for i in range(0, len(rl_envs)):
314
  rl_env = rl_envs[i]
@@ -332,17 +331,17 @@ with block:
332
  search_btn = gr.Button("Search my models πŸ”Ž")
333
  reset_btn = gr.Button("Clear my search")
334
  env = gr.Variable(rl_env["rl_env"])
335
- path = gr.Variable(path_)
336
  with gr.Row():
337
- gr_dataframe = gr.components.Dataframe(value=get_data(rl_env["rl_env"], path), headers=["Ranking πŸ†", "User πŸ€—", "Model id πŸ€–", "Results", "Mean Reward", "Std Reward"], datatype=["number", "markdown", "markdown", "number", "number", "number"], row_count=(100, 'fixed'))
338
 
339
  with gr.Row():
340
  #gr_search_dataframe = gr.components.Dataframe(headers=["Ranking πŸ†", "User πŸ€—", "Model id πŸ€–", "Results", "Mean Reward", "Std Reward"], datatype=["number", "markdown", "markdown", "number", "number", "number"], visible=False)
341
- search_btn.click(fn=filter_data, inputs=[env, path, user_id], outputs=gr_dataframe, api_name="filter_data")
342
 
343
  with gr.Row():
344
- search_btn.click(fn=filter_data, inputs=[env, path, user_id], outputs=gr_dataframe, api_name="filter_data")
345
- reset_btn.click(fn=get_data, inputs=[env, path], outputs=gr_dataframe, api_name="get_data")
346
 
347
  scheduler = BackgroundScheduler()
348
  # Refresh every hour
@@ -353,4 +352,3 @@ scheduler.start()
353
  block.launch()
354
 
355
 
356
-
 
215
  return ranked_dataframe
216
 
217
  def download_leaderboard_dataset():
218
+ path = snapshot_download(repo_id=DATASET_REPO_ID, repo_type="dataset")
219
+ return path
220
 
221
  def get_data(rl_env, path) -> pd.DataFrame:
222
  """
 
254
 
255
 
256
  def run_update_dataset():
257
+ path_ = download_leaderboard_dataset()
258
  for i in range(0, len(rl_envs)):
259
  rl_env = rl_envs[i]
260
  update_leaderboard_dataset(rl_env["rl_env"], path_)
 
286
 
287
  run_update_dataset()
288
 
 
289
  with block:
290
  gr.Markdown(f"""
291
  # πŸ† The Deep Reinforcement Learning Course Leaderboard πŸ†
 
307
 
308
  πŸ”§ There is an **environment missing?** Please open an issue.
309
  """)
310
+ path_ = download_leaderboard_dataset()
311
 
312
  for i in range(0, len(rl_envs)):
313
  rl_env = rl_envs[i]
 
331
  search_btn = gr.Button("Search my models πŸ”Ž")
332
  reset_btn = gr.Button("Clear my search")
333
  env = gr.Variable(rl_env["rl_env"])
334
+ grpath = gr.Variable(path_)
335
  with gr.Row():
336
+ gr_dataframe = gr.components.Dataframe(value=get_data(rl_env["rl_env"], path_), headers=["Ranking πŸ†", "User πŸ€—", "Model id πŸ€–", "Results", "Mean Reward", "Std Reward"], datatype=["number", "markdown", "markdown", "number", "number", "number"], row_count=(100, 'fixed'))
337
 
338
  with gr.Row():
339
  #gr_search_dataframe = gr.components.Dataframe(headers=["Ranking πŸ†", "User πŸ€—", "Model id πŸ€–", "Results", "Mean Reward", "Std Reward"], datatype=["number", "markdown", "markdown", "number", "number", "number"], visible=False)
340
+ search_btn.click(fn=filter_data, inputs=[env, grpath, user_id], outputs=gr_dataframe, api_name="filter_data")
341
 
342
  with gr.Row():
343
+ search_btn.click(fn=filter_data, inputs=[env, grpath, user_id], outputs=gr_dataframe, api_name="filter_data")
344
+ reset_btn.click(fn=get_data, inputs=[env, grpath], outputs=gr_dataframe, api_name="get_data")
345
 
346
  scheduler = BackgroundScheduler()
347
  # Refresh every hour
 
352
  block.launch()
353
 
354