Pratyush Maini commited on
Commit
693b8b0
·
1 Parent(s): cefd568
Files changed (1) hide show
  1. app.py +15 -9
app.py CHANGED
@@ -20,18 +20,12 @@ LEADERBOARD_PATH = f"locuslab/tofu_leaderboard"
20
  def restart_space():
21
  api.restart_space(repo_id=LEADERBOARD_PATH, token=TOKEN)
22
 
23
- def make_df_from_results_files(results_files):
24
- dfs = []
25
- for file in results_files:
26
- df = pd.read_csv(file)
27
- dfs.append(df)
28
- return pd.concat(dfs)
29
 
30
  # Function to load data from a given CSV file
31
- def load_data(model,version,metrics):
32
  version = version.replace("%", "p")
33
- file_path = f'versions/{model}-{version}.csv' # Replace with your file paths
34
- df = make_df_from_results_files(file_path)
35
 
36
  # we only want specific columns and in a specific order
37
 
@@ -64,6 +58,18 @@ def load_data(model,version,metrics):
64
 
65
  return df
66
 
 
 
 
 
 
 
 
 
 
 
 
 
67
 
68
  # Function for searching in the leaderboard
69
  def search_leaderboard(df, query):
 
20
  def restart_space():
21
  api.restart_space(repo_id=LEADERBOARD_PATH, token=TOKEN)
22
 
 
 
 
 
 
 
23
 
24
  # Function to load data from a given CSV file
25
+ def baseline_load_data(model,version,metrics):
26
  version = version.replace("%", "p")
27
+ file_path = f'versions/{model}-{version}/{model}-{version}.csv' # Replace with your file paths
28
+ df = pd.read_csv(file_path)
29
 
30
  # we only want specific columns and in a specific order
31
 
 
58
 
59
  return df
60
 
61
+ def load_data(model, version, metrics):
62
+ baseline_df = baseline_load_data(model, version, metrics)
63
+ # now for every file in "versions/{model}-{version}/*.csv"
64
+ # if file name is not "model-version.csv", load the file and append it to the dataframe
65
+ for file in os.listdir(f'versions/{model}-{version}'):
66
+ if file == f"{model}-{version}.csv":
67
+ continue
68
+ df = pd.read_csv(f'versions/{model}-{version}/{file}')
69
+ df = df[baseline_df.columns]
70
+ baseline_df = pd.concat([baseline_df, df])
71
+
72
+ return baseline_df
73
 
74
  # Function for searching in the leaderboard
75
  def search_leaderboard(df, query):