Spaces:
Running
Upload from GitHub Actions: backend: handle null creation_date in three apply() calls
Browse filesThe aggregated results may contain rows for models that don't have
metadata in models.json (e.g. when results-detailed includes historical
models that have since rotated out of important_models). The
results+models left-join leaves those rows with NaN/NaT creation_date,
which the old "x.isoformat() if x else None" lambdas tripped over
because pandas NaT is truthy and a float-NaN doesn't have .isoformat.
Replace with "pd.notna(x) and hasattr(x, 'isoformat')" in all three
spots: make_model_table, make_language_tier_history, make_license_history.
Surfaced after this morning's results-restore widened the aggregate
to historical models that aren't in the current cohort; the HF Space
returned 500 for every /api/data call ("Network response was not ok"
in the frontend).
- evals/backend.py +3 -3
|
@@ -173,7 +173,7 @@ def make_model_table(scores_df, models, scores_df_detailed=None):
|
|
| 173 |
df = pd.merge(df, models, left_on="model", right_on="id", how="left")
|
| 174 |
df["rank"] = df.index + 1
|
| 175 |
df["creation_date"] = df["creation_date"].apply(
|
| 176 |
-
lambda x: x.isoformat() if x else None
|
| 177 |
)
|
| 178 |
|
| 179 |
# Select columns dynamically
|
|
@@ -295,7 +295,7 @@ def make_language_tier_history(scores_df, languages, models):
|
|
| 295 |
tier_scores, models, left_on="model", right_on="id", how="left"
|
| 296 |
)
|
| 297 |
tier_scores["creation_date"] = tier_scores["creation_date"].apply(
|
| 298 |
-
lambda x: x.isoformat() if x else None
|
| 299 |
)
|
| 300 |
|
| 301 |
return tier_scores[
|
|
@@ -331,7 +331,7 @@ def make_license_history(scores_df, models):
|
|
| 331 |
lambda x: "Open-source" if x == "open-source" else "Commercial"
|
| 332 |
)
|
| 333 |
df["creation_date"] = df["creation_date"].apply(
|
| 334 |
-
lambda x: x.isoformat() if x else None
|
| 335 |
)
|
| 336 |
|
| 337 |
return df[
|
|
|
|
| 173 |
df = pd.merge(df, models, left_on="model", right_on="id", how="left")
|
| 174 |
df["rank"] = df.index + 1
|
| 175 |
df["creation_date"] = df["creation_date"].apply(
|
| 176 |
+
lambda x: x.isoformat() if pd.notna(x) and hasattr(x, "isoformat") else None
|
| 177 |
)
|
| 178 |
|
| 179 |
# Select columns dynamically
|
|
|
|
| 295 |
tier_scores, models, left_on="model", right_on="id", how="left"
|
| 296 |
)
|
| 297 |
tier_scores["creation_date"] = tier_scores["creation_date"].apply(
|
| 298 |
+
lambda x: x.isoformat() if pd.notna(x) and hasattr(x, "isoformat") else None
|
| 299 |
)
|
| 300 |
|
| 301 |
return tier_scores[
|
|
|
|
| 331 |
lambda x: "Open-source" if x == "open-source" else "Commercial"
|
| 332 |
)
|
| 333 |
df["creation_date"] = df["creation_date"].apply(
|
| 334 |
+
lambda x: x.isoformat() if pd.notna(x) and hasattr(x, "isoformat") else None
|
| 335 |
)
|
| 336 |
|
| 337 |
return df[
|