HongzeFu commited on
Commit
5301133
·
1 Parent(s): 75296f2
Untitled ADDED
@@ -0,0 +1 @@
 
 
1
+ Session expired. Please refresh the page and try again.
gradio-web/test/test_queue_session_limit_e2e.py CHANGED
@@ -715,3 +715,90 @@ def test_active_user_execute_is_not_blocked_by_waiting_init_loads(monkeypatch):
715
  server.should_exit = True
716
  thread.join(timeout=10)
717
  demo.close()
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
715
  server.should_exit = True
716
  thread.join(timeout=10)
717
  demo.close()
718
+
719
+
720
+ def test_waiting_page_enters_task_after_idle_session_ttl_release(monkeypatch):
721
+ config = importlib.reload(importlib.import_module("config"))
722
+ state_manager = importlib.reload(importlib.import_module("state_manager"))
723
+ callbacks = importlib.reload(importlib.import_module("gradio_callbacks"))
724
+ ui_layout = importlib.reload(importlib.import_module("ui_layout"))
725
+
726
+ monkeypatch.setattr(ui_layout, "SESSION_TIMEOUT", 2)
727
+
728
+ class _FakeProxy:
729
+ def __init__(self):
730
+ self.env_id = None
731
+ self.episode_idx = None
732
+ self.language_goal = "goal"
733
+ self.available_options = [("pick", 0)]
734
+ self.raw_solve_options = [{"label": "a", "action": "pick", "available": False}]
735
+ self.demonstration_frames = []
736
+
737
+ def load_episode(self, env_id, episode_idx):
738
+ self.env_id = env_id
739
+ self.episode_idx = episode_idx
740
+ return Image.new("RGB", (32, 32), color=(10, 20, 30)), "loaded"
741
+
742
+ def get_pil_image(self, use_segmented=False):
743
+ _ = use_segmented
744
+ return Image.new("RGB", (32, 32), color=(10, 20, 30))
745
+
746
+ def close(self):
747
+ return None
748
+
749
+ monkeypatch.setattr(state_manager, "ProcessSessionProxy", _FakeProxy)
750
+ monkeypatch.setattr(
751
+ callbacks.user_manager,
752
+ "init_session",
753
+ lambda uid: (
754
+ True,
755
+ "ok",
756
+ {"current_task": {"env_id": "BinFill", "episode_idx": 1}, "completed_count": 0},
757
+ ),
758
+ )
759
+ monkeypatch.setattr(callbacks, "get_task_hint", lambda env_id: "")
760
+ monkeypatch.setattr(callbacks, "should_show_demo_video", lambda env_id: False)
761
+
762
+ demo = ui_layout.create_ui_blocks()
763
+ root_url, demo, server, thread = _mount_demo(demo)
764
+
765
+ try:
766
+ with sync_playwright() as p:
767
+ browser = p.chromium.launch(headless=True)
768
+
769
+ active_pages = []
770
+ for _ in range(config.SESSION_CONCURRENCY_LIMIT):
771
+ page = browser.new_page(viewport={"width": 1280, "height": 900})
772
+ page.goto(root_url, wait_until="domcontentloaded")
773
+ active_pages.append(page)
774
+ time.sleep(0.25)
775
+
776
+ for page in active_pages:
777
+ _wait_until(lambda page=page: _read_progress_text(page) is None, timeout_s=15.0)
778
+
779
+ waiting_page = browser.new_page(viewport={"width": 1280, "height": 900})
780
+ waiting_page.goto(root_url, wait_until="domcontentloaded")
781
+
782
+ _wait_until(
783
+ lambda: _read_session_wait_overlay_snapshot(waiting_page)["visible"] is True,
784
+ timeout_s=10.0,
785
+ )
786
+ _wait_until(
787
+ lambda: len(state_manager.ACTIVE_SESSION_SLOTS) < config.SESSION_CONCURRENCY_LIMIT,
788
+ timeout_s=10.0,
789
+ )
790
+ _wait_until(
791
+ lambda: _read_session_wait_overlay_snapshot(waiting_page)["visible"] is False,
792
+ timeout_s=15.0,
793
+ )
794
+ _wait_until(
795
+ lambda: (_read_log_output_value(waiting_page) or "").strip() == "Please select the action.\nActions with 🎯 need to select a point on the image as input",
796
+ timeout_s=15.0,
797
+ )
798
+ assert _read_progress_text(waiting_page) is None
799
+
800
+ browser.close()
801
+ finally:
802
+ server.should_exit = True
803
+ thread.join(timeout=10)
804
+ demo.close()
gradio-web/ui_layout.py CHANGED
@@ -373,6 +373,7 @@ PROGRESS_TEXT_REWRITE_JS = f"""
373
  const modeIdle = {json.dumps(LOAD_STATUS_MODE_IDLE)};
374
  const episodeLoadingText = {json.dumps(UI_TEXT["progress"]["episode_loading"])};
375
  const queueWaitText = {json.dumps(UI_TEXT["progress"]["queue_wait"])};
 
376
 
377
  window.__robommeLoadStatusMode = window.__robommeLoadStatusMode || modeIdle;
378
  const getMode = () => window.__robommeLoadStatusMode || modeIdle;
@@ -449,8 +450,14 @@ PROGRESS_TEXT_REWRITE_JS = f"""
449
  node.dataset.robommeProgressCustomized === "1" && displayed === previousCustom
450
  ? node.dataset.robommeProgressRaw || displayed
451
  : displayed;
452
-
453
  if (getMode() !== modeEpisodeLoad) {{
 
 
 
 
 
 
 
454
  if (
455
  node.dataset.robommeProgressCustomized === "1" &&
456
  displayed === previousCustom &&
 
373
  const modeIdle = {json.dumps(LOAD_STATUS_MODE_IDLE)};
374
  const episodeLoadingText = {json.dumps(UI_TEXT["progress"]["episode_loading"])};
375
  const queueWaitText = {json.dumps(UI_TEXT["progress"]["queue_wait"])};
376
+ const elapsedOnlyPattern = /^\\d+(?:\\.\\d+)?s$/i;
377
 
378
  window.__robommeLoadStatusMode = window.__robommeLoadStatusMode || modeIdle;
379
  const getMode = () => window.__robommeLoadStatusMode || modeIdle;
 
450
  node.dataset.robommeProgressCustomized === "1" && displayed === previousCustom
451
  ? node.dataset.robommeProgressRaw || displayed
452
  : displayed;
 
453
  if (getMode() !== modeEpisodeLoad) {{
454
+ if (
455
+ (elapsedOnlyPattern.test(raw) ||
456
+ /^processing/i.test(raw) ||
457
+ /^queue:/i.test(raw))
458
+ ) {{
459
+ node.textContent = "";
460
+ }}
461
  if (
462
  node.dataset.robommeProgressCustomized === "1" &&
463
  displayed === previousCustom &&