Lakoc commited on
Commit
bbb5601
β€’
1 Parent(s): cdc057d

v0.0.4 fix of app reload state cached

Browse files
Files changed (1) hide show
  1. app.py +12 -3
app.py CHANGED
@@ -4,6 +4,7 @@ import gradio as gr
4
  import pandas as pd
5
  from gradio.themes.utils.sizes import text_md
6
  from gradio_modal import Modal
 
7
  from content import (HEADER_MARKDOWN, LEADERBOARD_TAB_TITLE_MARKDOWN, SUBMISSION_TAB_TITLE_MARKDOWN,
8
  MODAL_SUBMIT_MARKDOWN,
9
  SUBMISSION_DETAILS_MARKDOWN, RANKING_AFTER_SUBMISSION_MARKDOWN, MORE_DETAILS_MARKDOWN)
@@ -75,9 +76,15 @@ def hide_modal():
75
  return gr.update(visible=False)
76
 
77
 
78
- with (gr.Blocks(theme=gr.themes.Soft(text_size=text_md), css="footer {visibility: hidden}") as main):
79
- app_state = gr.State({})
 
 
 
 
 
80
 
 
81
  with gr.Row():
82
  with gr.Row():
83
  gr.Markdown(HEADER_MARKDOWN)
@@ -137,6 +144,7 @@ with (gr.Blocks(theme=gr.themes.Soft(text_size=text_md), css="footer {visibility
137
 
138
  pre_submission_btn.click(
139
  fn=on_submit_pressed,
 
140
  outputs=[pre_submission_btn]
141
  ).then(
142
  fn=process_submission,
@@ -167,5 +175,6 @@ with (gr.Blocks(theme=gr.themes.Soft(text_size=text_md), css="footer {visibility
167
  outputs=[pre_submission_btn, submission_btn_yes, submission_btn_no, submit_prompt, pre_submit_info,
168
  pre_submit_table]
169
  )
 
170
 
171
- main.launch()
 
4
  import pandas as pd
5
  from gradio.themes.utils.sizes import text_md
6
  from gradio_modal import Modal
7
+
8
  from content import (HEADER_MARKDOWN, LEADERBOARD_TAB_TITLE_MARKDOWN, SUBMISSION_TAB_TITLE_MARKDOWN,
9
  MODAL_SUBMIT_MARKDOWN,
10
  SUBMISSION_DETAILS_MARKDOWN, RANKING_AFTER_SUBMISSION_MARKDOWN, MORE_DETAILS_MARKDOWN)
 
76
  return gr.update(visible=False)
77
 
78
 
79
+ def on_application_load():
80
+ leaderboard_server.save_pre_submit()
81
+ leaderboard_server.update_leaderboard()
82
+ return gr.DataFrame(
83
+ value=leaderboard_server.get_leaderboard(), visible=True), gr.update(
84
+ choices=leaderboard_server.submission_ids)
85
+
86
 
87
+ with (gr.Blocks(theme=gr.themes.Soft(text_size=text_md), css="footer {visibility: hidden}") as main):
88
  with gr.Row():
89
  with gr.Row():
90
  gr.Markdown(HEADER_MARKDOWN)
 
144
 
145
  pre_submission_btn.click(
146
  fn=on_submit_pressed,
147
+ concurrency_limit=1,
148
  outputs=[pre_submission_btn]
149
  ).then(
150
  fn=process_submission,
 
175
  outputs=[pre_submission_btn, submission_btn_yes, submission_btn_no, submit_prompt, pre_submit_info,
176
  pre_submit_table]
177
  )
178
+ main.load(on_application_load, inputs=None, outputs=[results_table, detail_dropdown])
179
 
180
+ main.launch()