Spaces:
Running
Running
arunasrivastava
commited on
Commit
·
7c5a93e
1
Parent(s):
ea9b1ca
two space compatability
Browse files
app.py
CHANGED
@@ -2,8 +2,7 @@ import gradio as gr
|
|
2 |
import pandas as pd
|
3 |
import requests
|
4 |
from pathlib import Path
|
5 |
-
from datetime import datetime
|
6 |
-
import time
|
7 |
import logging
|
8 |
import os
|
9 |
|
@@ -12,20 +11,17 @@ logging.basicConfig(level=logging.INFO)
|
|
12 |
# Update URL format for HuggingFace Spaces
|
13 |
QUEUE_SPACE_URL = os.getenv(
|
14 |
'QUEUE_SPACE_URL',
|
15 |
-
'https://koellabs-ipa-transcription-en-queue.hf.space'
|
16 |
).rstrip('/')
|
17 |
|
18 |
-
LAST_UPDATED = "Dec 4th 2024"
|
19 |
-
|
20 |
def load_leaderboard_data():
|
21 |
try:
|
22 |
-
response = requests.get(f"{QUEUE_SPACE_URL}/
|
23 |
-
logging.info(f"Leaderboard request URL: {QUEUE_SPACE_URL}/
|
24 |
response.raise_for_status()
|
25 |
return pd.DataFrame(response.json())
|
26 |
except requests.RequestException as e:
|
27 |
logging.error(f"Error loading leaderboard: {e}")
|
28 |
-
# Fallback to static leaderboard if available
|
29 |
try:
|
30 |
return pd.read_json(Path("fake_queue/leaderboard.json"))
|
31 |
except:
|
@@ -57,8 +53,8 @@ def submit_evaluation(model_name, submission_name, github_url):
|
|
57 |
}
|
58 |
|
59 |
try:
|
60 |
-
response = requests.post(f"{QUEUE_SPACE_URL}/
|
61 |
-
logging.info(f"Submit request URL: {QUEUE_SPACE_URL}/
|
62 |
response.raise_for_status()
|
63 |
task_id = response.json()["task_id"]
|
64 |
return f"✅ Evaluation submitted successfully! Task ID: {task_id}"
|
@@ -69,8 +65,8 @@ def check_task_status(task_id):
|
|
69 |
if not task_id:
|
70 |
return "Please enter a task ID"
|
71 |
try:
|
72 |
-
response = requests.get(f"{QUEUE_SPACE_URL}/
|
73 |
-
logging.info(f"Status check URL: {QUEUE_SPACE_URL}/
|
74 |
response.raise_for_status()
|
75 |
return response.json()
|
76 |
except requests.RequestException as e:
|
|
|
2 |
import pandas as pd
|
3 |
import requests
|
4 |
from pathlib import Path
|
5 |
+
from datetime import datetime
|
|
|
6 |
import logging
|
7 |
import os
|
8 |
|
|
|
11 |
# Update URL format for HuggingFace Spaces
|
12 |
QUEUE_SPACE_URL = os.getenv(
|
13 |
'QUEUE_SPACE_URL',
|
14 |
+
'https://koellabs-ipa-transcription-en-queue.hf.space/api'
|
15 |
).rstrip('/')
|
16 |
|
|
|
|
|
17 |
def load_leaderboard_data():
|
18 |
try:
|
19 |
+
response = requests.get(f"{QUEUE_SPACE_URL}/leaderboard")
|
20 |
+
logging.info(f"Leaderboard request URL: {QUEUE_SPACE_URL}/leaderboard")
|
21 |
response.raise_for_status()
|
22 |
return pd.DataFrame(response.json())
|
23 |
except requests.RequestException as e:
|
24 |
logging.error(f"Error loading leaderboard: {e}")
|
|
|
25 |
try:
|
26 |
return pd.read_json(Path("fake_queue/leaderboard.json"))
|
27 |
except:
|
|
|
53 |
}
|
54 |
|
55 |
try:
|
56 |
+
response = requests.post(f"{QUEUE_SPACE_URL}/evaluate", json=request_data)
|
57 |
+
logging.info(f"Submit request URL: {QUEUE_SPACE_URL}/evaluate")
|
58 |
response.raise_for_status()
|
59 |
task_id = response.json()["task_id"]
|
60 |
return f"✅ Evaluation submitted successfully! Task ID: {task_id}"
|
|
|
65 |
if not task_id:
|
66 |
return "Please enter a task ID"
|
67 |
try:
|
68 |
+
response = requests.get(f"{QUEUE_SPACE_URL}/tasks/{task_id}")
|
69 |
+
logging.info(f"Status check URL: {QUEUE_SPACE_URL}/tasks/{task_id}")
|
70 |
response.raise_for_status()
|
71 |
return response.json()
|
72 |
except requests.RequestException as e:
|