Spaces:
Runtime error
Runtime error
Update app.py
Browse files49 unmodified lines505152535453545556565758575859606129 unmodified lines9192939495969495969798102991001011021 unmodified line10410510611010710810917 unmodified lines1271281291341301311321371381391401331341351 unmodified line13713813914814014114215014314414514614714814915215015115215315615715815915415515615716116216316415815916016116616716216316416517016616717217349 unmodified lines return " ".join(command)
def cleanup_previous_files(jsonl_file=None): for file in glob.glob("*.json") + glob.glob("*.log") + glob.glob("*.jsonl"):def cleanup_previous_files(jsonl_file): file_list = ['Dockerfile', 'app.py', 'README.md', os.path.basename(jsonl_file.name), "__pycache__"] for file in glob.glob("*"): try: if jsonl_file is not None and file == jsonl_file: continue os.remove(file) if file not in file_list: os.remove(file) except Exception as e: print(f"Error during cleanup of {file}: {e}")
29 unmodified lines
def stream_logs(command, jsonl_file=None): global is_running local_filename = None if jsonl_file is not None: local_filename = os.path.basename(jsonl_file.name) if is_running: yield "A command is already running. Please wait for it to finish.\n" return cleanup_previous_files(local_filename) cleanup_previous_files(jsonl_file) yield "Cleaned up previous files.\n"
log_content = []1 unmodified line log_content.append(log_line) yield "".join(log_content)
with gr.Blocks() as demo: gr.Markdown("# BigCodeBench Evaluator") 17 unmodified lines command_output = gr.Textbox(label="Command", value=default_command, interactive=False) with gr.Row(): submit_btn = gr.Button("Run Evaluation") download_btn = gr.DownloadButton(label="Download Result", visible=False) download_btn = gr.DownloadButton(label="Download Result") log_output = gr.Textbox(label="Execution Logs", lines=20)
def update_command(*args): return generate_command(*args) input_components = [ jsonl_file, split, subset, save_pass_rate, parallel, min_time_limit, max_as_limit, max_data_limit, max_stack_limit,1 unmodified line ] for component in input_components: component.change(update_command, inputs=input_components, outputs=command_output) component.change(generate_command, inputs=input_components, outputs=command_output) def start_evaluation(command, jsonl_file): def start_evaluation(command, jsonl_file, subset, split): extra = subset + "_" if subset != "full" else "" result_path = os.path.basename(jsonl_file.name).replace(".jsonl", f"_{extra}eval_results.json") with open(result_path, "w") as f: f.write("")
for log in stream_logs(command, jsonl_file): yield log, gr.update(), gr.update() yield log, gr.update(value=result_path, label=result_path), gr.update() result_file = find_result_file() if result_file: print(f"Result file: {result_file}") return (gr.update(label="Evaluation completed. Result file found."), gr.Button(visible=False), gr.DownloadButton(label="Download Result", value=result_file, visible=True)) return gr.update(label="Evaluation completed. Result file found."), gr.update(value=result_file) # gr.Button(visible=False)#, # gr.DownloadButton(label="Download Result", value=result_file, visible=True)) else: return (gr.update(label="Evaluation completed. No result file found."), gr.Button("Run Evaluation", visible=True), gr.DownloadButton(visible=False))
return gr.update(label="Evaluation completed. No result file found."), gr.update(value=result_path) # gr.Button("Run Evaluation", visible=True), # gr.DownloadButton(visible=False)) submit_btn.click(start_evaluation, inputs=[command_output, jsonl_file], outputs=[log_output, submit_btn, download_btn]) inputs=[command_output, jsonl_file, subset, split], outputs=[log_output, download_btn])
if __name__ == "__main__": demo.queue(max_size=300).launch(server_name="0.0.0.0", server_port=7860) demo.queue(max_size=300).launch(share=True, server_name="0.0.0.0", server_port=7860) scheduler = BackgroundScheduler() scheduler.add_job(restart_space, "interval", hours=3) # restarted every 3h as backup in case automatic updates are not working scheduler.start()app.py+25-31