Spaces:
Sleeping
Sleeping
Update utils/state_management.py
Browse files- utils/state_management.py +19 -19
utils/state_management.py
CHANGED
@@ -1,12 +1,11 @@
|
|
1 |
import gradio as gr
|
2 |
|
3 |
-
def start_evaluation(state
|
4 |
"""
|
5 |
Disables UI components when evaluation starts.
|
6 |
|
7 |
Args:
|
8 |
state (dict): Current evaluation state.
|
9 |
-
ui_components (dict): Dictionary of UI components to update.
|
10 |
|
11 |
Returns:
|
12 |
list: List of updated state and UI components.
|
@@ -14,18 +13,25 @@ def start_evaluation(state, ui_components):
|
|
14 |
if state["running"]:
|
15 |
return [
|
16 |
state,
|
17 |
-
|
18 |
-
gr.update(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
19 |
"Evaluation already in progress. Please wait.", # results_output
|
20 |
-
None,
|
21 |
-
gr.update(visible=False)
|
22 |
]
|
23 |
|
24 |
# Update state to running
|
25 |
state["running"] = True
|
26 |
|
27 |
-
#
|
28 |
-
|
29 |
state, # Updated state
|
30 |
gr.update(interactive=False), # subject_selection_mode
|
31 |
gr.update(interactive=False), # num_subjects_slider
|
@@ -40,8 +46,6 @@ def start_evaluation(state, ui_components):
|
|
40 |
None, # results_table
|
41 |
gr.update(visible=False) # results_table_container
|
42 |
]
|
43 |
-
|
44 |
-
return updates
|
45 |
|
46 |
def finish_evaluation(state):
|
47 |
"""
|
@@ -56,13 +60,12 @@ def finish_evaluation(state):
|
|
56 |
state["running"] = False
|
57 |
return state
|
58 |
|
59 |
-
def cancel_evaluation(state
|
60 |
"""
|
61 |
Re-enables UI components when evaluation is canceled.
|
62 |
|
63 |
Args:
|
64 |
state (dict): Current evaluation state.
|
65 |
-
ui_components (dict): Dictionary of UI components to update.
|
66 |
|
67 |
Returns:
|
68 |
list: List of updated state and UI components.
|
@@ -70,8 +73,8 @@ def cancel_evaluation(state, ui_components):
|
|
70 |
# Update state to not running
|
71 |
state["running"] = False
|
72 |
|
73 |
-
#
|
74 |
-
|
75 |
state, # Updated state
|
76 |
gr.update(interactive=True), # subject_selection_mode
|
77 |
gr.update(interactive=True), # num_subjects_slider
|
@@ -86,16 +89,13 @@ def cancel_evaluation(state, ui_components):
|
|
86 |
None, # results_table
|
87 |
gr.update(visible=False) # results_table_container
|
88 |
]
|
89 |
-
|
90 |
-
return updates
|
91 |
|
92 |
-
def handle_evaluation_results(eval_results
|
93 |
"""
|
94 |
Updates UI components based on evaluation results.
|
95 |
|
96 |
Args:
|
97 |
eval_results (dict): Results from evaluation.
|
98 |
-
ui_components (dict): Dictionary of UI components to update.
|
99 |
|
100 |
Returns:
|
101 |
list: List of updated UI components.
|
@@ -125,4 +125,4 @@ def handle_evaluation_results(eval_results, ui_components):
|
|
125 |
gr.update(interactive=True), # num_questions_slider
|
126 |
gr.update(interactive=True), # model1_dropdown
|
127 |
gr.update(visible=False) # results_table_container
|
128 |
-
]
|
|
|
1 |
import gradio as gr
|
2 |
|
3 |
+
def start_evaluation(state):
|
4 |
"""
|
5 |
Disables UI components when evaluation starts.
|
6 |
|
7 |
Args:
|
8 |
state (dict): Current evaluation state.
|
|
|
9 |
|
10 |
Returns:
|
11 |
list: List of updated state and UI components.
|
|
|
13 |
if state["running"]:
|
14 |
return [
|
15 |
state,
|
16 |
+
gr.update(interactive=False), # subject_selection_mode
|
17 |
+
gr.update(interactive=False), # num_subjects_slider
|
18 |
+
gr.update(interactive=False), # specific_subjects
|
19 |
+
gr.update(interactive=False), # all_questions_checkbox
|
20 |
+
gr.update(interactive=False), # num_questions_slider
|
21 |
+
gr.update(interactive=False), # model1_dropdown
|
22 |
+
gr.update(interactive=False), # model2_dropdown
|
23 |
+
gr.update(interactive=False), # eval_button
|
24 |
+
gr.update(visible=True), # cancel_button
|
25 |
"Evaluation already in progress. Please wait.", # results_output
|
26 |
+
None, # results_table
|
27 |
+
gr.update(visible=False) # results_table_container
|
28 |
]
|
29 |
|
30 |
# Update state to running
|
31 |
state["running"] = True
|
32 |
|
33 |
+
# Return updates for UI components
|
34 |
+
return [
|
35 |
state, # Updated state
|
36 |
gr.update(interactive=False), # subject_selection_mode
|
37 |
gr.update(interactive=False), # num_subjects_slider
|
|
|
46 |
None, # results_table
|
47 |
gr.update(visible=False) # results_table_container
|
48 |
]
|
|
|
|
|
49 |
|
50 |
def finish_evaluation(state):
|
51 |
"""
|
|
|
60 |
state["running"] = False
|
61 |
return state
|
62 |
|
63 |
+
def cancel_evaluation(state):
|
64 |
"""
|
65 |
Re-enables UI components when evaluation is canceled.
|
66 |
|
67 |
Args:
|
68 |
state (dict): Current evaluation state.
|
|
|
69 |
|
70 |
Returns:
|
71 |
list: List of updated state and UI components.
|
|
|
73 |
# Update state to not running
|
74 |
state["running"] = False
|
75 |
|
76 |
+
# Return updates for UI components
|
77 |
+
return [
|
78 |
state, # Updated state
|
79 |
gr.update(interactive=True), # subject_selection_mode
|
80 |
gr.update(interactive=True), # num_subjects_slider
|
|
|
89 |
None, # results_table
|
90 |
gr.update(visible=False) # results_table_container
|
91 |
]
|
|
|
|
|
92 |
|
93 |
+
def handle_evaluation_results(eval_results):
|
94 |
"""
|
95 |
Updates UI components based on evaluation results.
|
96 |
|
97 |
Args:
|
98 |
eval_results (dict): Results from evaluation.
|
|
|
99 |
|
100 |
Returns:
|
101 |
list: List of updated UI components.
|
|
|
125 |
gr.update(interactive=True), # num_questions_slider
|
126 |
gr.update(interactive=True), # model1_dropdown
|
127 |
gr.update(visible=False) # results_table_container
|
128 |
+
]
|