Spaces:
Sleeping
Sleeping
Update challenges/vqa/page.py
Browse files- challenges/vqa/page.py +51 -0
challenges/vqa/page.py
CHANGED
|
@@ -34,6 +34,57 @@ logging.basicConfig(level=logging.INFO, format='%(asctime)s - %(levelname)s - %(
|
|
| 34 |
|
| 35 |
|
| 36 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 37 |
|
| 38 |
def handle_submit(file, team, model_name, phase_label, challenge_type, profile: gr.OAuthProfile | None):
|
| 39 |
if profile is None:
|
|
|
|
| 34 |
|
| 35 |
|
| 36 |
|
| 37 |
+
def load_my_submissions(phase_filter: str, profile: gr.OAuthProfile | None):
|
| 38 |
+
if profile is None:
|
| 39 |
+
return pd.DataFrame(), "❌ Please log in to view your submissions.", ""
|
| 40 |
+
username = profile.username
|
| 41 |
+
submissions = _load_user_submissions(username)
|
| 42 |
+
|
| 43 |
+
if not submissions:
|
| 44 |
+
return pd.DataFrame(), "ℹ️ No submissions yet. Head to Submit Predictions to get started!", ""
|
| 45 |
+
|
| 46 |
+
all_submissions = submissions[:]
|
| 47 |
+
if phase_filter and phase_filter != "All":
|
| 48 |
+
submissions = [s for s in submissions if s["phase"] == phase_filter]
|
| 49 |
+
if not submissions:
|
| 50 |
+
return pd.DataFrame(), f"ℹ️ No submissions found for phase **{phase_filter}**.", ""
|
| 51 |
+
|
| 52 |
+
state_icons = {"queued": "🟡", "running": "🔵", "done": "🟢", "failed": "🔴", "unknown": "⚪"}
|
| 53 |
+
df = pd.DataFrame(submissions)
|
| 54 |
+
if "timestamp" in df.columns:
|
| 55 |
+
df["Submitted At"] = pd.to_datetime(
|
| 56 |
+
df["timestamp"], unit="s", errors="coerce"
|
| 57 |
+
).dt.strftime("%d %b %Y, %I:%M %p")
|
| 58 |
+
if "state" in df.columns:
|
| 59 |
+
df["Status"] = df["state"].apply(lambda s: f"{state_icons.get(s, '⚪')} {s.capitalize()}")
|
| 60 |
+
|
| 61 |
+
display_cols = ["Submitted At", "Status", "team", "model", "phase", "challenge_type", "error"]
|
| 62 |
+
metric_cols = [m for m in LEADERBOARD_METRICS if m in df.columns]
|
| 63 |
+
display_cols += metric_cols
|
| 64 |
+
df_display = df[[c for c in display_cols if c in df.columns]].copy()
|
| 65 |
+
df_display.rename(columns={
|
| 66 |
+
"team": "Team", "model": "Model", "phase": "Phase",
|
| 67 |
+
"challenge_type": "Challenge Type", "error": "Error",
|
| 68 |
+
}, inplace=True)
|
| 69 |
+
for m in metric_cols:
|
| 70 |
+
if m in df_display.columns:
|
| 71 |
+
df_display[m] = df_display[m].apply(lambda x: f"{x:.4f}" if pd.notna(x) else "")
|
| 72 |
+
|
| 73 |
+
total = len(all_submissions)
|
| 74 |
+
done = sum(1 for s in all_submissions if s["state"] == "done")
|
| 75 |
+
today_count = sum(
|
| 76 |
+
1 for s in all_submissions
|
| 77 |
+
if datetime.fromtimestamp(s["timestamp"], tz=timezone.utc).strftime("%Y-%m-%d") == _today_utc_str()
|
| 78 |
+
)
|
| 79 |
+
stats = (
|
| 80 |
+
f"**Total:** {total} | "
|
| 81 |
+
f"**Scored:** {done} | "
|
| 82 |
+
f"**Today:** {today_count}/{DAILY_SUBMISSION_CAP}"
|
| 83 |
+
)
|
| 84 |
+
return df_display, "", stats
|
| 85 |
+
|
| 86 |
+
|
| 87 |
+
|
| 88 |
|
| 89 |
def handle_submit(file, team, model_name, phase_label, challenge_type, profile: gr.OAuthProfile | None):
|
| 90 |
if profile is None:
|