Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -430,7 +430,7 @@ def save_all_results_to_file(all_results, user_data, count_data=None):
|
|
430 |
try:
|
431 |
api = HfApi()
|
432 |
|
433 |
-
#
|
434 |
api.upload_file(
|
435 |
path_or_fileobj=bytes(json_string, "utf-8"),
|
436 |
path_in_repo=f"submissions/{submission_filename}",
|
@@ -441,21 +441,6 @@ def save_all_results_to_file(all_results, user_data, count_data=None):
|
|
441 |
)
|
442 |
print(f"上传成功: {submission_filename}")
|
443 |
|
444 |
-
# 上传 count.json(如果提供)
|
445 |
-
"""if count_data:
|
446 |
-
with open(COUNT_JSON_PATH, "w", encoding="utf-8") as f:
|
447 |
-
json.dump(count_data, f, indent=4, ensure_ascii=False)
|
448 |
-
|
449 |
-
api.upload_file(
|
450 |
-
path_or_fileobj=COUNT_JSON_PATH,
|
451 |
-
path_in_repo=COUNT_JSON_REPO_PATH,
|
452 |
-
repo_id=repo_id,
|
453 |
-
repo_type="dataset",
|
454 |
-
token=hf_token,
|
455 |
-
commit_message=f"Update count.json after submission by {username}"
|
456 |
-
)
|
457 |
-
print("count.json 上传成功")"""
|
458 |
-
|
459 |
if count_data:
|
460 |
with FileLock(COUNT_JSON_PATH + ".lock", timeout=10):
|
461 |
with open(COUNT_JSON_PATH, "w", encoding="utf-8") as f:
|
@@ -480,6 +465,12 @@ def toggle_reference_view(current):
|
|
480 |
else:
|
481 |
return gr.update(visible=True), gr.update(visible=False), gr.update(value="参考")
|
482 |
|
|
|
|
|
|
|
|
|
|
|
|
|
483 |
def back_to_welcome():
|
484 |
return (
|
485 |
gr.update(visible=True), # welcome_page
|
|
|
430 |
try:
|
431 |
api = HfApi()
|
432 |
|
433 |
+
# Upload submission file
|
434 |
api.upload_file(
|
435 |
path_or_fileobj=bytes(json_string, "utf-8"),
|
436 |
path_in_repo=f"submissions/{submission_filename}",
|
|
|
441 |
)
|
442 |
print(f"上传成功: {submission_filename}")
|
443 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
444 |
if count_data:
|
445 |
with FileLock(COUNT_JSON_PATH + ".lock", timeout=10):
|
446 |
with open(COUNT_JSON_PATH, "w", encoding="utf-8") as f:
|
|
|
465 |
else:
|
466 |
return gr.update(visible=True), gr.update(visible=False), gr.update(value="参考")
|
467 |
|
468 |
+
def toggle_slider(null_checked, slider_value):
|
469 |
+
if null_checked:
|
470 |
+
return gr.update(interactivate=False), gr.update(value=0) # Disable slider
|
471 |
+
else:
|
472 |
+
return gr.update(interactive=True), gr.update(value=slider_value or 3) # Restore previous of default slider
|
473 |
+
|
474 |
def back_to_welcome():
|
475 |
return (
|
476 |
gr.update(visible=True), # welcome_page
|