terryyz commited on
Commit
ab1a0c8
1 Parent(s): 4c2c8e2

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -0
app.py CHANGED
@@ -18,6 +18,10 @@ from bigcodebench.data import get_bigcodebench, get_bigcodebench_hash, load_solu
18
  from bigcodebench.data.utils import CACHE_DIR
19
  from bigcodebench.eval import PASS, compatible_eval_result, estimate_pass_at_k, untrusted_check
20
  from bigcodebench.gen.util import trusted_check
 
 
 
 
21
 
22
  Result = Tuple[str, List[bool]]
23
 
@@ -251,6 +255,22 @@ def run_gradio():
251
  interface.queue(default_concurrency_limit=None)
252
  interface.launch(show_error=True)
253
 
 
 
 
 
 
 
 
 
 
 
 
254
  if __name__ == "__main__":
255
  run_gradio()
 
 
 
 
 
256
  # evaluate("complete", "hard", "meta-llama--Llama-3.2-3B-Instruct--bigcodebench-instruct--vllm-0-1.jsonl")
 
18
  from bigcodebench.data.utils import CACHE_DIR
19
  from bigcodebench.eval import PASS, compatible_eval_result, estimate_pass_at_k, untrusted_check
20
  from bigcodebench.gen.util import trusted_check
21
+ from apscheduler.schedulers.background import BackgroundScheduler
22
+
23
+ REPO_ID = "bigcode/bigcodebench-evaluator"
24
+ HF_TOKEN = os.environ.get("HF_TOKEN", None)
25
 
26
  Result = Tuple[str, List[bool]]
27
 
 
255
  interface.queue(default_concurrency_limit=None)
256
  interface.launch(show_error=True)
257
 
258
+
259
+ def restart_space():
260
+ logging.info(f"Restarting space with repo ID: {REPO_ID}")
261
+ try:
262
+ # Now restart the space
263
+ API.restart_space(repo_id=REPO_ID, token=HF_TOKEN)
264
+ logging.info("Space restarted successfully.")
265
+ except Exception as e:
266
+ logging.error(f"Failed to restart space: {e}")
267
+
268
+
269
  if __name__ == "__main__":
270
  run_gradio()
271
+
272
+ scheduler = BackgroundScheduler()
273
+ scheduler.add_job(restart_space, "interval", hours=1) # Restart every 1h
274
+ logging.info("Scheduler initialized to restart space every 1 hour.")
275
+ scheduler.start()
276
  # evaluate("complete", "hard", "meta-llama--Llama-3.2-3B-Instruct--bigcodebench-instruct--vllm-0-1.jsonl")