| 1 | # SPDX-License-Identifier: Apache-2.0 |
| 2 | # SPDX-FileCopyrightText: Copyright contributors to the vLLM project |
| 3 | from pathlib import Path |
| 4 | |
| 5 | import pytest |
| 6 | |
| 7 | |
| 8 | def pytest_addoption(parser): |
| 9 | parser.addoption( |
| 10 | "--config-list-file", |
| 11 | action="store", |
| 12 | help="Path to the file listing model config YAMLs (one per line)", |
| 13 | ) |
| 14 | parser.addoption( |
| 15 | "--tp-size", |
| 16 | action="store", |
| 17 | default="1", |
| 18 | help="Tensor parallel size to use for evaluation", |
| 19 | ) |
| 20 | |
| 21 | |
| 22 | @pytest.fixture(scope="session") |
| 23 | def config_list_file(pytestconfig, config_dir): |
| 24 | rel_path = pytestconfig.getoption("--config-list-file") |
| 25 | return config_dir / rel_path |
| 26 | |
| 27 | |
| 28 | @pytest.fixture(scope="session") |
| 29 | def tp_size(pytestconfig): |
| 30 | return pytestconfig.getoption("--tp-size") |
| 31 | |
| 32 | |
| 33 | def pytest_generate_tests(metafunc): |
| 34 | if "config_filename" in metafunc.fixturenames: |
| 35 | rel_path = metafunc.config.getoption("--config-list-file") |
| 36 | config_list_file = Path(rel_path).resolve() |
| 37 | config_dir = config_list_file.parent |
| 38 | with open(config_list_file, encoding="utf-8") as f: |
| 39 | configs = [ |
| 40 | config_dir / line.strip() |
| 41 | for line in f |
| 42 | if line.strip() and not line.startswith("#") |
| 43 | ] |
| 44 | metafunc.parametrize("config_filename", configs) |