Skip to content

Commit 0a926c6

Browse files
committed
fix: refresh video support bugfix & add e2e test
1 parent bf11ef6 commit 0a926c6

9 files changed

Lines changed: 1505 additions & 10 deletions

File tree

development.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,11 @@ Run CPU only tests:
1010

1111
```bash
1212
pip install pytest
13+
# CPU-only tests (unit + fake e2e)
1314
pytest tests/unit -v
15+
16+
# Real E2E tests (GPU required, longer runtime)
17+
pytest tests/e2e/test_e2e_sglang.py -v -s
1418
```
1519

1620
## Benchmark Scripts

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,4 +40,4 @@ package-dir = { "" = "src" }
4040
where = ["src"]
4141

4242
[tool.pytest.ini_options]
43-
testpaths = ["tests/unit"]
43+
testpaths = ["tests/unit", "tests/e2e"]

src/sglang_diffusion_routing/cli/main.py

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -25,18 +25,9 @@ def _run_router_server(
2525
) from exc
2626

2727
worker_urls = list(args.worker_urls or [])
28-
refresh_tasks = []
2928
for url in worker_urls:
3029
normalized_url = router.normalize_worker_url(url)
3130
router.register_worker(normalized_url)
32-
refresh_tasks.append(router.refresh_worker_video_support(normalized_url))
33-
34-
if refresh_tasks:
35-
36-
async def _refresh_all_worker_video_support() -> None:
37-
await asyncio.gather(*refresh_tasks)
38-
39-
asyncio.run(_refresh_all_worker_video_support())
4031

4132
print(f"{log_prefix} starting router on {args.host}:{args.port}", flush=True)
4233
print(

src/sglang_diffusion_routing/router/diffusion_router.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ def _setup_routes(self) -> None:
6969
)
7070

7171
async def _start_background_health_check(self) -> None:
72+
# Probe capability for pre-registered workers in the active server loop.
73+
unknown_workers = [
74+
url for url, support in self.worker_video_support.items() if support is None
75+
]
76+
if unknown_workers:
77+
await asyncio.gather(
78+
*(self.refresh_worker_video_support(url) for url in unknown_workers),
79+
return_exceptions=True,
80+
)
81+
7282
if self._health_task is None or self._health_task.done():
7383
self._health_task = asyncio.create_task(self._health_check_loop())
7484

@@ -383,6 +393,12 @@ async def generate(self, request: Request):
383393

384394
async def generate_video(self, request: Request):
385395
"""Route video generation to /v1/videos."""
396+
if not self.worker_request_counts:
397+
return JSONResponse(
398+
status_code=503,
399+
content={"error": "No workers registered in the pool"},
400+
)
401+
386402
candidate_workers = [
387403
worker_url
388404
for worker_url, support in self.worker_video_support.items()

tests/conftest.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
"""Pytest configuration: force local src import precedence."""
2+
3+
from __future__ import annotations
4+
5+
import sys
6+
from pathlib import Path
7+
8+
src_str = str(Path(__file__).resolve().parent.parent / "src")
9+
while src_str in sys.path:
10+
sys.path.remove(src_str)
11+
sys.path.insert(0, src_str)

tests/e2e/__init__.py

Whitespace-only changes.

0 commit comments

Comments
 (0)