Terry Zhuo
commited on
Commit
·
17dce22
1
Parent(s):
071ce9f
add lock
Browse files
app.py
CHANGED
@@ -3,12 +3,14 @@ import logging
|
|
3 |
import time
|
4 |
import datetime
|
5 |
import gradio as gr
|
6 |
-
from threading import Thread
|
7 |
import datasets
|
8 |
from huggingface_hub import snapshot_download, WebhooksServer, WebhookPayload, RepoCard
|
9 |
from gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumns
|
10 |
from apscheduler.schedulers.background import BackgroundScheduler
|
11 |
|
|
|
|
|
12 |
# Start ephemeral Spaces on PRs (see config in README.md)
|
13 |
from gradio_space_ci.webhook import IS_EPHEMERAL_SPACE, SPACE_ID, configure_space_ci
|
14 |
|
@@ -557,26 +559,30 @@ with main_block as demo:
|
|
557 |
|
558 |
|
559 |
def start_evaluation(command, jsonl_file, subset, split):
|
560 |
-
|
561 |
-
|
562 |
-
|
563 |
-
|
564 |
-
|
565 |
-
|
566 |
-
|
567 |
-
|
568 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
569 |
else:
|
570 |
-
|
571 |
-
|
572 |
-
|
573 |
-
|
574 |
-
|
575 |
-
# gr.DownloadButton(label="Download Result", value=result_file, visible=True))
|
576 |
-
else:
|
577 |
-
return gr.update(label="Evaluation completed. No result file found."), gr.update(value=result_path)
|
578 |
-
# gr.Button("Run Evaluation", visible=True),
|
579 |
-
# gr.DownloadButton(visible=False))
|
580 |
submit_btn.click(start_evaluation,
|
581 |
inputs=[command_output, jsonl_file, subset, split],
|
582 |
outputs=[log_output, download_btn, submit_btn])
|
|
|
3 |
import time
|
4 |
import datetime
|
5 |
import gradio as gr
|
6 |
+
from threading import Thread, Lock
|
7 |
import datasets
|
8 |
from huggingface_hub import snapshot_download, WebhooksServer, WebhookPayload, RepoCard
|
9 |
from gradio_leaderboard import Leaderboard, ColumnFilter, SelectColumns
|
10 |
from apscheduler.schedulers.background import BackgroundScheduler
|
11 |
|
12 |
+
lock = Lock()
|
13 |
+
|
14 |
# Start ephemeral Spaces on PRs (see config in README.md)
|
15 |
from gradio_space_ci.webhook import IS_EPHEMERAL_SPACE, SPACE_ID, configure_space_ci
|
16 |
|
|
|
559 |
|
560 |
|
561 |
def start_evaluation(command, jsonl_file, subset, split):
|
562 |
+
lock.acquire()
|
563 |
+
try:
|
564 |
+
extra = subset + "_" if subset != "full" else ""
|
565 |
+
if jsonl_file is not None:
|
566 |
+
result_path = os.path.basename(jsonl_file.name).replace(".jsonl", f"_{extra}eval_results.json")
|
567 |
+
else:
|
568 |
+
result_path = None
|
569 |
+
|
570 |
+
for log in stream_logs(command, jsonl_file):
|
571 |
+
if jsonl_file is not None and jsonl_file.name.endswith(".jsonl"):
|
572 |
+
yield log, gr.update(value=result_path, label=result_path, visible=True), gr.update(visible=False)
|
573 |
+
else:
|
574 |
+
yield log, gr.update(), gr.update()
|
575 |
+
result_file = find_result_file()
|
576 |
+
if result_file:
|
577 |
+
return gr.update(label="Evaluation completed. Result file found."), gr.update(value=result_file)
|
578 |
+
# gr.Button(visible=False)#,
|
579 |
+
# gr.DownloadButton(label="Download Result", value=result_file, visible=True))
|
580 |
else:
|
581 |
+
return gr.update(label="Evaluation completed. No result file found."), gr.update(value=result_path)
|
582 |
+
# gr.Button("Run Evaluation", visible=True),
|
583 |
+
# gr.DownloadButton(visible=False))
|
584 |
+
finally:
|
585 |
+
lock.release()
|
|
|
|
|
|
|
|
|
|
|
586 |
submit_btn.click(start_evaluation,
|
587 |
inputs=[command_output, jsonl_file, subset, split],
|
588 |
outputs=[log_output, download_btn, submit_btn])
|