Skip to content
Closed
Changes from all 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
51 changes: 33 additions & 18 deletions tests/e2e/singlecard/models/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,12 @@ def pytest_addoption(parser):
default="./benchmarks/accuracy/Qwen3-8B-Base.md",
help="Path to the report output file",
)
parser.addoption(
"--report-dir",
action="store",
default="./benchmarks/accuracy",
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

it's better to keep current path, ./, otherwise the ./benchmarks/accuracy is required.

Copy link
Copy Markdown
Collaborator Author

@wxsIcey wxsIcey Aug 5, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

help="Directory to store report files when using config list",
)


@pytest.fixture(scope="session")
Expand All @@ -48,26 +54,35 @@ def config(pytestconfig):
return pytestconfig.getoption("--config")


@pytest.fixture(scope="session")
def report_output(pytestconfig):
return pytestconfig.getoption("--report_output")
@pytest.fixture(scope="function")
def report_output(pytestconfig, config_filename):
if pytestconfig.getoption("--config-list-file"):
report_dir = pytestconfig.getoption("--report-dir")
model_name = Path(config_filename).stem
report_path = Path(report_dir) / f"{model_name}.md"
report_path.parent.mkdir(parents=True, exist_ok=True)
return report_path

output_path = pytestconfig.getoption("--report_output")
if output_path:
output_path = Path(output_path)
return output_path


def pytest_generate_tests(metafunc):
if "config_filename" in metafunc.fixturenames:
# If config specified, use the --config directly
single_config = metafunc.config.getoption("--config")
if single_config:
metafunc.parametrize("config_filename",
[Path(single_config).resolve()])
if metafunc.config.getoption("--config-list-file"):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why reorder this?

the original thoughts is that --config has higer priority than --config-list-file

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Because the --config option has default settings, if --config is checked first, the logic for --config-list-file will definitely not be executed.

rel_path = metafunc.config.getoption("--config-list-file")
config_list_file = Path(rel_path).resolve()
config_dir = config_list_file.parent
with open(config_list_file, encoding="utf-8") as f:
configs = [
config_dir / line.strip() for line in f
if line.strip() and not line.startswith("#")
]
metafunc.parametrize("config_filename", configs)
return
# Otherwise, check --config-list-file
rel_path = metafunc.config.getoption("--config-list-file")
config_list_file = Path(rel_path).resolve()
config_dir = config_list_file.parent
with open(config_list_file, encoding="utf-8") as f:
configs = [
config_dir / line.strip() for line in f
if line.strip() and not line.startswith("#")
]
metafunc.parametrize("config_filename", configs)
single_config = metafunc.config.getoption("--config")
config_path = Path(single_config).resolve()

metafunc.parametrize("config_filename", [config_path])
Loading