Unverified Commit 04cecda7 authored by ishandhanani's avatar ishandhanani Committed by GitHub
Browse files

fix(sglang): Fix YAML config parsing for store_true arguments (#5513)

parent 748fee6b
...@@ -372,15 +372,27 @@ async def parse_args(args: list[str]) -> Config: ...@@ -372,15 +372,27 @@ async def parse_args(args: list[str]) -> Config:
# Remove --config-key from args (not recognized by SGLang) # Remove --config-key from args (not recognized by SGLang)
args = args[:key_index] + args[key_index + 2 :] args = args[:key_index] + args[key_index + 2 :]
# Extract boolean actions from the parser to handle them correctly in YAML # Merge config file arguments with CLI arguments.
boolean_actions = [] # ConfigArgumentMerger API changed after SGLang v0.5.7:
for action in parser._actions: # - New API (post-v0.5.7): accepts parser= for proper store_true detection
if hasattr(action, "dest") and hasattr(action, "action"): # - Old API (v0.5.7 and earlier): only accepts boolean_actions=
if action.action in ["store_true", "store_false"]: # We use inspect.signature to detect the API rather than version checking
boolean_actions.append(action.dest) # since unreleased builds may have the new API while still reporting v0.5.7.
# Related upstream issue: https://github.com/sgl-project/sglang/issues/16256
# Merge config file arguments with CLI arguments # Upstream fix PR: https://github.com/sgl-project/sglang/pull/16638
config_merger = ConfigArgumentMerger(boolean_actions=boolean_actions) import inspect
sig = inspect.signature(ConfigArgumentMerger.__init__)
if "parser" in sig.parameters:
config_merger = ConfigArgumentMerger(parser=parser)
else:
# Legacy path: extract store_true actions manually
boolean_actions = [
action.dest
for action in parser._actions
if isinstance(action, argparse._StoreTrueAction)
]
config_merger = ConfigArgumentMerger(boolean_actions=boolean_actions)
args = config_merger.merge_config_with_args(args) args = config_merger.merge_config_with_args(args)
parsed_args = parser.parse_args(args) parsed_args = parser.parse_args(args)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment