Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
change
sglang
Commits
b763cf7e
Unverified
Commit
b763cf7e
authored
Jul 18, 2025
by
Simo Lin
Committed by
GitHub
Jul 18, 2025
Browse files
[router] allow router to have empty workers (#8160)
parent
8fcc55cf
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
24 additions
and
2 deletions
+24
-2
sgl-router/py_src/sglang_router/launch_router.py
sgl-router/py_src/sglang_router/launch_router.py
+2
-1
sgl-router/py_test/test_launch_router.py
sgl-router/py_test/test_launch_router.py
+22
-1
No files found.
sgl-router/py_src/sglang_router/launch_router.py
View file @
b763cf7e
...
...
@@ -97,7 +97,8 @@ class RouterArgs:
parser
.
add_argument
(
"--worker-urls"
,
type
=
str
,
nargs
=
"+"
,
nargs
=
"*"
,
default
=
[],
help
=
"List of worker URLs (e.g., http://worker1:8000 http://worker2:8000)"
,
)
...
...
sgl-router/py_test/test_launch_router.py
View file @
b763cf7e
...
...
@@ -90,7 +90,9 @@ class TestLaunchRouter(unittest.TestCase):
def
test_launch_router_with_empty_worker_urls
(
self
):
args
=
self
.
create_router_args
(
worker_urls
=
[])
self
.
run_router_process
(
args
)
# Expected error
self
.
run_router_process
(
args
)
# Should start successfully with empty worker list
def
test_launch_router_with_service_discovery
(
self
):
# Test router startup with service discovery enabled but no selectors
...
...
@@ -279,6 +281,25 @@ class TestLaunchRouter(unittest.TestCase):
self
.
assertEqual
(
router_args
.
prefill_selector
,
{})
self
.
assertEqual
(
router_args
.
decode_selector
,
{})
def
test_empty_worker_urls_args_parsing
(
self
):
"""Test that router accepts no worker URLs and defaults to empty list."""
import
argparse
from
sglang_router.launch_router
import
RouterArgs
parser
=
argparse
.
ArgumentParser
()
RouterArgs
.
add_cli_args
(
parser
)
# Test with no --worker-urls argument at all
args
=
parser
.
parse_args
([
"--policy"
,
"random"
,
"--port"
,
"30000"
])
router_args
=
RouterArgs
.
from_cli_args
(
args
)
self
.
assertEqual
(
router_args
.
worker_urls
,
[])
# Test with explicit empty --worker-urls
args
=
parser
.
parse_args
([
"--worker-urls"
,
"--policy"
,
"random"
])
router_args
=
RouterArgs
.
from_cli_args
(
args
)
self
.
assertEqual
(
router_args
.
worker_urls
,
[])
if
__name__
==
"__main__"
:
unittest
.
main
()
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment