[Config] Retire get_global_server_args, and clear the deprecated flags that have a replacement (#38375)
This commit is contained in:
@@ -11,6 +11,7 @@ import pathlib as _pathlib
|
||||
import shutil
|
||||
import tempfile
|
||||
import unittest
|
||||
import warnings
|
||||
from unittest.mock import patch
|
||||
|
||||
import sglang as _sglang
|
||||
@@ -246,10 +247,33 @@ class TestServerArgsOwnership(_IsolatedServerArgs):
|
||||
# Identity, not equality: the slot holds the very object published.
|
||||
sentinel = ServerArgs(model_path="dummy")
|
||||
server_args_module.set_global_server_args_for_scheduler(sentinel)
|
||||
self.assertIs(server_args_module.get_global_server_args(), sentinel)
|
||||
self.assertIs(get_server_args(), sentinel)
|
||||
self.assertIs(get_context().server_args, sentinel)
|
||||
|
||||
def test_the_retired_accessor_raises_and_names_the_replacement(self):
|
||||
"""`get_global_server_args` is retired: it answered with the record,
|
||||
so a caller reading a field resolution had decided got a stale value
|
||||
and no error at all.
|
||||
|
||||
`RuntimeError` unconditionally, not a warning first: a
|
||||
`DeprecationWarning` is filtered by default outside `__main__`, so no
|
||||
production caller would have seen it, and under
|
||||
`-W error::DeprecationWarning` it would have changed the exception a
|
||||
caller catches. The message has to name where to read instead, since
|
||||
the answer differs by what the caller wanted.
|
||||
"""
|
||||
with self.assertRaises(RuntimeError) as cm:
|
||||
server_args_module.get_global_server_args()
|
||||
message = str(cm.exception)
|
||||
self.assertIn("runtime_context", message)
|
||||
self.assertIn("get_server_args()", message)
|
||||
|
||||
# And the type does not change when warnings are errors.
|
||||
with warnings.catch_warnings():
|
||||
warnings.simplefilter("error")
|
||||
with self.assertRaises(RuntimeError):
|
||||
server_args_module.get_global_server_args()
|
||||
|
||||
def test_tokenizer_alias_is_distinct_role_shim(self):
|
||||
# Deliberately NOT an alias: the two legacy setters publish with
|
||||
# different process roles (scheduler vs tokenizer).
|
||||
@@ -260,10 +284,9 @@ class TestServerArgsOwnership(_IsolatedServerArgs):
|
||||
|
||||
def test_pre_publish_error_verbatim(self):
|
||||
reset_context()
|
||||
for accessor in (get_server_args, server_args_module.get_global_server_args):
|
||||
with self.assertRaises(ValueError) as cm:
|
||||
accessor()
|
||||
self.assertEqual(str(cm.exception), "Global server args is not set yet!")
|
||||
with self.assertRaises(ValueError) as cm:
|
||||
get_server_args()
|
||||
self.assertEqual(str(cm.exception), "Global server args is not set yet!")
|
||||
|
||||
def test_republish_overwrite_allowed(self):
|
||||
first = ServerArgs(model_path="dummy")
|
||||
|
||||
Reference in New Issue
Block a user