|
import pytest |
|
from pathlib import Path |
|
|
|
|
|
_test_failed_incremental: dict[str, dict[tuple[int, ...], str]] = {} |
|
|
|
|
|
def pytest_addoption(parser): |
|
parser.addoption("--cache_path", type=Path, |
|
help="Huggingface cache path (optional)") |
|
parser.addoption("--llama_path", type=Path, required=True, |
|
help="Path where the raw 7B weights are located (llama1)") |
|
parser.addoption("--llama2_path", type=Path, required=True, |
|
help="Path where the raw llama-2-7b weights are located") |
|
parser.addoption("--tmp_dir", type=Path, |
|
help="Prefix of the tempdir to create (optional)") |
|
parser.addoption("--data_path", type=Path, required=True, |
|
help="Path where the megatron dataset is located") |
|
parser.addoption("--vocab_path", type=Path, required=True, |
|
help="Meta's vocabfile") |
|
|
|
|
|
def pytest_runtest_makereport(item, call): |
|
if "incremental" in item.keywords: |
|
|
|
if call.excinfo is not None: |
|
|
|
|
|
cls_name = str(item.cls) |
|
|
|
parametrize_index = ( |
|
tuple(item.callspec.indices.values()) |
|
if hasattr(item, "callspec") |
|
else () |
|
) |
|
|
|
test_name = item.originalname or item.name |
|
|
|
_test_failed_incremental.setdefault(cls_name, {}).setdefault( |
|
parametrize_index, test_name |
|
) |
|
|
|
|
|
def pytest_runtest_setup(item): |
|
if "incremental" in item.keywords: |
|
|
|
cls_name = str(item.cls) |
|
|
|
if cls_name in _test_failed_incremental: |
|
|
|
parametrize_index = ( |
|
tuple(item.callspec.indices.values()) |
|
if hasattr(item, "callspec") |
|
else () |
|
) |
|
|
|
test_name = _test_failed_incremental[cls_name].get(parametrize_index, None) |
|
|
|
if test_name is not None: |
|
pytest.xfail("previous test failed ({})".format(test_name)) |
|
|