Spaces:
Sleeping
Sleeping
SAGE OSS Evaluator
commited on
Commit
·
bb10451
1
Parent(s):
f235878
update
Browse files
app.py
CHANGED
|
@@ -64,12 +64,12 @@ def model_hyperlink(link, model_name):
|
|
| 64 |
return model_name
|
| 65 |
|
| 66 |
def load_submission_history():
|
| 67 |
-
"""
|
| 68 |
try:
|
| 69 |
from src.oss.oss_file_manager import OSSFileManager
|
| 70 |
oss_manager = OSSFileManager()
|
| 71 |
|
| 72 |
-
#
|
| 73 |
history_content = oss_manager.download_file_content(
|
| 74 |
SUBMISSION_TRACKING_PATH + SUBMISSION_HISTORY_FILE
|
| 75 |
)
|
|
@@ -77,20 +77,20 @@ def load_submission_history():
|
|
| 77 |
if history_content:
|
| 78 |
return json.loads(history_content)
|
| 79 |
else:
|
| 80 |
-
print("📝
|
| 81 |
return {}
|
| 82 |
|
| 83 |
except Exception as e:
|
| 84 |
-
print(f"⚠️
|
| 85 |
return {}
|
| 86 |
|
| 87 |
def save_submission_history(history):
|
| 88 |
-
"""
|
| 89 |
try:
|
| 90 |
from src.oss.oss_file_manager import OSSFileManager
|
| 91 |
oss_manager = OSSFileManager()
|
| 92 |
|
| 93 |
-
#
|
| 94 |
history_json = json.dumps(history, indent=2, ensure_ascii=False)
|
| 95 |
success = oss_manager.upload_file_content(
|
| 96 |
content=history_json,
|
|
@@ -100,53 +100,53 @@ def save_submission_history(history):
|
|
| 100 |
return success
|
| 101 |
|
| 102 |
except Exception as e:
|
| 103 |
-
print(f"❌
|
| 104 |
return False
|
| 105 |
|
| 106 |
def check_user_submission_eligibility(profile: gr.OAuthProfile, org_name: str):
|
| 107 |
-
"""
|
| 108 |
try:
|
| 109 |
-
# 1.
|
| 110 |
user_data = requests.get(f"https://huggingface.co/api/users/{profile.username}/overview")
|
| 111 |
if user_data.status_code == 200:
|
| 112 |
creation_date = json.loads(user_data.content)["createdAt"]
|
| 113 |
account_age = datetime.datetime.now() - datetime.datetime.strptime(creation_date, '%Y-%m-%dT%H:%M:%S.%fZ')
|
| 114 |
|
| 115 |
if account_age < datetime.timedelta(days=60):
|
| 116 |
-
return False, "
|
| 117 |
else:
|
| 118 |
-
return False, "
|
| 119 |
|
| 120 |
-
# 2.
|
| 121 |
submission_history = load_submission_history()
|
| 122 |
user_submissions = submission_history.get(profile.username, [])
|
| 123 |
|
| 124 |
today = datetime.datetime.today().strftime('%Y-%m-%d')
|
| 125 |
today_submissions = [s for s in user_submissions if s.get("date", "") == today]
|
| 126 |
|
| 127 |
-
if len(today_submissions) >
|
| 128 |
-
return False, "
|
| 129 |
|
| 130 |
-
# 3.
|
| 131 |
for submission in user_submissions:
|
| 132 |
if submission.get("organization", "").lower() == org_name.lower():
|
| 133 |
-
return False, f"
|
| 134 |
|
| 135 |
-
return True, "
|
| 136 |
|
| 137 |
except Exception as e:
|
| 138 |
-
print(f"❌
|
| 139 |
-
return False, f"
|
| 140 |
|
| 141 |
def record_user_submission(profile: gr.OAuthProfile, org_name: str, email: str):
|
| 142 |
-
"""
|
| 143 |
try:
|
| 144 |
submission_history = load_submission_history()
|
| 145 |
|
| 146 |
if profile.username not in submission_history:
|
| 147 |
submission_history[profile.username] = []
|
| 148 |
|
| 149 |
-
#
|
| 150 |
submission_record = {
|
| 151 |
"date": datetime.datetime.today().strftime('%Y-%m-%d'),
|
| 152 |
"time": datetime.datetime.now().strftime('%H:%M:%S'),
|
|
@@ -157,11 +157,11 @@ def record_user_submission(profile: gr.OAuthProfile, org_name: str, email: str):
|
|
| 157 |
|
| 158 |
submission_history[profile.username].append(submission_record)
|
| 159 |
|
| 160 |
-
#
|
| 161 |
return save_submission_history(submission_history)
|
| 162 |
|
| 163 |
except Exception as e:
|
| 164 |
-
print(f"❌
|
| 165 |
return False
|
| 166 |
|
| 167 |
def get_leaderboard_dataframe():
|
|
@@ -231,7 +231,7 @@ with demo:
|
|
| 231 |
# Main leaderboard table
|
| 232 |
gr.Markdown("## 🏆 SAGE Benchmark Results", elem_classes="markdown-text")
|
| 233 |
|
| 234 |
-
# Debug information -
|
| 235 |
results_count = gr.Markdown(f"📊 **Showing {len(leaderboard_df)} results**")
|
| 236 |
|
| 237 |
leaderboard_table = gr.Dataframe(
|
|
@@ -246,7 +246,7 @@ with demo:
|
|
| 246 |
refresh_button = gr.Button("🔄 Refresh Leaderboard")
|
| 247 |
|
| 248 |
def refresh_leaderboard_with_count():
|
| 249 |
-
"""
|
| 250 |
df = refresh_leaderboard()
|
| 251 |
count_text = f"📊 **Showing {len(df)} results**"
|
| 252 |
return df, count_text
|
|
@@ -263,39 +263,39 @@ with demo:
|
|
| 263 |
|
| 264 |
# 添加提交说明(登录要求暂时注释)
|
| 265 |
gr.Markdown("""
|
| 266 |
-
### 📋
|
| 267 |
<!--
|
| 268 |
-
-
|
| 269 |
-
-
|
| 270 |
-
-
|
| 271 |
-->
|
| 272 |
-
-
|
| 273 |
-
-
|
| 274 |
-
-
|
| 275 |
-
-
|
| 276 |
|
| 277 |
<!--
|
| 278 |
-
### 🔐
|
| 279 |
-
|
| 280 |
-
-
|
| 281 |
-
-
|
| 282 |
-
-
|
| 283 |
-->
|
| 284 |
""", elem_classes="markdown-text")
|
| 285 |
|
| 286 |
with gr.Row():
|
| 287 |
with gr.Column():
|
| 288 |
org_textbox = gr.Textbox(
|
| 289 |
-
label="Organization Name -
|
| 290 |
placeholder="Your Organization"
|
| 291 |
)
|
| 292 |
email_textbox = gr.Textbox(
|
| 293 |
-
label="Contact Email -
|
| 294 |
placeholder="contact@example.com"
|
| 295 |
)
|
| 296 |
with gr.Column():
|
| 297 |
file_upload = gr.File(
|
| 298 |
-
label="Upload SAGE Results (JSON)
|
| 299 |
file_types=[".json"],
|
| 300 |
type="filepath"
|
| 301 |
)
|
|
@@ -312,35 +312,35 @@ with demo:
|
|
| 312 |
try:
|
| 313 |
if profile and getattr(profile, "username", None):
|
| 314 |
name = profile.username
|
| 315 |
-
text = f"✅
|
| 316 |
else:
|
| 317 |
-
text = "❌
|
| 318 |
return profile, text
|
| 319 |
except Exception:
|
| 320 |
-
return None, "❌
|
| 321 |
login_button.click(on_login, inputs=[], outputs=[profile_state, login_status])
|
| 322 |
|
| 323 |
# 进度显示和结果显示区域
|
| 324 |
-
progress_info = gr.HTML()
|
| 325 |
-
submission_result = gr.HTML()
|
| 326 |
|
| 327 |
def show_progress(step, message, total_steps=4):
|
| 328 |
-
"""
|
| 329 |
progress_percentage = int((step / total_steps) * 100)
|
| 330 |
progress_html = f"""
|
| 331 |
<div style="background-color: #e7f3ff; border: 1px solid #4dabf7; border-radius: 5px; padding: 15px; margin: 10px 0;">
|
| 332 |
<div style="display: flex; align-items: center; margin-bottom: 10px;">
|
| 333 |
-
<h4 style="color: #1971c2; margin: 0; flex-grow: 1;">⏳
|
| 334 |
<span style="color: #1971c2; font-weight: bold;">{progress_percentage}%</span>
|
| 335 |
</div>
|
| 336 |
-
<p style="color: #1971c2; margin: 5px 0;"><strong
|
| 337 |
<div style="background-color: #fff; border-radius: 10px; height: 20px; margin: 10px 0; border: 1px solid #dee2e6;">
|
| 338 |
<div style="background: linear-gradient(90deg, #4dabf7, #74c0fc); height: 100%; width: {progress_percentage}%; border-radius: 10px; transition: width 0.5s ease; display: flex; align-items: center; justify-content: center;">
|
| 339 |
{f'<span style="color: white; font-size: 12px; font-weight: bold;">{progress_percentage}%</span>' if progress_percentage > 20 else ''}
|
| 340 |
</div>
|
| 341 |
</div>
|
| 342 |
<p style="color: #495057; font-size: 14px; margin: 5px 0;">
|
| 343 |
-
{'✨
|
| 344 |
</p>
|
| 345 |
</div>
|
| 346 |
"""
|
|
@@ -349,36 +349,36 @@ with demo:
|
|
| 349 |
def handle_submission(file_upload, org_name, email, user_profile, progress=gr.Progress()):
|
| 350 |
try:
|
| 351 |
# 步骤1: 基本验证
|
| 352 |
-
progress(0.1, desc="
|
| 353 |
-
yield show_progress(1, "
|
| 354 |
|
| 355 |
# 校验登录
|
| 356 |
if user_profile is None or getattr(user_profile, "username", None) is None:
|
| 357 |
-
yield "", format_error("
|
| 358 |
return
|
| 359 |
|
| 360 |
if not file_upload:
|
| 361 |
-
yield "", format_error("
|
| 362 |
return
|
| 363 |
if not org_name or not org_name.strip():
|
| 364 |
-
yield "", format_error("
|
| 365 |
return
|
| 366 |
if not email or not email.strip():
|
| 367 |
-
yield "", format_error("
|
| 368 |
return
|
| 369 |
|
| 370 |
# 验证邮箱格式
|
| 371 |
_, parsed_email = parseaddr(email)
|
| 372 |
if "@" not in parsed_email:
|
| 373 |
-
yield "", format_warning("
|
| 374 |
return
|
| 375 |
|
| 376 |
# 步骤2: 文件验证和读取
|
| 377 |
-
progress(0.3, desc="
|
| 378 |
-
yield show_progress(2, "
|
| 379 |
|
| 380 |
import time
|
| 381 |
-
time.sleep(0.5) #
|
| 382 |
|
| 383 |
# 用户资格检查(账号年龄/频率/重复提交)
|
| 384 |
eligible, msg = check_user_submission_eligibility(user_profile, org_name)
|
|
@@ -387,18 +387,18 @@ with demo:
|
|
| 387 |
return
|
| 388 |
|
| 389 |
# 步骤3: 上传到OSS
|
| 390 |
-
progress(0.6, desc="
|
| 391 |
-
yield show_progress(3, "
|
| 392 |
|
| 393 |
# 处理文件提交
|
| 394 |
from src.submission.simple_submit import process_sage_submission_simple
|
| 395 |
result = process_sage_submission_simple(file_upload, org_name, email)
|
| 396 |
|
| 397 |
# 步骤4: 完成
|
| 398 |
-
progress(1.0, desc="
|
| 399 |
-
yield show_progress(4, "
|
| 400 |
|
| 401 |
-
time.sleep(0.5) #
|
| 402 |
|
| 403 |
# 记录提交历史
|
| 404 |
try:
|
|
@@ -409,11 +409,11 @@ with demo:
|
|
| 409 |
# 生成成功信息
|
| 410 |
success_info = f"""
|
| 411 |
<div style="background-color: #d4edda; border: 1px solid #c3e6cb; border-radius: 5px; padding: 15px; margin: 10px 0;">
|
| 412 |
-
<h4 style="color: #155724; margin-top: 0;">🎉
|
| 413 |
-
<p style="color: #155724; margin: 5px 0;"><strong
|
| 414 |
-
<p style="color: #155724; margin: 5px 0;"><strong
|
| 415 |
-
<p style="color: #155724; margin: 5px 0;"><strong
|
| 416 |
-
<p style="color: #155724; margin-bottom: 0;"
|
| 417 |
</div>
|
| 418 |
"""
|
| 419 |
|
|
@@ -421,11 +421,11 @@ with demo:
|
|
| 421 |
yield "", success_info + result
|
| 422 |
|
| 423 |
except ImportError as e:
|
| 424 |
-
yield "", format_error(f"
|
| 425 |
except Exception as e:
|
| 426 |
import traceback
|
| 427 |
traceback.print_exc()
|
| 428 |
-
yield "", format_error(f"
|
| 429 |
|
| 430 |
submit_button.click(
|
| 431 |
handle_submission,
|
|
|
|
| 64 |
return model_name
|
| 65 |
|
| 66 |
def load_submission_history():
|
| 67 |
+
"""Load user submission history from OSS"""
|
| 68 |
try:
|
| 69 |
from src.oss.oss_file_manager import OSSFileManager
|
| 70 |
oss_manager = OSSFileManager()
|
| 71 |
|
| 72 |
+
# Try to download submission history file
|
| 73 |
history_content = oss_manager.download_file_content(
|
| 74 |
SUBMISSION_TRACKING_PATH + SUBMISSION_HISTORY_FILE
|
| 75 |
)
|
|
|
|
| 77 |
if history_content:
|
| 78 |
return json.loads(history_content)
|
| 79 |
else:
|
| 80 |
+
print("📝 Creating new submission history")
|
| 81 |
return {}
|
| 82 |
|
| 83 |
except Exception as e:
|
| 84 |
+
print(f"⚠️ Failed to load submission history: {e}")
|
| 85 |
return {}
|
| 86 |
|
| 87 |
def save_submission_history(history):
|
| 88 |
+
"""Save user submission history to OSS"""
|
| 89 |
try:
|
| 90 |
from src.oss.oss_file_manager import OSSFileManager
|
| 91 |
oss_manager = OSSFileManager()
|
| 92 |
|
| 93 |
+
# Upload submission history
|
| 94 |
history_json = json.dumps(history, indent=2, ensure_ascii=False)
|
| 95 |
success = oss_manager.upload_file_content(
|
| 96 |
content=history_json,
|
|
|
|
| 100 |
return success
|
| 101 |
|
| 102 |
except Exception as e:
|
| 103 |
+
print(f"❌ Failed to save submission history: {e}")
|
| 104 |
return False
|
| 105 |
|
| 106 |
def check_user_submission_eligibility(profile: gr.OAuthProfile, org_name: str):
|
| 107 |
+
"""Check user submission eligibility"""
|
| 108 |
try:
|
| 109 |
+
# 1. Check account age limit (60 days)
|
| 110 |
user_data = requests.get(f"https://huggingface.co/api/users/{profile.username}/overview")
|
| 111 |
if user_data.status_code == 200:
|
| 112 |
creation_date = json.loads(user_data.content)["createdAt"]
|
| 113 |
account_age = datetime.datetime.now() - datetime.datetime.strptime(creation_date, '%Y-%m-%dT%H:%M:%S.%fZ')
|
| 114 |
|
| 115 |
if account_age < datetime.timedelta(days=60):
|
| 116 |
+
return False, "This account does not meet the submission requirement. Account age must exceed 60 days."
|
| 117 |
else:
|
| 118 |
+
return False, "Unable to verify account information. Please try again later."
|
| 119 |
|
| 120 |
+
# 2. Check daily submission limit
|
| 121 |
submission_history = load_submission_history()
|
| 122 |
user_submissions = submission_history.get(profile.username, [])
|
| 123 |
|
| 124 |
today = datetime.datetime.today().strftime('%Y-%m-%d')
|
| 125 |
today_submissions = [s for s in user_submissions if s.get("date", "") == today]
|
| 126 |
|
| 127 |
+
if len(today_submissions) > 1:
|
| 128 |
+
return False, "You have already submitted twice today. Please try again tomorrow."
|
| 129 |
|
| 130 |
+
# 3. Check duplicate submission (organization + username)
|
| 131 |
for submission in user_submissions:
|
| 132 |
if submission.get("organization", "").lower() == org_name.lower():
|
| 133 |
+
return False, f"You have already submitted results for organization '{org_name}'. To update, please contact the administrator."
|
| 134 |
|
| 135 |
+
return True, "Eligibility check passed"
|
| 136 |
|
| 137 |
except Exception as e:
|
| 138 |
+
print(f"❌ User eligibility check failed: {e}")
|
| 139 |
+
return False, f"System check error, please try again later: {str(e)}"
|
| 140 |
|
| 141 |
def record_user_submission(profile: gr.OAuthProfile, org_name: str, email: str):
|
| 142 |
+
"""Record user submission"""
|
| 143 |
try:
|
| 144 |
submission_history = load_submission_history()
|
| 145 |
|
| 146 |
if profile.username not in submission_history:
|
| 147 |
submission_history[profile.username] = []
|
| 148 |
|
| 149 |
+
# Record this submission
|
| 150 |
submission_record = {
|
| 151 |
"date": datetime.datetime.today().strftime('%Y-%m-%d'),
|
| 152 |
"time": datetime.datetime.now().strftime('%H:%M:%S'),
|
|
|
|
| 157 |
|
| 158 |
submission_history[profile.username].append(submission_record)
|
| 159 |
|
| 160 |
+
# Save submission history
|
| 161 |
return save_submission_history(submission_history)
|
| 162 |
|
| 163 |
except Exception as e:
|
| 164 |
+
print(f"❌ Failed to record submission history: {e}")
|
| 165 |
return False
|
| 166 |
|
| 167 |
def get_leaderboard_dataframe():
|
|
|
|
| 231 |
# Main leaderboard table
|
| 232 |
gr.Markdown("## 🏆 SAGE Benchmark Results", elem_classes="markdown-text")
|
| 233 |
|
| 234 |
+
# Debug information - dynamic component
|
| 235 |
results_count = gr.Markdown(f"📊 **Showing {len(leaderboard_df)} results**")
|
| 236 |
|
| 237 |
leaderboard_table = gr.Dataframe(
|
|
|
|
| 246 |
refresh_button = gr.Button("🔄 Refresh Leaderboard")
|
| 247 |
|
| 248 |
def refresh_leaderboard_with_count():
|
| 249 |
+
"""Refresh leaderboard and update count display"""
|
| 250 |
df = refresh_leaderboard()
|
| 251 |
count_text = f"📊 **Showing {len(df)} results**"
|
| 252 |
return df, count_text
|
|
|
|
| 263 |
|
| 264 |
# 添加提交说明(登录要求暂时注释)
|
| 265 |
gr.Markdown("""
|
| 266 |
+
### 📋 Submission Requirements
|
| 267 |
<!--
|
| 268 |
+
- Login required: You must log in with a Hugging Face account
|
| 269 |
+
- Account age: Account must be older than 60 days
|
| 270 |
+
- Submission frequency: Each user can submit up to 2 times per day
|
| 271 |
-->
|
| 272 |
+
- File format: Upload a JSON file in the SAGE format
|
| 273 |
+
- Organization: Provide the exact organization name (shown on the leaderboard)
|
| 274 |
+
- Contact email: Provide a valid email for notifications
|
| 275 |
+
- Auto evaluation: After submission, the system will run LLM-based evaluation and update the leaderboard
|
| 276 |
|
| 277 |
<!--
|
| 278 |
+
### 🔐 Security Policy
|
| 279 |
+
To prevent spam and ensure evaluation quality, we enforce:
|
| 280 |
+
- New accounts must wait 60 days before submitting (prevents abuse)
|
| 281 |
+
- Daily submission limits to ensure leaderboard quality and system stability
|
| 282 |
+
- Duplicate checks to avoid multiple submissions for the same organization
|
| 283 |
-->
|
| 284 |
""", elem_classes="markdown-text")
|
| 285 |
|
| 286 |
with gr.Row():
|
| 287 |
with gr.Column():
|
| 288 |
org_textbox = gr.Textbox(
|
| 289 |
+
label="Organization Name - will be shown on the leaderboard",
|
| 290 |
placeholder="Your Organization"
|
| 291 |
)
|
| 292 |
email_textbox = gr.Textbox(
|
| 293 |
+
label="Contact Email - used for contact, not publicly visible",
|
| 294 |
placeholder="contact@example.com"
|
| 295 |
)
|
| 296 |
with gr.Column():
|
| 297 |
file_upload = gr.File(
|
| 298 |
+
label="Upload SAGE Results (JSON)",
|
| 299 |
file_types=[".json"],
|
| 300 |
type="filepath"
|
| 301 |
)
|
|
|
|
| 312 |
try:
|
| 313 |
if profile and getattr(profile, "username", None):
|
| 314 |
name = profile.username
|
| 315 |
+
text = f"✅ Logged in as: **{name}**"
|
| 316 |
else:
|
| 317 |
+
text = "❌ Login failed, please try again"
|
| 318 |
return profile, text
|
| 319 |
except Exception:
|
| 320 |
+
return None, "❌ Login failed, please try again"
|
| 321 |
login_button.click(on_login, inputs=[], outputs=[profile_state, login_status])
|
| 322 |
|
| 323 |
# 进度显示和结果显示区域
|
| 324 |
+
progress_info = gr.HTML()
|
| 325 |
+
submission_result = gr.HTML()
|
| 326 |
|
| 327 |
def show_progress(step, message, total_steps=4):
|
| 328 |
+
"""Show progress information"""
|
| 329 |
progress_percentage = int((step / total_steps) * 100)
|
| 330 |
progress_html = f"""
|
| 331 |
<div style="background-color: #e7f3ff; border: 1px solid #4dabf7; border-radius: 5px; padding: 15px; margin: 10px 0;">
|
| 332 |
<div style="display: flex; align-items: center; margin-bottom: 10px;">
|
| 333 |
+
<h4 style="color: #1971c2; margin: 0; flex-grow: 1;">⏳ Processing submission...</h4>
|
| 334 |
<span style="color: #1971c2; font-weight: bold;">{progress_percentage}%</span>
|
| 335 |
</div>
|
| 336 |
+
<p style="color: #1971c2; margin: 5px 0;"><strong>Step {step}/{total_steps}:</strong> {message}</p>
|
| 337 |
<div style="background-color: #fff; border-radius: 10px; height: 20px; margin: 10px 0; border: 1px solid #dee2e6;">
|
| 338 |
<div style="background: linear-gradient(90deg, #4dabf7, #74c0fc); height: 100%; width: {progress_percentage}%; border-radius: 10px; transition: width 0.5s ease; display: flex; align-items: center; justify-content: center;">
|
| 339 |
{f'<span style="color: white; font-size: 12px; font-weight: bold;">{progress_percentage}%</span>' if progress_percentage > 20 else ''}
|
| 340 |
</div>
|
| 341 |
</div>
|
| 342 |
<p style="color: #495057; font-size: 14px; margin: 5px 0;">
|
| 343 |
+
{'✨ Almost done, please wait...' if step >= total_steps else '📤 Please wait, processing your submission...'}
|
| 344 |
</p>
|
| 345 |
</div>
|
| 346 |
"""
|
|
|
|
| 349 |
def handle_submission(file_upload, org_name, email, user_profile, progress=gr.Progress()):
|
| 350 |
try:
|
| 351 |
# 步骤1: 基本验证
|
| 352 |
+
progress(0.1, desc="Validating submission info...")
|
| 353 |
+
yield show_progress(1, "Validating submission info"), ""
|
| 354 |
|
| 355 |
# 校验登录
|
| 356 |
if user_profile is None or getattr(user_profile, "username", None) is None:
|
| 357 |
+
yield "", format_error("Please log in with Hugging Face before submitting")
|
| 358 |
return
|
| 359 |
|
| 360 |
if not file_upload:
|
| 361 |
+
yield "", format_error("Please select a file to upload")
|
| 362 |
return
|
| 363 |
if not org_name or not org_name.strip():
|
| 364 |
+
yield "", format_error("Please enter organization name")
|
| 365 |
return
|
| 366 |
if not email or not email.strip():
|
| 367 |
+
yield "", format_error("Please enter email address")
|
| 368 |
return
|
| 369 |
|
| 370 |
# 验证邮箱格式
|
| 371 |
_, parsed_email = parseaddr(email)
|
| 372 |
if "@" not in parsed_email:
|
| 373 |
+
yield "", format_warning("Please provide a valid email address")
|
| 374 |
return
|
| 375 |
|
| 376 |
# 步骤2: 文件验证和读取
|
| 377 |
+
progress(0.3, desc="Validating file format...")
|
| 378 |
+
yield show_progress(2, "Validating file format and content"), ""
|
| 379 |
|
| 380 |
import time
|
| 381 |
+
time.sleep(0.5) # allow users to see progress update
|
| 382 |
|
| 383 |
# 用户资格检查(账号年龄/频率/重复提交)
|
| 384 |
eligible, msg = check_user_submission_eligibility(user_profile, org_name)
|
|
|
|
| 387 |
return
|
| 388 |
|
| 389 |
# 步骤3: 上传到OSS
|
| 390 |
+
progress(0.6, desc="Uploading file to OSS...")
|
| 391 |
+
yield show_progress(3, "Uploading file to OSS storage"), ""
|
| 392 |
|
| 393 |
# 处理文件提交
|
| 394 |
from src.submission.simple_submit import process_sage_submission_simple
|
| 395 |
result = process_sage_submission_simple(file_upload, org_name, email)
|
| 396 |
|
| 397 |
# 步骤4: 完成
|
| 398 |
+
progress(1.0, desc="Submission completed!")
|
| 399 |
+
yield show_progress(4, "Submission completed, preparing evaluation"), ""
|
| 400 |
|
| 401 |
+
time.sleep(0.5) # allow users to see completion state
|
| 402 |
|
| 403 |
# 记录提交历史
|
| 404 |
try:
|
|
|
|
| 409 |
# 生成成功信息
|
| 410 |
success_info = f"""
|
| 411 |
<div style="background-color: #d4edda; border: 1px solid #c3e6cb; border-radius: 5px; padding: 15px; margin: 10px 0;">
|
| 412 |
+
<h4 style="color: #155724; margin-top: 0;">🎉 Submission successful!</h4>
|
| 413 |
+
<p style="color: #155724; margin: 5px 0;"><strong>Organization:</strong> {org_name}</p>
|
| 414 |
+
<p style="color: #155724; margin: 5px 0;"><strong>Email:</strong> {email}</p>
|
| 415 |
+
<p style="color: #155724; margin: 5px 0;"><strong>Submitted at:</strong> {datetime.datetime.now().strftime('%Y-%m-%d %H:%M:%S')}</p>
|
| 416 |
+
<p style="color: #155724; margin-bottom: 0;">Your results have been submitted via OSS. LLM evaluation will complete in 5-10 minutes and the leaderboard will be updated.</p>
|
| 417 |
</div>
|
| 418 |
"""
|
| 419 |
|
|
|
|
| 421 |
yield "", success_info + result
|
| 422 |
|
| 423 |
except ImportError as e:
|
| 424 |
+
yield "", format_error(f"Submission system modules unavailable: {e}")
|
| 425 |
except Exception as e:
|
| 426 |
import traceback
|
| 427 |
traceback.print_exc()
|
| 428 |
+
yield "", format_error(f"An error occurred during submission: {str(e)}")
|
| 429 |
|
| 430 |
submit_button.click(
|
| 431 |
handle_submission,
|