Merge branch 'v0.6.4-docker' of github.com:RoboMME/robomme-benchmark into v0.6.4-docker
Browse files- app.py +8 -3
- gradio-web/gradio_callbacks.py +12 -3
- gradio-web/ui_layout.py +14 -8
app.py
CHANGED
|
@@ -315,13 +315,18 @@ def create_dummy_demo() -> gr.Blocks:
|
|
| 315 |
elem_id="next_task_btn",
|
| 316 |
)
|
| 317 |
|
| 318 |
-
with gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 319 |
task_hint_display = gr.Textbox(
|
| 320 |
value=_task_hint(DUMMY_TASKS[0]),
|
| 321 |
lines=8,
|
| 322 |
max_lines=16,
|
| 323 |
-
show_label=
|
| 324 |
-
label="Task Hint",
|
| 325 |
interactive=True,
|
| 326 |
elem_id="task_hint_display",
|
| 327 |
)
|
|
|
|
| 315 |
elem_id="next_task_btn",
|
| 316 |
)
|
| 317 |
|
| 318 |
+
with gr.Accordion(
|
| 319 |
+
"Task Hint",
|
| 320 |
+
open=False,
|
| 321 |
+
visible=True,
|
| 322 |
+
elem_classes=["native-card"],
|
| 323 |
+
elem_id="task_hint_card",
|
| 324 |
+
):
|
| 325 |
task_hint_display = gr.Textbox(
|
| 326 |
value=_task_hint(DUMMY_TASKS[0]),
|
| 327 |
lines=8,
|
| 328 |
max_lines=16,
|
| 329 |
+
show_label=False,
|
|
|
|
| 330 |
interactive=True,
|
| 331 |
elem_id="task_hint_display",
|
| 332 |
)
|
gradio-web/gradio_callbacks.py
CHANGED
|
@@ -76,7 +76,10 @@ def _entry_rejected_text():
|
|
| 76 |
|
| 77 |
def touch_session(uid):
|
| 78 |
"""Re-emit the current session key to refresh gr.State TTL."""
|
| 79 |
-
|
|
|
|
|
|
|
|
|
|
| 80 |
|
| 81 |
|
| 82 |
def cleanup_user_session(uid):
|
|
@@ -278,10 +281,16 @@ def on_video_end(uid):
|
|
| 278 |
|
| 279 |
def on_demo_video_play(uid):
|
| 280 |
"""Mark the demo video as consumed and disable the play button."""
|
| 281 |
-
if not
|
| 282 |
-
LOGGER.warning("on_demo_video_play: missing
|
| 283 |
raise gr.Error(_session_error_text())
|
| 284 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 285 |
already_clicked = get_play_button_clicked(uid)
|
| 286 |
if not already_clicked:
|
| 287 |
set_play_button_clicked(uid, True)
|
|
|
|
| 76 |
|
| 77 |
def touch_session(uid):
|
| 78 |
"""Re-emit the current session key to refresh gr.State TTL."""
|
| 79 |
+
if not uid:
|
| 80 |
+
return None
|
| 81 |
+
# Keep the browser-side uid even when the backend session is stubbed or not yet materialized.
|
| 82 |
+
return uid
|
| 83 |
|
| 84 |
|
| 85 |
def cleanup_user_session(uid):
|
|
|
|
| 281 |
|
| 282 |
def on_demo_video_play(uid):
|
| 283 |
"""Mark the demo video as consumed and disable the play button."""
|
| 284 |
+
if not uid:
|
| 285 |
+
LOGGER.warning("on_demo_video_play: missing uid")
|
| 286 |
raise gr.Error(_session_error_text())
|
| 287 |
|
| 288 |
+
if not get_session(uid):
|
| 289 |
+
LOGGER.warning(
|
| 290 |
+
"on_demo_video_play: missing session uid=%s; disabling button anyway",
|
| 291 |
+
_uid_for_log(uid),
|
| 292 |
+
)
|
| 293 |
+
|
| 294 |
already_clicked = get_play_button_clicked(uid)
|
| 295 |
if not already_clicked:
|
| 296 |
set_play_button_clicked(uid, True)
|
gradio-web/ui_layout.py
CHANGED
|
@@ -342,9 +342,9 @@ SET_EPISODE_LOAD_MODE_JS = f"""
|
|
| 342 |
}}
|
| 343 |
"""
|
| 344 |
|
| 345 |
-
|
| 346 |
SET_EPISODE_LOAD_MODE_IF_SWITCH_JS = f"""
|
| 347 |
-
(
|
| 348 |
const normalize = (value) => (value == null ? "" : String(value).trim().toLowerCase());
|
| 349 |
const nextEnv = normalize(selectedEnv);
|
| 350 |
const currentEnv = normalize(currentTaskEnv);
|
|
@@ -352,6 +352,7 @@ SET_EPISODE_LOAD_MODE_IF_SWITCH_JS = f"""
|
|
| 352 |
nextEnv && nextEnv !== currentEnv
|
| 353 |
? {json.dumps(LOAD_STATUS_MODE_EPISODE_LOAD)}
|
| 354 |
: {json.dumps(LOAD_STATUS_MODE_IDLE)};
|
|
|
|
| 355 |
}}
|
| 356 |
"""
|
| 357 |
|
|
@@ -901,13 +902,13 @@ def create_ui_blocks():
|
|
| 901 |
demo.head = THEME_LOCK_HEAD
|
| 902 |
|
| 903 |
gr.Markdown("## π₯ RoboMME Interactive Demo πππ", elem_id="header_title")
|
| 904 |
-
gr.Markdown("###
|
| 905 |
with gr.Row():
|
| 906 |
with gr.Column(scale=1):
|
| 907 |
header_task_box = gr.Dropdown(
|
| 908 |
choices=list(user_manager.env_choices),
|
| 909 |
value=render_header_task(""),
|
| 910 |
-
label="Current Task
|
| 911 |
show_label=True,
|
| 912 |
interactive=True,
|
| 913 |
elem_id="header_task",
|
|
@@ -915,7 +916,7 @@ def create_ui_blocks():
|
|
| 915 |
with gr.Column(scale=2):
|
| 916 |
header_goal_box = gr.Textbox(
|
| 917 |
value=render_header_goal(""),
|
| 918 |
-
label="Task Goal
|
| 919 |
show_label=True,
|
| 920 |
interactive=False,
|
| 921 |
lines=1,
|
|
@@ -1046,13 +1047,18 @@ def create_ui_blocks():
|
|
| 1046 |
elem_id="next_task_btn",
|
| 1047 |
)
|
| 1048 |
|
| 1049 |
-
with gr.
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1050 |
task_hint_display = gr.Textbox(
|
| 1051 |
value="",
|
| 1052 |
lines=8,
|
| 1053 |
max_lines=16,
|
| 1054 |
-
show_label=
|
| 1055 |
-
label="Task Hintπ‘",
|
| 1056 |
interactive=True,
|
| 1057 |
elem_id="task_hint_display",
|
| 1058 |
)
|
|
|
|
| 342 |
}}
|
| 343 |
"""
|
| 344 |
|
| 345 |
+
# Gradio js preprocessors with inputs must return the original args, or Python receives None.
|
| 346 |
SET_EPISODE_LOAD_MODE_IF_SWITCH_JS = f"""
|
| 347 |
+
(uid, selectedEnv, currentTaskEnv) => {{
|
| 348 |
const normalize = (value) => (value == null ? "" : String(value).trim().toLowerCase());
|
| 349 |
const nextEnv = normalize(selectedEnv);
|
| 350 |
const currentEnv = normalize(currentTaskEnv);
|
|
|
|
| 352 |
nextEnv && nextEnv !== currentEnv
|
| 353 |
? {json.dumps(LOAD_STATUS_MODE_EPISODE_LOAD)}
|
| 354 |
: {json.dumps(LOAD_STATUS_MODE_IDLE)};
|
| 355 |
+
return [uid, selectedEnv, currentTaskEnv];
|
| 356 |
}}
|
| 357 |
"""
|
| 358 |
|
|
|
|
| 902 |
demo.head = THEME_LOCK_HEAD
|
| 903 |
|
| 904 |
gr.Markdown("## π₯ RoboMME Interactive Demo πππ", elem_id="header_title")
|
| 905 |
+
gr.Markdown("### Curious about memory-based robotic tasks? π€ Try it yourself π")
|
| 906 |
with gr.Row():
|
| 907 |
with gr.Column(scale=1):
|
| 908 |
header_task_box = gr.Dropdown(
|
| 909 |
choices=list(user_manager.env_choices),
|
| 910 |
value=render_header_task(""),
|
| 911 |
+
label="Current Task π",
|
| 912 |
show_label=True,
|
| 913 |
interactive=True,
|
| 914 |
elem_id="header_task",
|
|
|
|
| 916 |
with gr.Column(scale=2):
|
| 917 |
header_goal_box = gr.Textbox(
|
| 918 |
value=render_header_goal(""),
|
| 919 |
+
label="Task Goal π",
|
| 920 |
show_label=True,
|
| 921 |
interactive=False,
|
| 922 |
lines=1,
|
|
|
|
| 1047 |
elem_id="next_task_btn",
|
| 1048 |
)
|
| 1049 |
|
| 1050 |
+
with gr.Accordion(
|
| 1051 |
+
"Task Hintπ‘",
|
| 1052 |
+
open=False,
|
| 1053 |
+
visible=True,
|
| 1054 |
+
elem_classes=["native-card"],
|
| 1055 |
+
elem_id="task_hint_card",
|
| 1056 |
+
):
|
| 1057 |
task_hint_display = gr.Textbox(
|
| 1058 |
value="",
|
| 1059 |
lines=8,
|
| 1060 |
max_lines=16,
|
| 1061 |
+
show_label=False,
|
|
|
|
| 1062 |
interactive=True,
|
| 1063 |
elem_id="task_hint_display",
|
| 1064 |
)
|