HongzeFu commited on
Commit
e51a493
·
1 Parent(s): 41fc019

session 10 900s

Browse files
gradio-web/config.py CHANGED
@@ -19,9 +19,9 @@ RIGHT_TOP_LOG_SCALE = 1
19
  UI_GLOBAL_FONT_SIZE = "24px"
20
 
21
  # Session / queue 配置
22
- SESSION_TIMEOUT = 20 # 30秒无用户主动操作后,交由 gr.State TTL 自动回收 session
23
  SESSION_CONCURRENCY_ID = "session_actions"
24
- SESSION_CONCURRENCY_LIMIT = 2
25
 
26
  # 兜底执行次数配置
27
  EXECUTE_LIMIT_OFFSET = 4 # 兜底执行次数 = non_demonstration_task_length + EXECUTE_LIMIT_OFFSET
@@ -87,7 +87,7 @@ UI_TEXT = {
87
  "progress": {
88
  "episode_loading": "The episode is loading...",
89
  "queue_wait": "Lots of people are playing! Please wait...",
90
- "entry_rejected": "too many people playing",
91
  },
92
  "errors": {
93
  "load_missing_task": "Error loading task: missing current_task",
 
19
  UI_GLOBAL_FONT_SIZE = "24px"
20
 
21
  # Session / queue 配置
22
+ SESSION_TIMEOUT = 90 # 30秒无用户主动操作后,交由 gr.State TTL 自动回收 session
23
  SESSION_CONCURRENCY_ID = "session_actions"
24
+ SESSION_CONCURRENCY_LIMIT = 10
25
 
26
  # 兜底执行次数配置
27
  EXECUTE_LIMIT_OFFSET = 4 # 兜底执行次数 = non_demonstration_task_length + EXECUTE_LIMIT_OFFSET
 
87
  "progress": {
88
  "episode_loading": "The episode is loading...",
89
  "queue_wait": "Lots of people are playing! Please wait...",
90
+ "entry_rejected": "Too many users are trying the demo right now. Please try again later.",
91
  },
92
  "errors": {
93
  "load_missing_task": "Error loading task: missing current_task",
gradio-web/test/test_queue_session_limit_e2e.py CHANGED
@@ -130,14 +130,21 @@ def _read_session_wait_overlay_snapshot(page) -> dict[str, float | bool | None]:
130
  proseBackground: null,
131
  proseBorderRadius: null,
132
  proseBoxShadow: null,
 
 
 
 
133
  };
134
  }
135
  const markdown = host.querySelector('[data-testid="markdown"]');
136
  const prose = markdown ? markdown.querySelector('.prose, .md') || markdown : null;
 
137
  const text = prose ? ((prose.innerText || prose.textContent || '').trim()) : '';
138
  const rect = host.getBoundingClientRect();
139
  const style = getComputedStyle(host);
140
  const proseStyle = prose ? getComputedStyle(prose) : null;
 
 
141
  return {
142
  present: true,
143
  visible: style.display !== 'none' && rect.width > 0 && rect.height > 0 && text.length > 0,
@@ -148,6 +155,10 @@ def _read_session_wait_overlay_snapshot(page) -> dict[str, float | bool | None]:
148
  proseBackground: proseStyle ? proseStyle.backgroundColor || null : null,
149
  proseBorderRadius: proseStyle ? proseStyle.borderRadius || null : null,
150
  proseBoxShadow: proseStyle ? proseStyle.boxShadow || null : null,
 
 
 
 
151
  };
152
  }"""
153
  )
@@ -271,6 +282,10 @@ def test_entry_rejects_immediately_when_session_limit_is_full(monkeypatch):
271
  assert pages[-1].evaluate("() => document.getElementById('robomme_episode_loading_copy') === null") is True
272
  rejection_snapshot = _read_session_wait_overlay_snapshot(pages[-1])
273
  assert rejection_snapshot["content"] == config.UI_TEXT["progress"]["entry_rejected"]
 
 
 
 
274
  assert _read_unified_overlay_text(pages[-1]) == config.UI_TEXT["progress"]["entry_rejected"]
275
  assert len(state_manager.GLOBAL_SESSIONS) == config.SESSION_CONCURRENCY_LIMIT
276
 
@@ -452,7 +467,7 @@ def test_execute_does_not_use_episode_loading_copy(monkeypatch):
452
 
453
  body_text = page.evaluate("() => document.body.innerText")
454
  assert "The episode is loading..." not in body_text
455
- assert "too many people playing" not in body_text
456
  assert page.evaluate("() => document.getElementById('robomme_episode_loading_copy') === null") is True
457
 
458
  browser.close()
 
130
  proseBackground: null,
131
  proseBorderRadius: null,
132
  proseBoxShadow: null,
133
+ markdownDisplay: null,
134
+ markdownVisibility: null,
135
+ wrapperDisplay: null,
136
+ wrapperVisibility: null,
137
  };
138
  }
139
  const markdown = host.querySelector('[data-testid="markdown"]');
140
  const prose = markdown ? markdown.querySelector('.prose, .md') || markdown : null;
141
+ const wrapper = markdown ? markdown.parentElement : null;
142
  const text = prose ? ((prose.innerText || prose.textContent || '').trim()) : '';
143
  const rect = host.getBoundingClientRect();
144
  const style = getComputedStyle(host);
145
  const proseStyle = prose ? getComputedStyle(prose) : null;
146
+ const markdownStyle = markdown ? getComputedStyle(markdown) : null;
147
+ const wrapperStyle = wrapper ? getComputedStyle(wrapper) : null;
148
  return {
149
  present: true,
150
  visible: style.display !== 'none' && rect.width > 0 && rect.height > 0 && text.length > 0,
 
155
  proseBackground: proseStyle ? proseStyle.backgroundColor || null : null,
156
  proseBorderRadius: proseStyle ? proseStyle.borderRadius || null : null,
157
  proseBoxShadow: proseStyle ? proseStyle.boxShadow || null : null,
158
+ markdownDisplay: markdownStyle ? markdownStyle.display || null : null,
159
+ markdownVisibility: markdownStyle ? markdownStyle.visibility || null : null,
160
+ wrapperDisplay: wrapperStyle ? wrapperStyle.display || null : null,
161
+ wrapperVisibility: wrapperStyle ? wrapperStyle.visibility || null : null,
162
  };
163
  }"""
164
  )
 
282
  assert pages[-1].evaluate("() => document.getElementById('robomme_episode_loading_copy') === null") is True
283
  rejection_snapshot = _read_session_wait_overlay_snapshot(pages[-1])
284
  assert rejection_snapshot["content"] == config.UI_TEXT["progress"]["entry_rejected"]
285
+ assert rejection_snapshot["wrapperDisplay"] == "block"
286
+ assert rejection_snapshot["wrapperVisibility"] == "visible"
287
+ assert rejection_snapshot["markdownDisplay"] == "flex"
288
+ assert rejection_snapshot["markdownVisibility"] == "visible"
289
  assert _read_unified_overlay_text(pages[-1]) == config.UI_TEXT["progress"]["entry_rejected"]
290
  assert len(state_manager.GLOBAL_SESSIONS) == config.SESSION_CONCURRENCY_LIMIT
291
 
 
467
 
468
  body_text = page.evaluate("() => document.body.innerText")
469
  assert "The episode is loading..." not in body_text
470
+ assert "Too many users are trying the demo right now. Please try again later." not in body_text
471
  assert page.evaluate("() => document.getElementById('robomme_episode_loading_copy') === null") is True
472
 
473
  browser.close()
gradio-web/test/test_ui_native_layout_contract.py CHANGED
@@ -169,7 +169,7 @@ def test_native_ui_config_contains_phase_machine_and_precheck_chain(reload_modul
169
  )
170
  assert all("Loading environment, please wait..." not in str(v) for v in values)
171
  assert "The episode is loading..." in ui_layout.PROGRESS_TEXT_REWRITE_JS
172
- assert ui_layout.UI_TEXT["progress"]["entry_rejected"] == "too many people playing"
173
 
174
  log_output_comp = next(
175
  comp
 
169
  )
170
  assert all("Loading environment, please wait..." not in str(v) for v in values)
171
  assert "The episode is loading..." in ui_layout.PROGRESS_TEXT_REWRITE_JS
172
+ assert ui_layout.UI_TEXT["progress"]["entry_rejected"] == "Too many users are trying the demo right now. Please try again later."
173
 
174
  log_output_comp = next(
175
  comp
gradio-web/ui_layout.py CHANGED
@@ -444,8 +444,10 @@ PROGRESS_TEXT_REWRITE_JS = f"""
444
  markdown instanceof HTMLElement
445
  ? markdown.querySelector(".prose, .md") || markdown
446
  : null;
447
- const pending =
448
- markdown instanceof HTMLElement ? markdown.closest(".pending") : host.querySelector(".pending");
 
 
449
  const spinner =
450
  host.querySelector("svg") instanceof SVGElement
451
  ? host.querySelector("svg").closest("div")
@@ -474,7 +476,7 @@ PROGRESS_TEXT_REWRITE_JS = f"""
474
  wrap,
475
  markdown,
476
  prose,
477
- pending,
478
  spinner,
479
  }};
480
  }};
@@ -581,7 +583,7 @@ PROGRESS_TEXT_REWRITE_JS = f"""
581
  wrap,
582
  markdown,
583
  prose,
584
- pending,
585
  spinner,
586
  }} = overlayRefs;
587
  const markdownText =
@@ -594,9 +596,9 @@ PROGRESS_TEXT_REWRITE_JS = f"""
594
  if (spinner instanceof HTMLElement && overlayState !== overlayStateEpisodeLoad) {{
595
  clearInlineStyles(spinner, spinnerStyleKeys);
596
  }}
597
- if (pending instanceof HTMLElement) {{
598
- pending.style.setProperty("display", showMarkdown ? "block" : "none", "important");
599
- pending.style.setProperty("visibility", showMarkdown ? "visible" : "hidden", "important");
600
  }}
601
  if (markdown instanceof HTMLElement) {{
602
  markdown.style.setProperty("display", showMarkdown ? "flex" : "none", "important");
 
444
  markdown instanceof HTMLElement
445
  ? markdown.querySelector(".prose, .md") || markdown
446
  : null;
447
+ const markdownWrapper =
448
+ markdown instanceof HTMLElement && markdown.parentElement instanceof HTMLElement
449
+ ? markdown.parentElement
450
+ : null;
451
  const spinner =
452
  host.querySelector("svg") instanceof SVGElement
453
  ? host.querySelector("svg").closest("div")
 
476
  wrap,
477
  markdown,
478
  prose,
479
+ markdownWrapper,
480
  spinner,
481
  }};
482
  }};
 
583
  wrap,
584
  markdown,
585
  prose,
586
+ markdownWrapper,
587
  spinner,
588
  }} = overlayRefs;
589
  const markdownText =
 
596
  if (spinner instanceof HTMLElement && overlayState !== overlayStateEpisodeLoad) {{
597
  clearInlineStyles(spinner, spinnerStyleKeys);
598
  }}
599
+ if (markdownWrapper instanceof HTMLElement) {{
600
+ markdownWrapper.style.setProperty("display", showMarkdown ? "block" : "none", "important");
601
+ markdownWrapper.style.setProperty("visibility", showMarkdown ? "visible" : "hidden", "important");
602
  }}
603
  if (markdown instanceof HTMLElement) {{
604
  markdown.style.setProperty("display", showMarkdown ? "flex" : "none", "important");