[router] Allow empty worker list for sglang.launch_router (#2979)

This commit is contained in:
Byron Hsu
2025-01-19 17:05:23 +08:00
committed by GitHub
parent 53cc91e504
commit ef18b0eda2
8 changed files with 46 additions and 17 deletions

View File

@@ -27,7 +27,7 @@ def setup_logger():
@dataclasses.dataclass
class RouterArgs:
# Worker configuration
worker_urls: List[str]
worker_urls: List[str] = dataclasses.field(default_factory=list)
host: str = "127.0.0.1"
port: int = 30000
@@ -141,8 +141,9 @@ class RouterArgs:
use_router_prefix: If True, look for arguments with 'router-' prefix
"""
prefix = "router_" if use_router_prefix else ""
worker_urls = args.worker_urls if args.worker_urls is not None else []
return cls(
worker_urls=args.worker_urls,
worker_urls=worker_urls,
host=args.host,
port=args.port,
policy=getattr(args, f"{prefix}policy"),
@@ -237,7 +238,6 @@ Examples:
def main() -> None:
logger = setup_logger()
router_args = parse_router_args(sys.argv[1:])
router = launch_router(router_args)