Update app.py
Browse files
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 |
-
|
| 57 |
-
|
| 58 |
-
|
| 59 |
-
|
| 60 |
-
|
| 61 |
-
|
| 62 |
-
|
| 63 |
-
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
|
| 72 |
-
|
| 73 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 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 = []
|