Update src/benchmark_utils.py
Browse files- src/benchmark_utils.py +17 -2
src/benchmark_utils.py
CHANGED
|
@@ -1,5 +1,7 @@
|
|
| 1 |
import pandas as pd
|
| 2 |
import streamlit as st
|
|
|
|
|
|
|
| 3 |
|
| 4 |
@st.cache_data(hash_funcs={pd.DataFrame: lambda _: None})
|
| 5 |
def load_leaderboard(file_path="data/results_df_all_tuned.csv"):
|
|
@@ -13,8 +15,21 @@ def load_leaderboard(file_path="data/results_df_all_tuned.csv"):
|
|
| 13 |
pd.DataFrame: DataFrame đã được sắp xếp, sẵn sàng để hiển thị.
|
| 14 |
"""
|
| 15 |
try:
|
|
|
|
|
|
|
| 16 |
df = pd.read_csv(file_path)
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
SORT_COLUMN_NAME = 'RMSE (Absolute Error)'
|
| 19 |
|
| 20 |
if SORT_COLUMN_NAME in df.columns:
|
|
@@ -23,7 +38,7 @@ def load_leaderboard(file_path="data/results_df_all_tuned.csv"):
|
|
| 23 |
st.warning(f"Không tìm thấy cột '{SORT_COLUMN_NAME}' để sắp xếp leaderboard. "
|
| 24 |
f"Vui lòng kiểm tra file `src/benchmark_utils.py`.")
|
| 25 |
df_sorted = df
|
| 26 |
-
|
| 27 |
return df_sorted
|
| 28 |
|
| 29 |
except FileNotFoundError:
|
|
|
|
| 1 |
import pandas as pd
|
| 2 |
import streamlit as st
|
| 3 |
+
import time
|
| 4 |
+
import os
|
| 5 |
|
| 6 |
@st.cache_data(hash_funcs={pd.DataFrame: lambda _: None})
|
| 7 |
def load_leaderboard(file_path="data/results_df_all_tuned.csv"):
|
|
|
|
| 15 |
pd.DataFrame: DataFrame đã được sắp xếp, sẵn sàng để hiển thị.
|
| 16 |
"""
|
| 17 |
try:
|
| 18 |
+
# Time the read to help diagnose cold-starts on hosted platforms
|
| 19 |
+
start = time.time()
|
| 20 |
df = pd.read_csv(file_path)
|
| 21 |
+
elapsed = time.time() - start
|
| 22 |
+
|
| 23 |
+
# Report file size and load time to the Streamlit console/UI for diagnostics
|
| 24 |
+
try:
|
| 25 |
+
fsize_mb = os.path.getsize(file_path) / (1024 * 1024)
|
| 26 |
+
except Exception:
|
| 27 |
+
fsize_mb = 0.0
|
| 28 |
+
|
| 29 |
+
# If load took longer than a short threshold, surface an informational note
|
| 30 |
+
if elapsed > 0.5:
|
| 31 |
+
st.info(f"Loaded leaderboard file '{file_path}' ({fsize_mb:.2f} MB) in {elapsed:.2f} s")
|
| 32 |
+
|
| 33 |
SORT_COLUMN_NAME = 'RMSE (Absolute Error)'
|
| 34 |
|
| 35 |
if SORT_COLUMN_NAME in df.columns:
|
|
|
|
| 38 |
st.warning(f"Không tìm thấy cột '{SORT_COLUMN_NAME}' để sắp xếp leaderboard. "
|
| 39 |
f"Vui lòng kiểm tra file `src/benchmark_utils.py`.")
|
| 40 |
df_sorted = df
|
| 41 |
+
|
| 42 |
return df_sorted
|
| 43 |
|
| 44 |
except FileNotFoundError:
|