saraht14 commited on
Commit
3c0e379
·
verified ·
1 Parent(s): c0c878d
Files changed (1) hide show
  1. app.py +18 -18
app.py CHANGED
@@ -24,22 +24,22 @@ matplotlib.use("Agg")
24
 
25
  # The variable "username" actually refers to "model name"
26
 
27
- def fetch_required_files(exp_config):
28
- # os.makedirs("temp_data", exist_ok=True)
29
- for key in exp_config:
30
- file_path = exp_config[key]['file']
31
- url = f"https://saraht14-server.hf.space/file/{file_path}.txt"
32
 
33
- filename_only = os.path.basename(file_path) + ".txt"
34
- local_path = os.path.join("./", filename_only)
35
 
36
- downloaded = download_file(url, local_path)
37
- if not downloaded:
38
- raise Exception(f"Could not download file: {file_path}")
39
 
40
- exp_config[key]["local_file"] = local_path
41
 
42
- return exp_config
43
 
44
 
45
  def download_file(url, local_path):
@@ -68,23 +68,23 @@ def download_file(url, local_path):
68
  # updated_requests.push_to_hub("IndoorOutdoor/requests", token=HF_TOKEN)
69
  # print("Logged submission request to the requests dataset.")
70
  # def update_results_dataset(leaderboard_df):
71
- repo_id = "saraht14/responses"
72
  def update_results_dataset(new_row_df):
73
- repo_id = "saraht14/responses"
74
 
75
  try:
76
- leaderboard_dataset = load_dataset(repo_id, split="train", token=HF_TOKEN)
77
  leaderboard_df = leaderboard_dataset.to_pandas()
78
  updated_df = pd.concat([leaderboard_df, new_row_df], ignore_index=True)
79
  updated_dataset = Dataset.from_pandas(updated_df)
80
- updated_dataset.push_to_hub(repo_id, token=HF_TOKEN)
81
  print("New row(s) added to existing leaderboard dataset.")
82
  return updated_dataset
83
  except Exception as e:
84
  print("Dataset not found or failed to load, creating a new one.")
85
  try:
86
  new_dataset = Dataset.from_pandas(new_row_df)
87
- new_dataset.push_to_hub(repo_id, token=HF_TOKEN)
88
  return new_dataset
89
  print("New leaderboard dataset created and uploaded.")
90
  except Exception as inner_e:
@@ -159,7 +159,7 @@ df = pd.read_csv(metadata_path)
159
  print(df.head())
160
  def fetch_lb():
161
  try:
162
- leaderboard_dataset = load_dataset("saraht14/responses", split="train", token=HF_TOKEN)
163
  leaderboard_data = leaderboard_dataset.to_pandas()
164
  leaderboard_data = leaderboard_data[HEADERS] # keep it ordered
165
  leaderboard_data = leaderboard_data.sort_values(by=["Accuracy", "Execution Time (s)"], ascending=[False, True])
 
24
 
25
  # The variable "username" actually refers to "model name"
26
 
27
+ # def fetch_required_files(exp_config):
28
+ # # os.makedirs("temp_data", exist_ok=True)
29
+ # for key in exp_config:
30
+ # file_path = exp_config[key]['file']
31
+ # url = f"https://saraht14-server.hf.space/file/{file_path}.txt"
32
 
33
+ # filename_only = os.path.basename(file_path) + ".txt"
34
+ # local_path = os.path.join("./", filename_only)
35
 
36
+ # downloaded = download_file(url, local_path)
37
+ # if not downloaded:
38
+ # raise Exception(f"Could not download file: {file_path}")
39
 
40
+ # exp_config[key]["local_file"] = local_path
41
 
42
+ # return exp_config
43
 
44
 
45
  def download_file(url, local_path):
 
68
  # updated_requests.push_to_hub("IndoorOutdoor/requests", token=HF_TOKEN)
69
  # print("Logged submission request to the requests dataset.")
70
  # def update_results_dataset(leaderboard_df):
71
+ # repo_id = "saraht14/responses"
72
  def update_results_dataset(new_row_df):
73
+ # repo_id = "saraht14/responses"
74
 
75
  try:
76
+ leaderboard_dataset = load_dataset(RESULTS_REPO, split="train", token=HF_TOKEN)
77
  leaderboard_df = leaderboard_dataset.to_pandas()
78
  updated_df = pd.concat([leaderboard_df, new_row_df], ignore_index=True)
79
  updated_dataset = Dataset.from_pandas(updated_df)
80
+ updated_dataset.push_to_hub(RESULTS_REPO, token=HF_TOKEN)
81
  print("New row(s) added to existing leaderboard dataset.")
82
  return updated_dataset
83
  except Exception as e:
84
  print("Dataset not found or failed to load, creating a new one.")
85
  try:
86
  new_dataset = Dataset.from_pandas(new_row_df)
87
+ new_dataset.push_to_hub(RESULTS_REPO, token=HF_TOKEN)
88
  return new_dataset
89
  print("New leaderboard dataset created and uploaded.")
90
  except Exception as inner_e:
 
159
  print(df.head())
160
  def fetch_lb():
161
  try:
162
+ leaderboard_dataset = load_dataset(RESULTS_REPO, split="train", token=HF_TOKEN)
163
  leaderboard_data = leaderboard_dataset.to_pandas()
164
  leaderboard_data = leaderboard_data[HEADERS] # keep it ordered
165
  leaderboard_data = leaderboard_data.sort_values(by=["Accuracy", "Execution Time (s)"], ascending=[False, True])