Skip to content

Commit 78b94d7

Browse files
authored
fix(sglang): Fix YAML config parsing for store_true arguments (#5513) (#5520)
1 parent 2589917 commit 78b94d7

File tree

1 file changed

+21
-9
lines changed
  • components/src/dynamo/sglang

1 file changed

+21
-9
lines changed

components/src/dynamo/sglang/args.py

Lines changed: 21 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -372,15 +372,27 @@ async def parse_args(args: list[str]) -> Config:
372372
# Remove --config-key from args (not recognized by SGLang)
373373
args = args[:key_index] + args[key_index + 2 :]
374374

375-
# Extract boolean actions from the parser to handle them correctly in YAML
376-
boolean_actions = []
377-
for action in parser._actions:
378-
if hasattr(action, "dest") and hasattr(action, "action"):
379-
if action.action in ["store_true", "store_false"]:
380-
boolean_actions.append(action.dest)
381-
382-
# Merge config file arguments with CLI arguments
383-
config_merger = ConfigArgumentMerger(boolean_actions=boolean_actions)
375+
# Merge config file arguments with CLI arguments.
376+
# ConfigArgumentMerger API changed after SGLang v0.5.7:
377+
# - New API (post-v0.5.7): accepts parser= for proper store_true detection
378+
# - Old API (v0.5.7 and earlier): only accepts boolean_actions=
379+
# We use inspect.signature to detect the API rather than version checking
380+
# since unreleased builds may have the new API while still reporting v0.5.7.
381+
# Related upstream issue: https://github.com/sgl-project/sglang/issues/16256
382+
# Upstream fix PR: https://github.com/sgl-project/sglang/pull/16638
383+
import inspect
384+
385+
sig = inspect.signature(ConfigArgumentMerger.__init__)
386+
if "parser" in sig.parameters:
387+
config_merger = ConfigArgumentMerger(parser=parser)
388+
else:
389+
# Legacy path: extract store_true actions manually
390+
boolean_actions = [
391+
action.dest
392+
for action in parser._actions
393+
if isinstance(action, argparse._StoreTrueAction)
394+
]
395+
config_merger = ConfigArgumentMerger(boolean_actions=boolean_actions)
384396
args = config_merger.merge_config_with_args(args)
385397

386398
parsed_args = parser.parse_args(args)

0 commit comments

Comments
 (0)