Fix MODEL_NAME=None + Fix Gradio dashboard slowness (remove auto-reset on tab/radio)
Browse files- server/app.py +11 -20
server/app.py
CHANGED
|
@@ -335,43 +335,34 @@ def build_custom_ui():
|
|
| 335 |
|
| 336 |
step_btn = gr.Button("Execute Strategic Step", variant="primary")
|
| 337 |
|
| 338 |
-
# Logic
|
| 339 |
def sync_from_mode(mode):
|
|
|
|
| 340 |
t_id = "task_easy"
|
| 341 |
if mode == "propose_new_rule": t_id = "task_medium"
|
| 342 |
elif mode == "evolve_policy": t_id = "task_hard"
|
| 343 |
-
|
| 344 |
-
# Perform reset with the new task_id
|
| 345 |
-
res = handle_reset(t_id)
|
| 346 |
-
return (t_id,) + res
|
| 347 |
|
| 348 |
def sync_from_tab(evt: gr.SelectData):
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
mode = "propose_new_rule"
|
| 354 |
-
elif evt.index == 2:
|
| 355 |
-
t_id = "task_hard"
|
| 356 |
-
mode = "evolve_policy"
|
| 357 |
-
|
| 358 |
-
res = handle_reset(t_id)
|
| 359 |
-
return (t_id, mode) + res
|
| 360 |
|
| 361 |
# Event Listeners
|
| 362 |
reset_btn.click(handle_reset, inputs=[task_id], outputs=[corpus_table, policy_display, best_score_disp, steps_left_disp, episode_disp, corpus_count_disp, reward_plot, reward_outcome_disp, raw_json_box])
|
| 363 |
|
| 364 |
-
#
|
| 365 |
action_mode.change(
|
| 366 |
sync_from_mode,
|
| 367 |
inputs=[action_mode],
|
| 368 |
-
outputs=[task_id
|
| 369 |
)
|
| 370 |
|
| 371 |
-
#
|
| 372 |
action_tabs.select(
|
| 373 |
sync_from_tab,
|
| 374 |
-
outputs=[task_id, action_mode
|
| 375 |
)
|
| 376 |
|
| 377 |
step_btn.click(
|
|
|
|
| 335 |
|
| 336 |
step_btn = gr.Button("Execute Strategic Step", variant="primary")
|
| 337 |
|
| 338 |
+
# Logic — lightweight sync (NO reset on tab/radio change)
|
| 339 |
def sync_from_mode(mode):
|
| 340 |
+
"""Only update the dropdown to match the radio. No environment reset."""
|
| 341 |
t_id = "task_easy"
|
| 342 |
if mode == "propose_new_rule": t_id = "task_medium"
|
| 343 |
elif mode == "evolve_policy": t_id = "task_hard"
|
| 344 |
+
return t_id
|
|
|
|
|
|
|
|
|
|
| 345 |
|
| 346 |
def sync_from_tab(evt: gr.SelectData):
|
| 347 |
+
"""Only update dropdown + radio to match the tab. No environment reset."""
|
| 348 |
+
mapping = {0: ("task_easy", "propose_clarification"), 1: ("task_medium", "propose_new_rule"), 2: ("task_hard", "evolve_policy")}
|
| 349 |
+
t_id, mode = mapping.get(evt.index, ("task_easy", "propose_clarification"))
|
| 350 |
+
return t_id, mode
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 351 |
|
| 352 |
# Event Listeners
|
| 353 |
reset_btn.click(handle_reset, inputs=[task_id], outputs=[corpus_table, policy_display, best_score_disp, steps_left_disp, episode_disp, corpus_count_disp, reward_plot, reward_outcome_disp, raw_json_box])
|
| 354 |
|
| 355 |
+
# Lightweight Sync: Radio -> Dropdown (instant, no reset)
|
| 356 |
action_mode.change(
|
| 357 |
sync_from_mode,
|
| 358 |
inputs=[action_mode],
|
| 359 |
+
outputs=[task_id]
|
| 360 |
)
|
| 361 |
|
| 362 |
+
# Lightweight Sync: Tab -> Dropdown & Radio (instant, no reset)
|
| 363 |
action_tabs.select(
|
| 364 |
sync_from_tab,
|
| 365 |
+
outputs=[task_id, action_mode]
|
| 366 |
)
|
| 367 |
|
| 368 |
step_btn.click(
|