Terry Zhuo
commited on
Commit
·
1a1b9bb
1
Parent(s):
cfd6a6e
update
Browse files- README.md +2 -2
- __pycache__/app.cpython-310.pyc +0 -0
- app.py +10 -23
README.md
CHANGED
@@ -1,6 +1,6 @@
|
|
1 |
---
|
2 |
-
title:
|
3 |
-
emoji:
|
4 |
colorFrom: indigo
|
5 |
colorTo: indigo
|
6 |
sdk: docker
|
|
|
1 |
---
|
2 |
+
title: BigCodeBench Evaluator
|
3 |
+
emoji: 💻
|
4 |
colorFrom: indigo
|
5 |
colorTo: indigo
|
6 |
sdk: docker
|
__pycache__/app.cpython-310.pyc
ADDED
Binary file (4.75 kB). View file
|
|
app.py
CHANGED
@@ -8,23 +8,7 @@ import uuid
|
|
8 |
import glob
|
9 |
import shutil
|
10 |
from pathlib import Path
|
11 |
-
|
12 |
-
class Logger:
|
13 |
-
def __init__(self, filename):
|
14 |
-
self.terminal = sys.stdout
|
15 |
-
self.log = open(filename, "w")
|
16 |
-
|
17 |
-
def write(self, message):
|
18 |
-
self.terminal.write(message)
|
19 |
-
self.log.write(message)
|
20 |
-
self.log.flush()
|
21 |
-
|
22 |
-
def flush(self):
|
23 |
-
self.terminal.flush()
|
24 |
-
self.log.flush()
|
25 |
-
|
26 |
-
def isatty(self):
|
27 |
-
return False
|
28 |
|
29 |
default_command = "bigcodebench.evaluate"
|
30 |
is_running = False
|
@@ -91,7 +75,7 @@ def run_bigcodebench(command):
|
|
91 |
for line in process.stdout:
|
92 |
yield line
|
93 |
|
94 |
-
|
95 |
|
96 |
if process.returncode != 0:
|
97 |
yield f"Error: Command exited with status {process.returncode}\n"
|
@@ -107,12 +91,14 @@ def run_bigcodebench(command):
|
|
107 |
|
108 |
def stream_logs(command, jsonl_file=None):
|
109 |
global is_running
|
|
|
110 |
if jsonl_file is not None:
|
111 |
local_filename = os.path.basename(jsonl_file.name)
|
|
|
112 |
if is_running:
|
113 |
yield "A command is already running. Please wait for it to finish.\n"
|
114 |
return
|
115 |
-
|
116 |
cleanup_previous_files(local_filename)
|
117 |
yield "Cleaned up previous files.\n"
|
118 |
|
@@ -148,8 +134,6 @@ with gr.Blocks() as demo:
|
|
148 |
download_btn = gr.DownloadButton(label="Download Result", visible=False)
|
149 |
log_output = gr.Textbox(label="Execution Logs", lines=20)
|
150 |
|
151 |
-
# Hidden component to store the result file path
|
152 |
-
# result_file_path = gr.State("")
|
153 |
|
154 |
def update_command(*args):
|
155 |
return generate_command(*args)
|
@@ -172,7 +156,7 @@ with gr.Blocks() as demo:
|
|
172 |
print(f"Result file: {result_file}")
|
173 |
return (gr.update(label="Evaluation completed. Result file found."),
|
174 |
gr.Button(visible=False),
|
175 |
-
gr.DownloadButton("Download Result", value=result_file, visible=True))
|
176 |
else:
|
177 |
return (gr.update(label="Evaluation completed. No result file found."),
|
178 |
gr.Button("Run Evaluation", visible=True),
|
@@ -183,4 +167,7 @@ with gr.Blocks() as demo:
|
|
183 |
outputs=[log_output, submit_btn, download_btn])
|
184 |
|
185 |
if __name__ == "__main__":
|
186 |
-
demo.queue(max_size=300).launch(server_name="0.0.0.0", server_port=7860)
|
|
|
|
|
|
|
|
8 |
import glob
|
9 |
import shutil
|
10 |
from pathlib import Path
|
11 |
+
from apscheduler.schedulers.background import BackgroundScheduler
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
|
13 |
default_command = "bigcodebench.evaluate"
|
14 |
is_running = False
|
|
|
75 |
for line in process.stdout:
|
76 |
yield line
|
77 |
|
78 |
+
process.wait()
|
79 |
|
80 |
if process.returncode != 0:
|
81 |
yield f"Error: Command exited with status {process.returncode}\n"
|
|
|
91 |
|
92 |
def stream_logs(command, jsonl_file=None):
|
93 |
global is_running
|
94 |
+
local_filename = None
|
95 |
if jsonl_file is not None:
|
96 |
local_filename = os.path.basename(jsonl_file.name)
|
97 |
+
|
98 |
if is_running:
|
99 |
yield "A command is already running. Please wait for it to finish.\n"
|
100 |
return
|
101 |
+
|
102 |
cleanup_previous_files(local_filename)
|
103 |
yield "Cleaned up previous files.\n"
|
104 |
|
|
|
134 |
download_btn = gr.DownloadButton(label="Download Result", visible=False)
|
135 |
log_output = gr.Textbox(label="Execution Logs", lines=20)
|
136 |
|
|
|
|
|
137 |
|
138 |
def update_command(*args):
|
139 |
return generate_command(*args)
|
|
|
156 |
print(f"Result file: {result_file}")
|
157 |
return (gr.update(label="Evaluation completed. Result file found."),
|
158 |
gr.Button(visible=False),
|
159 |
+
gr.DownloadButton(label="Download Result", value=result_file, visible=True))
|
160 |
else:
|
161 |
return (gr.update(label="Evaluation completed. No result file found."),
|
162 |
gr.Button("Run Evaluation", visible=True),
|
|
|
167 |
outputs=[log_output, submit_btn, download_btn])
|
168 |
|
169 |
if __name__ == "__main__":
|
170 |
+
demo.queue(max_size=300).launch(server_name="0.0.0.0", server_port=7860)
|
171 |
+
scheduler = BackgroundScheduler()
|
172 |
+
scheduler.add_job(restart_space, "interval", hours=3) # restarted every 3h as backup in case automatic updates are not working
|
173 |
+
scheduler.start()
|