Spaces:
Running
on
CPU Upgrade
Running
on
CPU Upgrade
Update app.py
Browse files
app.py
CHANGED
|
@@ -3,7 +3,6 @@ import subprocess
|
|
| 3 |
import sys
|
| 4 |
import os
|
| 5 |
import threading
|
| 6 |
-
import time
|
| 7 |
|
| 8 |
class Logger:
|
| 9 |
def __init__(self, filename):
|
|
@@ -25,21 +24,22 @@ class Logger:
|
|
| 25 |
log_file = "bigcodebench_output.log"
|
| 26 |
sys.stdout = Logger(log_file)
|
| 27 |
|
| 28 |
-
default_command = "bigcodebench.evaluate"
|
| 29 |
-
is_running = False
|
| 30 |
-
|
| 31 |
def generate_command(
|
| 32 |
jsonl_file, split, subset, save_pass_rate, parallel,
|
| 33 |
min_time_limit, max_as_limit, max_data_limit, max_stack_limit,
|
| 34 |
check_gt_only, no_gt
|
| 35 |
):
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
command.extend(["--samples", samples])
|
| 41 |
|
| 42 |
-
command
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
|
| 44 |
if save_pass_rate:
|
| 45 |
command.append("--save_pass_rate")
|
|
@@ -63,8 +63,6 @@ def generate_command(
|
|
| 63 |
return " ".join(command)
|
| 64 |
|
| 65 |
def run_bigcodebench(command):
|
| 66 |
-
global is_running
|
| 67 |
-
is_running = True
|
| 68 |
print(f"Executing command: {command}")
|
| 69 |
|
| 70 |
process = subprocess.Popen(command.split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
|
|
@@ -76,67 +74,54 @@ def run_bigcodebench(command):
|
|
| 76 |
|
| 77 |
if process.returncode != 0:
|
| 78 |
print(f"Error: Command exited with status {process.returncode}")
|
| 79 |
-
|
| 80 |
-
cleanup_command = "pids=$(ps -u $(id -u) -o pid,comm | grep 'bigcodebench' | awk '{print $1}'); if [ -n \"$pids\" ]; then echo $pids | xargs -r kill; fi; rm -rf /tmp/*"
|
| 81 |
-
subprocess.run(cleanup_command, shell=True, stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 82 |
-
|
| 83 |
-
is_running = False
|
| 84 |
|
| 85 |
def read_logs():
|
| 86 |
with open(log_file, "r") as f:
|
| 87 |
return f.read()
|
| 88 |
|
| 89 |
-
|
| 90 |
-
|
| 91 |
-
|
| 92 |
-
|
| 93 |
-
|
| 94 |
-
|
| 95 |
-
|
| 96 |
-
|
| 97 |
-
|
| 98 |
-
|
| 99 |
-
|
| 100 |
-
|
| 101 |
-
|
| 102 |
-
|
| 103 |
-
|
| 104 |
-
|
| 105 |
-
|
| 106 |
-
|
| 107 |
-
|
| 108 |
-
|
| 109 |
-
|
| 110 |
-
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
| 121 |
-
|
| 122 |
-
|
| 123 |
-
|
| 124 |
-
|
| 125 |
-
|
| 126 |
-
|
| 127 |
-
|
| 128 |
-
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
run_bigcodebench(command)
|
| 133 |
-
return read_logs()
|
| 134 |
-
|
| 135 |
-
return gr.update(value="Evaluation started. Please wait for the logs to update..."), gr.update(value=run_and_update)
|
| 136 |
-
|
| 137 |
-
submit_btn.click(on_submit, inputs=[command_output], outputs=[log_output, log_output])
|
| 138 |
-
|
| 139 |
-
demo.launch(server_name="0.0.0.0", server_port=7860)
|
| 140 |
|
| 141 |
if __name__ == "__main__":
|
| 142 |
-
|
|
|
|
| 3 |
import sys
|
| 4 |
import os
|
| 5 |
import threading
|
|
|
|
| 6 |
|
| 7 |
class Logger:
|
| 8 |
def __init__(self, filename):
|
|
|
|
| 24 |
log_file = "bigcodebench_output.log"
|
| 25 |
sys.stdout = Logger(log_file)
|
| 26 |
|
|
|
|
|
|
|
|
|
|
| 27 |
def generate_command(
|
| 28 |
jsonl_file, split, subset, save_pass_rate, parallel,
|
| 29 |
min_time_limit, max_as_limit, max_data_limit, max_stack_limit,
|
| 30 |
check_gt_only, no_gt
|
| 31 |
):
|
| 32 |
+
if jsonl_file is None:
|
| 33 |
+
return "Please upload a JSONL file"
|
| 34 |
+
|
| 35 |
+
samples = os.path.basename(jsonl_file.name)
|
|
|
|
| 36 |
|
| 37 |
+
command = [
|
| 38 |
+
"bigcodebench.evaluate",
|
| 39 |
+
"--split", split,
|
| 40 |
+
"--subset", subset,
|
| 41 |
+
"--samples", samples
|
| 42 |
+
]
|
| 43 |
|
| 44 |
if save_pass_rate:
|
| 45 |
command.append("--save_pass_rate")
|
|
|
|
| 63 |
return " ".join(command)
|
| 64 |
|
| 65 |
def run_bigcodebench(command):
|
|
|
|
|
|
|
| 66 |
print(f"Executing command: {command}")
|
| 67 |
|
| 68 |
process = subprocess.Popen(command.split(), stdout=subprocess.PIPE, stderr=subprocess.STDOUT, universal_newlines=True)
|
|
|
|
| 74 |
|
| 75 |
if process.returncode != 0:
|
| 76 |
print(f"Error: Command exited with status {process.returncode}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 77 |
|
| 78 |
def read_logs():
|
| 79 |
with open(log_file, "r") as f:
|
| 80 |
return f.read()
|
| 81 |
|
| 82 |
+
with gr.Blocks() as demo:
|
| 83 |
+
gr.Markdown("# BigCodeBench Evaluation App")
|
| 84 |
+
|
| 85 |
+
with gr.Row():
|
| 86 |
+
jsonl_file = gr.File(label="Upload JSONL file", file_types=[".jsonl"])
|
| 87 |
+
split = gr.Dropdown(choices=["complete", "instruct"], label="Split", value="complete")
|
| 88 |
+
subset = gr.Dropdown(choices=["full", "hard"], label="Subset", value="full")
|
| 89 |
+
|
| 90 |
+
with gr.Row():
|
| 91 |
+
save_pass_rate = gr.Checkbox(label="Save Pass Rate")
|
| 92 |
+
parallel = gr.Number(label="Parallel (optional)", precision=0)
|
| 93 |
+
min_time_limit = gr.Number(label="Min Time Limit", value=1, precision=1)
|
| 94 |
+
max_as_limit = gr.Number(label="Max AS Limit", value=128*1024, precision=0)
|
| 95 |
+
|
| 96 |
+
with gr.Row():
|
| 97 |
+
max_data_limit = gr.Number(label="Max Data Limit", value=4*1024, precision=0)
|
| 98 |
+
max_stack_limit = gr.Number(label="Max Stack Limit", value=5, precision=0)
|
| 99 |
+
check_gt_only = gr.Checkbox(label="Check GT Only")
|
| 100 |
+
no_gt = gr.Checkbox(label="No GT")
|
| 101 |
+
|
| 102 |
+
command_output = gr.Textbox(label="Command", lines=2)
|
| 103 |
+
submit_btn = gr.Button("Run Evaluation")
|
| 104 |
+
log_output = gr.Textbox(label="Execution Logs", lines=10)
|
| 105 |
+
|
| 106 |
+
def update_command(*args):
|
| 107 |
+
return generate_command(*args)
|
| 108 |
+
|
| 109 |
+
input_components = [
|
| 110 |
+
jsonl_file, split, subset, save_pass_rate, parallel,
|
| 111 |
+
min_time_limit, max_as_limit, max_data_limit, max_stack_limit,
|
| 112 |
+
check_gt_only, no_gt
|
| 113 |
+
]
|
| 114 |
+
|
| 115 |
+
for component in input_components:
|
| 116 |
+
component.change(update_command, inputs=input_components, outputs=command_output)
|
| 117 |
+
|
| 118 |
+
def on_submit(command):
|
| 119 |
+
threading.Thread(target=run_bigcodebench, args=(command,), daemon=True).start()
|
| 120 |
+
return "Evaluation started. Please wait for the logs to update..."
|
| 121 |
+
|
| 122 |
+
submit_btn.click(on_submit, inputs=[command_output], outputs=[log_output])
|
| 123 |
+
|
| 124 |
+
demo.load(read_logs, None, log_output, every=1)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
|
| 126 |
if __name__ == "__main__":
|
| 127 |
+
demo.queue().launch()
|