rbgo commited on
Commit
f9e9910
·
verified ·
1 Parent(s): 6dcc5e4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -18
app.py CHANGED
@@ -53,24 +53,30 @@ def add_new_entry(file, password):
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 = []
 
53
  if password != UPLOAD_SECRET:
54
  return df, "Incorrect password. Upload failed."
55
 
56
+ try:
57
+ # Read the uploaded file
58
+ new_df = pd.read_csv(file.name)
59
+
60
+ columns_order = [
61
+ "Model_Name", "Library", "TTFT", "Tokens-per-Second", "Token_Count",
62
+ "input_length", "output_length"
63
+ ]
64
+ for col in columns_order:
65
+ if col not in new_df.columns:
66
+ new_df[col] = pd.NA
67
+ new_df = new_df[columns_order]
68
+
69
+ # Append the new data to the existing DataFrame
70
+ df = pd.concat([df, new_df], ignore_index=True)
71
+
72
+ # Save the uploaded file to the CSV folder
73
+ filename = os.path.basename(file.name)
74
+ destination = os.path.join(csv_folder_path, filename)
75
+ file.save(destination)
76
+
77
+ return df, f"File '{filename}' uploaded and data added successfully!"
78
+ except Exception as e:
79
+ return df, f"An error occurred: {str(e)}"
80
 
81
  def read_and_process_csv_files(folder_path):
82
  all_data = []