Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
chriscanal
commited on
Commit
•
75297e7
1
Parent(s):
02700b6
Fixing bug that messes up the order of models
Browse filesCreating copy of original df to avoid modifying the original when ordering by date uploaded.
src/display_models/plot_results.py
CHANGED
@@ -36,10 +36,12 @@ def to_datetime(model_info: Tuple[str, Any]) -> datetime:
|
|
36 |
def join_model_info_with_results(results_df: pd.DataFrame) -> pd.DataFrame:
|
37 |
"""
|
38 |
Integrates model information with the results DataFrame by matching 'Model sha'.
|
39 |
-
|
40 |
:param results_df: A DataFrame containing results information including 'Model sha' column.
|
41 |
:return: A DataFrame with updated 'Results Date' columns, which are synchronized with model information.
|
42 |
"""
|
|
|
|
|
|
|
43 |
# load cache from disk
|
44 |
try:
|
45 |
with open("model_info_cache.pkl", "rb") as f:
|
@@ -49,7 +51,7 @@ def join_model_info_with_results(results_df: pd.DataFrame) -> pd.DataFrame:
|
|
49 |
|
50 |
# Sort date strings using datetime objects as keys
|
51 |
sorted_dates = sorted(list(model_info_cache.items()), key=to_datetime, reverse=True)
|
52 |
-
|
53 |
|
54 |
# Define the date format string
|
55 |
date_format = "%Y-%m-%dT%H:%M:%S.%fZ"
|
@@ -60,8 +62,8 @@ def join_model_info_with_results(results_df: pd.DataFrame) -> pd.DataFrame:
|
|
60 |
last_modified_datetime = datetime.strptime(obj.lastModified, date_format).replace(tzinfo=timezone.utc)
|
61 |
|
62 |
# Update the "Results Date" column where "Model sha" equals obj.sha
|
63 |
-
|
64 |
-
return
|
65 |
|
66 |
|
67 |
def create_scores_df(results_df: pd.DataFrame) -> pd.DataFrame:
|
|
|
36 |
def join_model_info_with_results(results_df: pd.DataFrame) -> pd.DataFrame:
|
37 |
"""
|
38 |
Integrates model information with the results DataFrame by matching 'Model sha'.
|
|
|
39 |
:param results_df: A DataFrame containing results information including 'Model sha' column.
|
40 |
:return: A DataFrame with updated 'Results Date' columns, which are synchronized with model information.
|
41 |
"""
|
42 |
+
# copy dataframe to avoid modifying the original
|
43 |
+
df = results_df.copy(deep=True)
|
44 |
+
|
45 |
# load cache from disk
|
46 |
try:
|
47 |
with open("model_info_cache.pkl", "rb") as f:
|
|
|
51 |
|
52 |
# Sort date strings using datetime objects as keys
|
53 |
sorted_dates = sorted(list(model_info_cache.items()), key=to_datetime, reverse=True)
|
54 |
+
df["Results Date"] = datetime.now().replace(tzinfo=timezone.utc)
|
55 |
|
56 |
# Define the date format string
|
57 |
date_format = "%Y-%m-%dT%H:%M:%S.%fZ"
|
|
|
62 |
last_modified_datetime = datetime.strptime(obj.lastModified, date_format).replace(tzinfo=timezone.utc)
|
63 |
|
64 |
# Update the "Results Date" column where "Model sha" equals obj.sha
|
65 |
+
df.loc[df["Model sha"] == obj.sha, "Results Date"] = last_modified_datetime
|
66 |
+
return df
|
67 |
|
68 |
|
69 |
def create_scores_df(results_df: pd.DataFrame) -> pd.DataFrame:
|