Terry Zhuo commited on
Commit ·
1a1b9bb
1
Parent(s): cfd6a6e
update
Browse filesFiles changed (3)
- README.md+2-2
- __pycache__/app.cpython-310.pycAdded
- app.py+10-23
123456---title: Bigcodebench Evaluatoremoji: 📈colorFrom: indigocolorTo: indigosdk: docker123456---title: BigCodeBench Evaluatoremoji: 💻colorFrom: indigocolorTo: indigosdk: docker
7 unmodified lines8910111213141516171819202122232425262728293060 unmodified lines919293949596979 unmodified lines10710810911011111211311411511611711829 unmodified lines14814915015115215315415516 unmodified lines1721731741751761771784 unmodified lines1831841851867 unmodified linesimport globimport shutilfrom pathlib import Pathclass Logger:def __init__(self, filename):self.terminal = sys.stdoutself.log = open(filename, "w")def write(self, message):self.terminal.write(message)self.log.write(message)self.log.flush()def flush(self):self.terminal.flush()self.log.flush()def isatty(self):return Falsedefault_command = "bigcodebench.evaluate"is_running = False60 unmodified linesfor line in process.stdout:yield line# process.wait()if process.returncode != 0:yield f"Error: Command exited with status {process.returncode}\n"9 unmodified linesdef stream_logs(command, jsonl_file=None):global is_runningif 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"returncleanup_previous_files(local_filename)yield "Cleaned up previous files.\n"29 unmodified linesdownload_btn = gr.DownloadButton(label="Download Result", visible=False)log_output = gr.Textbox(label="Execution Logs", lines=20)# Hidden component to store the result file path# result_file_path = gr.State("")def update_command(*args):return generate_command(*args)16 unmodified linesprint(f"Result file: {result_file}")return (gr.update(label="Evaluation completed. Result file found."),gr.Button(visible=False),gr.DownloadButton("Download Result", value=result_file, visible=True))else:return (gr.update(label="Evaluation completed. No result file found."),gr.Button("Run Evaluation", visible=True),4 unmodified linesoutputs=[log_output, submit_btn, download_btn])if __name__ == "__main__":demo.queue(max_size=300).launch(server_name="0.0.0.0", server_port=7860)7 unmodified lines89101112131460 unmodified lines757677787980819 unmodified lines91929394959697989910010110210310429 unmodified lines13413513613713813916 unmodified lines1561571581591601611624 unmodified lines1671681691701711721737 unmodified linesimport globimport shutilfrom pathlib import Pathfrom apscheduler.schedulers.background import BackgroundSchedulerdefault_command = "bigcodebench.evaluate"is_running = False60 unmodified linesfor line in process.stdout:yield lineprocess.wait()if process.returncode != 0:yield f"Error: Command exited with status {process.returncode}\n"9 unmodified linesdef stream_logs(command, jsonl_file=None):global is_runninglocal_filename = Noneif 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"returncleanup_previous_files(local_filename)yield "Cleaned up previous files.\n"29 unmodified linesdownload_btn = gr.DownloadButton(label="Download Result", visible=False)log_output = gr.Textbox(label="Execution Logs", lines=20)def update_command(*args):return generate_command(*args)16 unmodified linesprint(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))else:return (gr.update(label="Evaluation completed. No result file found."),gr.Button("Run Evaluation", visible=True),4 unmodified linesoutputs=[log_output, submit_btn, download_btn])if __name__ == "__main__":demo.queue(max_size=300).launch(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 workingscheduler.start()
README.md+2-2
__pycache__/app.cpython-310.pycAdded
app.py+10-23