wuyangchen commited on
Commit
e4faaaa
·
verified ·
1 Parent(s): 16a9218

add arklib and fix bug

Browse files
Files changed (1) hide show
  1. app.py +81 -1
app.py CHANGED
@@ -2036,4 +2036,84 @@ with gr.Blocks(
2036
  label="Lean code",
2037
  )
2038
  play_btn = gr.Button("Run", variant="primary")
2039
- play_out = gr.Textbox(label="Output", lines=16, max_lines=40)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2036
  label="Lean code",
2037
  )
2038
  play_btn = gr.Button("Run", variant="primary")
2039
+ play_out = gr.Textbox(label="Output", lines=16, max_lines=40)
2040
+ play_btn.click(
2041
+ run_lean,
2042
+ play_code,
2043
+ play_out,
2044
+ concurrency_id="lean",
2045
+ concurrency_limit=1,
2046
+ api_name="run_lean",
2047
+ )
2048
+
2049
+ home_lb_btn.click(lambda: _select_tab("leaderboard"), outputs=app_tabs, api_name=False)
2050
+ home_submit_btn.click(lambda: _select_tab("submit"), outputs=app_tabs, api_name=False)
2051
+
2052
+ submit_btn.click(
2053
+ verify_and_submit,
2054
+ [user_in, file_in],
2055
+ [progress_df, submit_status],
2056
+ api_name="verify_and_submit",
2057
+ )
2058
+
2059
+ refresh_btn.click(_leaderboard_html, None, lb_table, api_name="leaderboard")
2060
+
2061
+ # Poll the persisted submission status for whatever username is in the box.
2062
+ # Works regardless of who submitted or when — tab close / browser disconnect
2063
+ # has no effect on the underlying worker thread.
2064
+ gr.Timer(value=15).tick(
2065
+ submission_status,
2066
+ inputs=[user_in],
2067
+ outputs=[progress_df, submit_status],
2068
+ )
2069
+
2070
+ # Auto-refresh the leaderboard so finished submissions appear without
2071
+ # the user having to click Refresh.
2072
+ gr.Timer(value=60).tick(_leaderboard_html, outputs=lb_table)
2073
+
2074
+ # Populate the leaderboard + home front-runners on every page load. The
2075
+ # `value=` baked into the components is only the build-time snapshot served
2076
+ # to every browser; without these the page shows that stale/empty snapshot
2077
+ # until a timer ticks. Both refresh fns re-read the bucket file first, so a
2078
+ # fresh visitor immediately sees the current standings.
2079
+ demo.load(_leaderboard_html, outputs=lb_table)
2080
+ demo.load(refresh_home, outputs=home_body)
2081
+
2082
+ # Hidden admin endpoints — gated by env-var ADMIN_RESET_TOKEN.
2083
+ _admin_tok = gr.Textbox(visible=False)
2084
+ _admin_out = gr.Textbox(visible=False)
2085
+ _admin_btn = gr.Button(visible=False)
2086
+ _admin_btn.click(admin_reset, _admin_tok, _admin_out, api_name="admin_reset")
2087
+
2088
+ _cl_tok = gr.Textbox(visible=False)
2089
+ _cl_user = gr.Textbox(visible=False)
2090
+ _cl_sid = gr.Textbox(visible=False)
2091
+ _cl_out = gr.Textbox(visible=False)
2092
+ _cl_btn = gr.Button(visible=False)
2093
+ _cl_btn.click(
2094
+ compat_list, [_cl_tok, _cl_user, _cl_sid], _cl_out,
2095
+ api_name="compat_list",
2096
+ )
2097
+
2098
+ _log_tok = gr.Textbox(visible=False)
2099
+ _log_user = gr.Textbox(visible=False)
2100
+ _log_sid = gr.Textbox(visible=False)
2101
+ _log_name = gr.Textbox(visible=False)
2102
+ _log_ver = gr.Textbox(visible=False)
2103
+ _log_out = gr.Textbox(visible=False)
2104
+ _log_btn = gr.Button(visible=False)
2105
+ _log_btn.click(
2106
+ compat_log,
2107
+ [_log_tok, _log_user, _log_sid, _log_name, _log_ver],
2108
+ _log_out,
2109
+ api_name="compat_log",
2110
+ )
2111
+
2112
+
2113
+ if __name__ == "__main__":
2114
+ demo.queue(default_concurrency_limit=None).launch(
2115
+ server_name="0.0.0.0",
2116
+ server_port=int(os.environ.get("GRADIO_SERVER_PORT", "7860")),
2117
+ allowed_paths=[BENCHMARK_JSONL_PATH, str(SPONSOR_ASSETS_DIR)],
2118
+ favicon_path=str(APP_ICON_PATH),
2119
+ )