goal [-1]
Browse files
gradio-web/oracle_logic.py
CHANGED
|
@@ -143,12 +143,12 @@ def _fetch_segmentation(env):
|
|
| 143 |
def _build_solve_options(env, planner, selected_target, env_id):
|
| 144 |
return get_vqa_options(env, planner, selected_target, env_id)
|
| 145 |
|
| 146 |
-
def
|
| 147 |
if isinstance(value, str):
|
| 148 |
text = value.strip()
|
| 149 |
return text or default
|
| 150 |
if isinstance(value, (list, tuple)):
|
| 151 |
-
for item in value:
|
| 152 |
if item is None:
|
| 153 |
continue
|
| 154 |
text = str(item).strip()
|
|
@@ -301,7 +301,7 @@ def _extract_demonstration_payload(demonstration_data):
|
|
| 301 |
frames_candidate = demonstration_data.get("frames")
|
| 302 |
if frames_candidate is None:
|
| 303 |
frames_candidate = demonstration_data.get("front_rgb_list")
|
| 304 |
-
return
|
| 305 |
|
| 306 |
if isinstance(demonstration_data, (tuple, list)):
|
| 307 |
obs_batch = demonstration_data[0] if len(demonstration_data) >= 1 else None
|
|
@@ -322,7 +322,7 @@ def _extract_demonstration_payload(demonstration_data):
|
|
| 322 |
if goal_candidate is None:
|
| 323 |
goal_candidate = info_batch.get("language_goal")
|
| 324 |
|
| 325 |
-
return
|
| 326 |
|
| 327 |
return default_goal, default_frames
|
| 328 |
|
|
|
|
| 143 |
def _build_solve_options(env, planner, selected_target, env_id):
|
| 144 |
return get_vqa_options(env, planner, selected_target, env_id)
|
| 145 |
|
| 146 |
+
def _extract_last_text(value, default="Unknown Goal"):
|
| 147 |
if isinstance(value, str):
|
| 148 |
text = value.strip()
|
| 149 |
return text or default
|
| 150 |
if isinstance(value, (list, tuple)):
|
| 151 |
+
for item in reversed(value):
|
| 152 |
if item is None:
|
| 153 |
continue
|
| 154 |
text = str(item).strip()
|
|
|
|
| 301 |
frames_candidate = demonstration_data.get("frames")
|
| 302 |
if frames_candidate is None:
|
| 303 |
frames_candidate = demonstration_data.get("front_rgb_list")
|
| 304 |
+
return _extract_last_text(goal_candidate, default_goal), _ensure_list(frames_candidate)
|
| 305 |
|
| 306 |
if isinstance(demonstration_data, (tuple, list)):
|
| 307 |
obs_batch = demonstration_data[0] if len(demonstration_data) >= 1 else None
|
|
|
|
| 322 |
if goal_candidate is None:
|
| 323 |
goal_candidate = info_batch.get("language_goal")
|
| 324 |
|
| 325 |
+
return _extract_last_text(goal_candidate, default_goal), _ensure_list(frames_candidate)
|
| 326 |
|
| 327 |
return default_goal, default_frames
|
| 328 |
|
gradio-web/test/test_oracle_builder_integration.py
CHANGED
|
@@ -180,5 +180,5 @@ def test_load_episode_supports_tuple_demonstration_data(monkeypatch, reload_modu
|
|
| 180 |
|
| 181 |
assert img == "IMG"
|
| 182 |
assert msg == "Ready"
|
| 183 |
-
assert session.language_goal == "
|
| 184 |
assert session.demonstration_frames == ["tuple_f1", "tuple_f2"]
|
|
|
|
| 180 |
|
| 181 |
assert img == "IMG"
|
| 182 |
assert msg == "Ready"
|
| 183 |
+
assert session.language_goal == "backup goal"
|
| 184 |
assert session.demonstration_frames == ["tuple_f1", "tuple_f2"]
|
gradio-web/test/test_ui_native_layout_contract.py
CHANGED
|
@@ -23,6 +23,12 @@ def test_native_ui_has_no_legacy_runtime_js_or_card_shell_tokens(reload_module):
|
|
| 23 |
assert token not in css
|
| 24 |
|
| 25 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
def test_native_ui_config_contains_phase_machine_and_precheck_chain(reload_module):
|
| 27 |
ui_layout = reload_module("ui_layout")
|
| 28 |
demo = ui_layout.create_ui_blocks()
|
|
|
|
| 23 |
assert token not in css
|
| 24 |
|
| 25 |
|
| 26 |
+
def test_extract_last_goal_prefers_last_list_item(reload_module):
|
| 27 |
+
ui_layout = reload_module("ui_layout")
|
| 28 |
+
|
| 29 |
+
assert ui_layout.extract_last_goal("['goal a', 'goal b']") == "goal b"
|
| 30 |
+
|
| 31 |
+
|
| 32 |
def test_native_ui_config_contains_phase_machine_and_precheck_chain(reload_module):
|
| 33 |
ui_layout = reload_module("ui_layout")
|
| 34 |
demo = ui_layout.create_ui_blocks()
|
gradio-web/ui_layout.py
CHANGED
|
@@ -241,8 +241,8 @@ button#reference_action_btn:not(:disabled):hover,
|
|
| 241 |
"""
|
| 242 |
|
| 243 |
|
| 244 |
-
def
|
| 245 |
-
"""Extract
|
| 246 |
if not goal_text:
|
| 247 |
return ""
|
| 248 |
text = goal_text.strip()
|
|
@@ -250,7 +250,10 @@ def extract_first_goal(goal_text):
|
|
| 250 |
try:
|
| 251 |
goals = ast.literal_eval(text)
|
| 252 |
if isinstance(goals, list) and goals:
|
| 253 |
-
|
|
|
|
|
|
|
|
|
|
| 254 |
except Exception:
|
| 255 |
pass
|
| 256 |
return text.split("\n")[0].strip()
|
|
@@ -284,8 +287,8 @@ def create_ui_blocks():
|
|
| 284 |
return " ".join(clean_task.splitlines()).strip() or None
|
| 285 |
|
| 286 |
def render_header_goal(goal_text):
|
| 287 |
-
|
| 288 |
-
return
|
| 289 |
|
| 290 |
with gr.Blocks(title="Oracle Planner Interface") as demo:
|
| 291 |
demo.theme = gr.themes.Soft()
|
|
|
|
| 241 |
"""
|
| 242 |
|
| 243 |
|
| 244 |
+
def extract_last_goal(goal_text):
|
| 245 |
+
"""Extract last goal from goal text that may be a list representation."""
|
| 246 |
if not goal_text:
|
| 247 |
return ""
|
| 248 |
text = goal_text.strip()
|
|
|
|
| 250 |
try:
|
| 251 |
goals = ast.literal_eval(text)
|
| 252 |
if isinstance(goals, list) and goals:
|
| 253 |
+
for goal in reversed(goals):
|
| 254 |
+
goal_text = str(goal).strip()
|
| 255 |
+
if goal_text:
|
| 256 |
+
return goal_text
|
| 257 |
except Exception:
|
| 258 |
pass
|
| 259 |
return text.split("\n")[0].strip()
|
|
|
|
| 287 |
return " ".join(clean_task.splitlines()).strip() or None
|
| 288 |
|
| 289 |
def render_header_goal(goal_text):
|
| 290 |
+
last_goal = extract_last_goal(goal_text or "")
|
| 291 |
+
return last_goal if last_goal else "—"
|
| 292 |
|
| 293 |
with gr.Blocks(title="Oracle Planner Interface") as demo:
|
| 294 |
demo.theme = gr.themes.Soft()
|