rbgo commited on
Commit
bab3995
·
verified ·
1 Parent(s): 9f250e3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +32 -25
app.py CHANGED
@@ -41,6 +41,37 @@ HOW_WE_TESTED = """
41
 
42
  csv_folder_path = 'result_csv/'
43
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
44
  def read_and_process_csv_files(folder_path):
45
  all_data = []
46
  for filename in os.listdir(folder_path):
@@ -53,7 +84,7 @@ def read_and_process_csv_files(folder_path):
53
 
54
  columns_order = [
55
  "Model_Name", "Library", "TTFT", "Tokens-per-Second", "Token_Count",
56
- "input_length", "output_length", "Input", "Output"
57
  ]
58
 
59
  for col in columns_order:
@@ -67,30 +98,6 @@ df = read_and_process_csv_files(csv_folder_path)
67
  def get_leaderboard_df():
68
  return df
69
 
70
- def add_new_entry(file):
71
- global df
72
- if file is None:
73
- return df, "No file uploaded."
74
-
75
- new_df = pd.read_csv(file.name)
76
-
77
- columns_order = [
78
- "Model_Name", "Library", "TTFT", "Tokens-per-Second", "Token_Count",
79
- "input_length", "output_length", "Input", "Output"
80
- ]
81
- for col in columns_order:
82
- if col not in new_df.columns:
83
- new_df[col] = pd.NA
84
- new_df = new_df[columns_order]
85
-
86
- df = pd.concat([df, new_df], ignore_index=True)
87
-
88
- filename = os.path.basename(file.name)
89
- destination = os.path.join(csv_folder_path, filename)
90
- shutil.copy(file.name, destination)
91
-
92
- return df, f"File '{filename}' uploaded and data added successfully!"
93
-
94
  def filter_and_search(search_term, library_filter):
95
  filtered_df = df.copy()
96
 
 
41
 
42
  csv_folder_path = 'result_csv/'
43
 
44
+ UPLOAD_SECRET = os.getenv("UPLOAD_SECRET")
45
+
46
+ # ... [Previous functions remain the same: read_and_process_csv_files, get_leaderboard_df, filter_and_search] ...
47
+
48
+ def add_new_entry(file, password):
49
+ global df
50
+ if file is None:
51
+ return df, "No file uploaded."
52
+
53
+ if password != UPLOAD_SECRET:
54
+ return df, "Incorrect password. Upload failed."
55
+
56
+ new_df = pd.read_csv(file.name)
57
+
58
+ columns_order = [
59
+ "Model_Name", "Library", "TTFT", "Tokens-per-Second", "Token_Count",
60
+ "Input_Tokens", "Output_Tokens"
61
+ ]
62
+ for col in columns_order:
63
+ if col not in new_df.columns:
64
+ new_df[col] = pd.NA
65
+ new_df = new_df[columns_order]
66
+
67
+ df = pd.concat([df, new_df], ignore_index=True)
68
+
69
+ filename = os.path.basename(file.name)
70
+ destination = os.path.join(csv_folder_path, filename)
71
+ shutil.copy(file.name, destination)
72
+
73
+ return df, f"File '{filename}' uploaded and data added successfully!"
74
+
75
  def read_and_process_csv_files(folder_path):
76
  all_data = []
77
  for filename in os.listdir(folder_path):
 
84
 
85
  columns_order = [
86
  "Model_Name", "Library", "TTFT", "Tokens-per-Second", "Token_Count",
87
+ "input_length", "output_length"
88
  ]
89
 
90
  for col in columns_order:
 
98
  def get_leaderboard_df():
99
  return df
100
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  def filter_and_search(search_term, library_filter):
102
  filtered_df = df.copy()
103