Spaces:
Sleeping
Sleeping
fix
Browse files
app.py
CHANGED
|
@@ -5,7 +5,7 @@ import os
|
|
| 5 |
import time
|
| 6 |
import datetime
|
| 7 |
from typing import Dict, Any
|
| 8 |
-
from utils import fetch_competition_summary, fetch_models_evaluation, highlight_score_column, get_competitions
|
| 9 |
# from dotenv import load_dotenv
|
| 10 |
from cfg import *
|
| 11 |
# load_dotenv()
|
|
@@ -86,8 +86,11 @@ def main():
|
|
| 86 |
for competition_info in competitions:
|
| 87 |
competition = competition_info[0]
|
| 88 |
if not competition_summaries[competition].empty:
|
|
|
|
|
|
|
|
|
|
| 89 |
# get all winning hotkeys and number of wins
|
| 90 |
-
winning_hotkeys =
|
| 91 |
|
| 92 |
# if not empty, get the best hotkey
|
| 93 |
if not winning_hotkeys.empty:
|
|
|
|
| 5 |
import time
|
| 6 |
import datetime
|
| 7 |
from typing import Dict, Any
|
| 8 |
+
from utils import fetch_competition_summary, fetch_models_evaluation, highlight_score_column, get_competitions, get_latest_evaluation_time
|
| 9 |
# from dotenv import load_dotenv
|
| 10 |
from cfg import *
|
| 11 |
# load_dotenv()
|
|
|
|
| 86 |
for competition_info in competitions:
|
| 87 |
competition = competition_info[0]
|
| 88 |
if not competition_summaries[competition].empty:
|
| 89 |
+
# get only competition sumaries that heppen after latest evaluation time
|
| 90 |
+
evaluation_time = get_latest_evaluation_time(competition_info[1])
|
| 91 |
+
filtered_competition_summaries = competition_summaries[competition][competition_summaries[competition]["Created At"] > evaluation_time]
|
| 92 |
# get all winning hotkeys and number of wins
|
| 93 |
+
winning_hotkeys = filtered_competition_summaries["Winning Hotkey"].value_counts()
|
| 94 |
|
| 95 |
# if not empty, get the best hotkey
|
| 96 |
if not winning_hotkeys.empty:
|
utils.py
CHANGED
|
@@ -2,7 +2,7 @@ import streamlit as st
|
|
| 2 |
import pandas as pd
|
| 3 |
import wandb
|
| 4 |
import time
|
| 5 |
-
from datetime import datetime
|
| 6 |
import requests
|
| 7 |
|
| 8 |
|
|
@@ -26,6 +26,40 @@ def get_competitions(CONFIG_URL):
|
|
| 26 |
return competitions
|
| 27 |
|
| 28 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 29 |
def fetch_competition_summary(api, entity, project):
|
| 30 |
data = []
|
| 31 |
|
|
|
|
| 2 |
import pandas as pd
|
| 3 |
import wandb
|
| 4 |
import time
|
| 5 |
+
from datetime import datetime, timedelta
|
| 6 |
import requests
|
| 7 |
|
| 8 |
|
|
|
|
| 26 |
return competitions
|
| 27 |
|
| 28 |
|
| 29 |
+
def get_latest_evaluation_time(evaluation_times):
|
| 30 |
+
"""
|
| 31 |
+
Get the latest UTC evaluation time as a datetime object (either today or yesterday).
|
| 32 |
+
|
| 33 |
+
Args:
|
| 34 |
+
evaluation_times (list): List of evaluation times as strings (in HH:MM format).
|
| 35 |
+
|
| 36 |
+
Returns:
|
| 37 |
+
datetime: Latest evaluation time as a datetime object.
|
| 38 |
+
"""
|
| 39 |
+
|
| 40 |
+
# Get the current UTC date and time
|
| 41 |
+
current_utc_datetime = datetime.utcnow()
|
| 42 |
+
current_utc_time = current_utc_datetime.time()
|
| 43 |
+
|
| 44 |
+
# Convert evaluation times to datetime.time objects
|
| 45 |
+
eval_times = [datetime.strptime(time, "%H:%M").time() for time in evaluation_times]
|
| 46 |
+
|
| 47 |
+
# Sort the evaluation times to ensure they are in chronological order
|
| 48 |
+
eval_times.sort()
|
| 49 |
+
|
| 50 |
+
# Loop through the evaluation times in reverse to find the latest time that has passed
|
| 51 |
+
for eval_time in reversed(eval_times):
|
| 52 |
+
if current_utc_time >= eval_time:
|
| 53 |
+
# If the time has passed today, return today's date with that time
|
| 54 |
+
return current_utc_datetime.replace(hour=eval_time.hour, minute=eval_time.minute, second=0, microsecond=0)
|
| 55 |
+
|
| 56 |
+
# If none of the evaluation times have passed, return the latest one from the previous day
|
| 57 |
+
yesterday = current_utc_datetime - timedelta(days=1)
|
| 58 |
+
latest_eval_time = eval_times[-1]
|
| 59 |
+
|
| 60 |
+
return yesterday.replace(hour=latest_eval_time.hour, minute=latest_eval_time.minute, second=0, microsecond=0)
|
| 61 |
+
|
| 62 |
+
|
| 63 |
def fetch_competition_summary(api, entity, project):
|
| 64 |
data = []
|
| 65 |
|