mirror of
https://git.datalinker.icu/vllm-project/vllm.git
synced 2026-01-10 09:25:18 +08:00
[Bugfix] fix when config.yaml config value is list parse error (#23528)
Signed-off-by: rongfu.leng <rongfu.leng@daocloud.io>
This commit is contained in:
parent
9de25c294b
commit
8dbf6ed7be
@ -5,13 +5,17 @@
|
||||
import asyncio
|
||||
import hashlib
|
||||
import json
|
||||
import os
|
||||
import pickle
|
||||
import socket
|
||||
import tempfile
|
||||
from collections.abc import AsyncIterator
|
||||
from pathlib import Path
|
||||
from unittest.mock import patch
|
||||
|
||||
import pytest
|
||||
import torch
|
||||
import yaml
|
||||
import zmq
|
||||
from transformers import AutoTokenizer
|
||||
from vllm_test_utils.monitor import monitor
|
||||
@ -991,3 +995,40 @@ def test_current_stream_multithread():
|
||||
child_thread.join(timeout=5)
|
||||
if child_thread.is_alive():
|
||||
pytest.fail("Child thread failed to exit properly")
|
||||
|
||||
|
||||
def test_load_config_file(tmp_path):
|
||||
# Define the configuration data
|
||||
config_data = {
|
||||
"enable-logging": True,
|
||||
"list-arg": ["item1", "item2"],
|
||||
"port": 12323,
|
||||
"tensor-parallel-size": 4
|
||||
}
|
||||
|
||||
# Write the configuration data to a temporary YAML file
|
||||
config_file_path = tmp_path / "config.yaml"
|
||||
with open(config_file_path, "w") as config_file:
|
||||
yaml.dump(config_data, config_file)
|
||||
|
||||
# Initialize the parser
|
||||
parser = FlexibleArgumentParser()
|
||||
|
||||
# Call the function with the temporary file path
|
||||
processed_args = parser.load_config_file(str(config_file_path))
|
||||
|
||||
# Expected output
|
||||
expected_args = [
|
||||
"--enable-logging",
|
||||
"--list-arg",
|
||||
"item1",
|
||||
"item2",
|
||||
"--port",
|
||||
"12323",
|
||||
"--tensor-parallel-size",
|
||||
"4",
|
||||
]
|
||||
|
||||
# Assert that the processed arguments match the expected output
|
||||
assert processed_args == expected_args
|
||||
os.remove(str(config_file_path))
|
||||
|
||||
@ -1974,7 +1974,7 @@ class FlexibleArgumentParser(ArgumentParser):
|
||||
|
||||
file_path = args[index + 1]
|
||||
|
||||
config_args = self._load_config_file(file_path)
|
||||
config_args = self.load_config_file(file_path)
|
||||
|
||||
# 0th index is for {serve,chat,complete}
|
||||
# optionally followed by model_tag (only for serve)
|
||||
@ -2005,7 +2005,7 @@ class FlexibleArgumentParser(ArgumentParser):
|
||||
|
||||
return args
|
||||
|
||||
def _load_config_file(self, file_path: str) -> list[str]:
|
||||
def load_config_file(self, file_path: str) -> list[str]:
|
||||
"""Loads a yaml file and returns the key value pairs as a
|
||||
flattened list with argparse like pattern
|
||||
```yaml
|
||||
@ -2046,6 +2046,11 @@ class FlexibleArgumentParser(ArgumentParser):
|
||||
if isinstance(value, bool) and key not in store_boolean_arguments:
|
||||
if value:
|
||||
processed_args.append('--' + key)
|
||||
elif isinstance(value, list):
|
||||
if value:
|
||||
processed_args.append('--' + key)
|
||||
for item in value:
|
||||
processed_args.append(str(item))
|
||||
else:
|
||||
processed_args.append('--' + key)
|
||||
processed_args.append(str(value))
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user