Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 23 additions & 0 deletions tests/utils_/test_argparse_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@

import json
import os
Comment thread
hmellor marked this conversation as resolved.
Resolved
from argparse import BooleanOptionalAction

import pytest
import yaml
Expand Down Expand Up @@ -379,6 +380,28 @@ def test_load_config_file(tmp_path):
os.remove(str(config_file_path))


def test_load_config_file_false_store_true_dropped(tmp_path):
"""False values for store_true flags are silently dropped (correct)."""
config_data = {
"enable-feature": False,
"port": 8000,
}

config_file_path = tmp_path / "config.yaml"
with open(config_file_path, "w") as config_file:
yaml.dump(config_data, config_file)

parser = FlexibleArgumentParser()
parser.add_argument("--enable-feature", action=BooleanOptionalAction)
parser.add_argument("--port", type=int)

processed_args = parser.load_config_file(str(config_file_path))

assert "--enable-feature" not in processed_args
assert "--no-enable-feature" not in processed_args
assert "--port" in processed_args
Comment thread
hmellor marked this conversation as resolved.
Resolved
Comment thread
hmellor marked this conversation as resolved.
Resolved


def test_load_config_file_nested(tmp_path):
"""Test that nested dicts in YAML config are converted to JSON strings."""
config_data = {
Expand Down
2 changes: 2 additions & 0 deletions vllm/utils/argparse_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -573,6 +573,8 @@ def load_config_file(self, file_path: str) -> list[str]:
if isinstance(value, bool):
if value:
processed_args.append("--" + key)
elif (no_key := f"--no-{key}") in self._option_string_actions:
processed_args.append(no_key)
elif isinstance(value, list):
if value:
processed_args.append("--" + key)
Expand Down
Loading