Spaces:
Sleeping
Sleeping
improvements
Browse files
app.py
CHANGED
@@ -18,7 +18,9 @@ baseline_ranker_options = []
|
|
18 |
run_ids = []
|
19 |
finder_options = []
|
20 |
finder_labels = {"All": "All Source Finders"}
|
|
|
21 |
|
|
|
22 |
|
23 |
# Get all questions
|
24 |
|
@@ -44,14 +46,20 @@ async def initialize_data():
|
|
44 |
baseline_ranker_labels = {str(f["id"]): f["name"] for f in source_finders}
|
45 |
|
46 |
|
47 |
-
def update_sources_list(question_option, source_finder_id, baseline_ranker_id: str, run_id: str):
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
return asyncio.run(update_sources_list_async(question_option, source_finder_id, baseline_ranker_id, run_id))
|
49 |
|
50 |
|
51 |
# Main function to handle UI interactions
|
52 |
async def update_sources_list_async(question_option, source_finder_id, baseline_ranker_id: str, run_id: str):
|
53 |
if not question_option:
|
54 |
-
return
|
55 |
|
56 |
# Extract question ID from selection
|
57 |
question_id = int(question_option.split(":")[0])
|
@@ -94,6 +102,7 @@ async def update_sources_list_async(question_option, source_finder_id, baseline_
|
|
94 |
|
95 |
# Ensure we clean up when done
|
96 |
async def main():
|
|
|
97 |
await initialize_data()
|
98 |
with gr.Blocks(title="Source Runs Explorer") as app:
|
99 |
gr.Markdown("# Source Runs Explorer")
|
@@ -107,13 +116,15 @@ async def main():
|
|
107 |
choices=question_options,
|
108 |
label="Select Question",
|
109 |
value=None,
|
110 |
-
interactive=True
|
|
|
111 |
)
|
112 |
with gr.Column(scale=1):
|
113 |
baseline_rankers_dropdown = gr.Dropdown(
|
114 |
choices=baseline_ranker_options,
|
115 |
label="Select Baseline Ranker",
|
116 |
-
interactive=True
|
|
|
117 |
)
|
118 |
|
119 |
with gr.Row():
|
@@ -121,7 +132,8 @@ async def main():
|
|
121 |
source_finder_dropdown = gr.Dropdown(
|
122 |
choices=finder_options,
|
123 |
label="Source Finder",
|
124 |
-
interactive=True
|
|
|
125 |
)
|
126 |
with gr.Column(scale=1):
|
127 |
run_id_dropdown = gr.Dropdown(
|
@@ -129,7 +141,8 @@ async def main():
|
|
129 |
value="1",
|
130 |
allow_custom_value=True,
|
131 |
label="Run id for Question and source finder",
|
132 |
-
interactive=True
|
|
|
133 |
)
|
134 |
|
135 |
result_text = gr.Markdown("Select a question to view source runs")
|
@@ -194,12 +207,6 @@ async def main():
|
|
194 |
outputs=[results_table, statistics_table, run_id_dropdown, result_text]
|
195 |
)
|
196 |
|
197 |
-
# Initial load of data when question is selected
|
198 |
-
question_dropdown.change(
|
199 |
-
update_sources_list,
|
200 |
-
inputs=[question_dropdown, source_finder_dropdown, run_id_dropdown, baseline_rankers_dropdown],
|
201 |
-
outputs=[results_table, statistics_table, run_id_dropdown, result_text]
|
202 |
-
)
|
203 |
|
204 |
app.queue()
|
205 |
app.launch()
|
|
|
18 |
run_ids = []
|
19 |
finder_options = []
|
20 |
finder_labels = {"All": "All Source Finders"}
|
21 |
+
previous_run_id = None
|
22 |
|
23 |
+
run_id_dropdown = None
|
24 |
|
25 |
# Get all questions
|
26 |
|
|
|
46 |
baseline_ranker_labels = {str(f["id"]): f["name"] for f in source_finders}
|
47 |
|
48 |
|
49 |
+
def update_sources_list(question_option, source_finder_id, baseline_ranker_id: str, run_id: str, evt: gr.EventData = None):
|
50 |
+
global previous_run_id
|
51 |
+
if evt and evt.target and evt.target.elem_id == "run_id_dropdown":
|
52 |
+
if run_id == previous_run_id:
|
53 |
+
return gr.update(), gr.update(), gr.update(), gr.update()
|
54 |
+
# Store the current run_id for future comparison
|
55 |
+
previous_run_id = run_id
|
56 |
return asyncio.run(update_sources_list_async(question_option, source_finder_id, baseline_ranker_id, run_id))
|
57 |
|
58 |
|
59 |
# Main function to handle UI interactions
|
60 |
async def update_sources_list_async(question_option, source_finder_id, baseline_ranker_id: str, run_id: str):
|
61 |
if not question_option:
|
62 |
+
return gr.update(), gr.update(), gr.update(), "No question selected"
|
63 |
|
64 |
# Extract question ID from selection
|
65 |
question_id = int(question_option.split(":")[0])
|
|
|
102 |
|
103 |
# Ensure we clean up when done
|
104 |
async def main():
|
105 |
+
global run_id_dropdown
|
106 |
await initialize_data()
|
107 |
with gr.Blocks(title="Source Runs Explorer") as app:
|
108 |
gr.Markdown("# Source Runs Explorer")
|
|
|
116 |
choices=question_options,
|
117 |
label="Select Question",
|
118 |
value=None,
|
119 |
+
interactive=True,
|
120 |
+
elem_id="question_dropdown"
|
121 |
)
|
122 |
with gr.Column(scale=1):
|
123 |
baseline_rankers_dropdown = gr.Dropdown(
|
124 |
choices=baseline_ranker_options,
|
125 |
label="Select Baseline Ranker",
|
126 |
+
interactive=True,
|
127 |
+
elem_id="baseline_rankers_dropdown"
|
128 |
)
|
129 |
|
130 |
with gr.Row():
|
|
|
132 |
source_finder_dropdown = gr.Dropdown(
|
133 |
choices=finder_options,
|
134 |
label="Source Finder",
|
135 |
+
interactive=True,
|
136 |
+
elem_id="source_finder_dropdown"
|
137 |
)
|
138 |
with gr.Column(scale=1):
|
139 |
run_id_dropdown = gr.Dropdown(
|
|
|
141 |
value="1",
|
142 |
allow_custom_value=True,
|
143 |
label="Run id for Question and source finder",
|
144 |
+
interactive=True,
|
145 |
+
elem_id="run_id_dropdown"
|
146 |
)
|
147 |
|
148 |
result_text = gr.Markdown("Select a question to view source runs")
|
|
|
207 |
outputs=[results_table, statistics_table, run_id_dropdown, result_text]
|
208 |
)
|
209 |
|
|
|
|
|
|
|
|
|
|
|
|
|
210 |
|
211 |
app.queue()
|
212 |
app.launch()
|