Update app.py
Browse files
app.py
CHANGED
@@ -2,7 +2,6 @@ import gradio as gr
|
|
2 |
import pandas as pd
|
3 |
import os
|
4 |
import shutil
|
5 |
-
import tempfile
|
6 |
|
7 |
# Description and Introduction texts
|
8 |
DESCRIPTION = """
|
@@ -54,39 +53,24 @@ def add_new_entry(file, password):
|
|
54 |
if password != UPLOAD_SECRET:
|
55 |
return df, "Incorrect password. Upload failed."
|
56 |
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
|
63 |
-
|
64 |
-
|
65 |
-
|
66 |
-
|
67 |
-
|
68 |
-
|
69 |
-
|
70 |
-
|
71 |
-
|
72 |
-
|
73 |
-
|
74 |
-
|
75 |
-
# Append the new data to the existing DataFrame
|
76 |
-
df = pd.concat([df, new_df], ignore_index=True)
|
77 |
-
|
78 |
-
# Move the temporary file to the CSV folder
|
79 |
-
filename = os.path.basename(file.name)
|
80 |
-
destination = os.path.join(csv_folder_path, filename)
|
81 |
-
shutil.move(temp_file_path, destination)
|
82 |
-
|
83 |
-
return df, f"File '{filename}' uploaded and data added successfully!"
|
84 |
-
except Exception as e:
|
85 |
-
return df, f"An error occurred: {str(e)}"
|
86 |
-
finally:
|
87 |
-
# Ensure the temporary file is removed if it still exists
|
88 |
-
if 'temp_file_path' in locals() and os.path.exists(temp_file_path):
|
89 |
-
os.unlink(temp_file_path)
|
90 |
|
91 |
def read_and_process_csv_files(folder_path):
|
92 |
all_data = []
|
|
|
2 |
import pandas as pd
|
3 |
import os
|
4 |
import shutil
|
|
|
5 |
|
6 |
# Description and Introduction texts
|
7 |
DESCRIPTION = """
|
|
|
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 = []
|