Spaces:
Runtime error
Runtime error
empty text in text field when switching things
Browse files
app.py
CHANGED
|
@@ -58,7 +58,7 @@ async def update_run_ids_async(question_option, source_finder_name, baseline_ran
|
|
| 58 |
available_run_id_dict = await get_run_ids(conn, finder_id_int)
|
| 59 |
run_id_options = list(available_run_id_dict.keys())
|
| 60 |
return gr.Dropdown(choices=[]), None, None, gr.Dropdown(choices=run_id_options,
|
| 61 |
-
value=None), "Select Question to see results.csv", ""
|
| 62 |
|
| 63 |
|
| 64 |
def update_questions_list(source_finder_name, run_id, baseline_ranker_name):
|
|
@@ -72,9 +72,9 @@ async def update_questions_list_async(source_finder_name, run_id, baseline_ranke
|
|
| 72 |
run_id_int = available_run_id_dict.get(run_id)
|
| 73 |
baseline_ranker_id = baseline_rankers_dict.get(baseline_ranker_name)
|
| 74 |
questions = await get_updated_question_list(conn, baseline_ranker_id, run_id_int)
|
| 75 |
-
return gr.Dropdown(choices=questions, value=None), None, None, None, None
|
| 76 |
else:
|
| 77 |
-
return None, None, None, None, None
|
| 78 |
|
| 79 |
|
| 80 |
async def get_updated_question_list(conn, baseline_ranker_id, finder_id_int):
|
|
@@ -105,9 +105,9 @@ def update_sources_list(question_option, source_finder_id, run_id: str, baseline
|
|
| 105 |
async def update_sources_list_async(question_option, source_finder_name, run_id, baseline_ranker_name: str):
|
| 106 |
global available_run_id_dict, previous_run_id, questions_dict
|
| 107 |
if not question_option:
|
| 108 |
-
return gr.skip(), gr.skip(), "No question selected", ""
|
| 109 |
if not source_finder_name or not run_id or not baseline_ranker_name:
|
| 110 |
-
return gr.skip(), gr.skip(), "Need to select source finder and baseline", ""
|
| 111 |
logger.info("processing update")
|
| 112 |
async with get_async_connection() as conn:
|
| 113 |
if type(baseline_ranker_name) == list:
|
|
@@ -129,7 +129,7 @@ async def update_sources_list_async(question_option, source_finder_name, run_id,
|
|
| 129 |
baseline_ranker_id_int)
|
| 130 |
else:
|
| 131 |
all_stats = None
|
| 132 |
-
return None, all_stats, "Select Run Id and source finder to see results.csv", ""
|
| 133 |
|
| 134 |
# Extract question ID from selection
|
| 135 |
question_id = questions_dict.get(question_option)
|
|
@@ -147,7 +147,7 @@ async def update_sources_list_async(question_option, source_finder_name, run_id,
|
|
| 147 |
df = pd.DataFrame(source_runs)
|
| 148 |
|
| 149 |
if not source_runs:
|
| 150 |
-
return None, None, "No results.csv found for the selected filters",
|
| 151 |
|
| 152 |
# Format table columns
|
| 153 |
columns_to_display = ['sugya_id', 'in_baseline', 'baseline_rank', 'in_source_run', 'source_run_rank',
|
|
@@ -160,7 +160,7 @@ async def update_sources_list_async(question_option, source_finder_name, run_id,
|
|
| 160 |
metadata = await get_metadata(conn, question_id, run_id_int)
|
| 161 |
|
| 162 |
result_message = f"Found {len(source_runs)} results.csv"
|
| 163 |
-
return df_display, stats, result_message, metadata
|
| 164 |
|
| 165 |
|
| 166 |
# Add a new function to handle row selection
|
|
@@ -303,20 +303,20 @@ async def main():
|
|
| 303 |
run_id_dropdown.change(
|
| 304 |
update_questions_list,
|
| 305 |
inputs=[source_finder_dropdown, run_id_dropdown, baseline_rankers_dropdown],
|
| 306 |
-
outputs=[question_dropdown, result_text, metadata_text, results_table, statistics_table]
|
| 307 |
)
|
| 308 |
|
| 309 |
question_dropdown.change(
|
| 310 |
update_sources_list,
|
| 311 |
inputs=[question_dropdown, source_finder_dropdown, run_id_dropdown, baseline_rankers_dropdown],
|
| 312 |
-
outputs=[results_table, statistics_table, result_text, metadata_text]
|
| 313 |
)
|
| 314 |
|
| 315 |
source_finder_dropdown.change(
|
| 316 |
update_run_ids,
|
| 317 |
inputs=[question_dropdown, source_finder_dropdown, baseline_rankers_dropdown],
|
| 318 |
# outputs=[run_id_dropdown, results_table, result_text, download_button]
|
| 319 |
-
outputs=[question_dropdown, results_table, statistics_table, run_id_dropdown, result_text, metadata_text]
|
| 320 |
)
|
| 321 |
|
| 322 |
app.queue()
|
|
|
|
| 58 |
available_run_id_dict = await get_run_ids(conn, finder_id_int)
|
| 59 |
run_id_options = list(available_run_id_dict.keys())
|
| 60 |
return gr.Dropdown(choices=[]), None, None, gr.Dropdown(choices=run_id_options,
|
| 61 |
+
value=None), "Select Question to see results.csv", "", ""
|
| 62 |
|
| 63 |
|
| 64 |
def update_questions_list(source_finder_name, run_id, baseline_ranker_name):
|
|
|
|
| 72 |
run_id_int = available_run_id_dict.get(run_id)
|
| 73 |
baseline_ranker_id = baseline_rankers_dict.get(baseline_ranker_name)
|
| 74 |
questions = await get_updated_question_list(conn, baseline_ranker_id, run_id_int)
|
| 75 |
+
return gr.Dropdown(choices=questions, value=None), None, None, None, None, ""
|
| 76 |
else:
|
| 77 |
+
return None, None, None, None, None, ""
|
| 78 |
|
| 79 |
|
| 80 |
async def get_updated_question_list(conn, baseline_ranker_id, finder_id_int):
|
|
|
|
| 105 |
async def update_sources_list_async(question_option, source_finder_name, run_id, baseline_ranker_name: str):
|
| 106 |
global available_run_id_dict, previous_run_id, questions_dict
|
| 107 |
if not question_option:
|
| 108 |
+
return gr.skip(), gr.skip(), "No question selected", "", ""
|
| 109 |
if not source_finder_name or not run_id or not baseline_ranker_name:
|
| 110 |
+
return gr.skip(), gr.skip(), "Need to select source finder and baseline", "", ""
|
| 111 |
logger.info("processing update")
|
| 112 |
async with get_async_connection() as conn:
|
| 113 |
if type(baseline_ranker_name) == list:
|
|
|
|
| 129 |
baseline_ranker_id_int)
|
| 130 |
else:
|
| 131 |
all_stats = None
|
| 132 |
+
return None, all_stats, "Select Run Id and source finder to see results.csv", "", ""
|
| 133 |
|
| 134 |
# Extract question ID from selection
|
| 135 |
question_id = questions_dict.get(question_option)
|
|
|
|
| 147 |
df = pd.DataFrame(source_runs)
|
| 148 |
|
| 149 |
if not source_runs:
|
| 150 |
+
return None, None, "No results.csv found for the selected filters", "", ""
|
| 151 |
|
| 152 |
# Format table columns
|
| 153 |
columns_to_display = ['sugya_id', 'in_baseline', 'baseline_rank', 'in_source_run', 'source_run_rank',
|
|
|
|
| 160 |
metadata = await get_metadata(conn, question_id, run_id_int)
|
| 161 |
|
| 162 |
result_message = f"Found {len(source_runs)} results.csv"
|
| 163 |
+
return df_display, stats, result_message, metadata, ""
|
| 164 |
|
| 165 |
|
| 166 |
# Add a new function to handle row selection
|
|
|
|
| 303 |
run_id_dropdown.change(
|
| 304 |
update_questions_list,
|
| 305 |
inputs=[source_finder_dropdown, run_id_dropdown, baseline_rankers_dropdown],
|
| 306 |
+
outputs=[question_dropdown, result_text, metadata_text, results_table, statistics_table, source_text]
|
| 307 |
)
|
| 308 |
|
| 309 |
question_dropdown.change(
|
| 310 |
update_sources_list,
|
| 311 |
inputs=[question_dropdown, source_finder_dropdown, run_id_dropdown, baseline_rankers_dropdown],
|
| 312 |
+
outputs=[results_table, statistics_table, result_text, metadata_text, source_text]
|
| 313 |
)
|
| 314 |
|
| 315 |
source_finder_dropdown.change(
|
| 316 |
update_run_ids,
|
| 317 |
inputs=[question_dropdown, source_finder_dropdown, baseline_rankers_dropdown],
|
| 318 |
# outputs=[run_id_dropdown, results_table, result_text, download_button]
|
| 319 |
+
outputs=[question_dropdown, results_table, statistics_table, run_id_dropdown, result_text, metadata_text, source_text]
|
| 320 |
)
|
| 321 |
|
| 322 |
app.queue()
|