From b01d291468e38acddcfb9606261c74704c671f7b Mon Sep 17 00:00:00 2001 From: Alex Bozarth Date: Mon, 20 Apr 2026 15:03:50 -0500 Subject: [PATCH 1/3] feat: add --skip-resource-checks flag to bypass hardware capability gates Adds a pytest CLI flag that disables VRAM/RAM skip predicates, allowing developers to force-run hardware-gated tests on under-spec machines. API credential and Ollama checks are intentionally unaffected. Closes #758 Assisted-by: Claude Code Signed-off-by: Alex Bozarth --- test/README.md | 4 ++++ test/conftest.py | 14 ++++++++++++++ test/predicates.py | 6 ++++++ 3 files changed, 24 insertions(+) diff --git a/test/README.md b/test/README.md index 4c4c7a148..abc3d9d2a 100644 --- a/test/README.md +++ b/test/README.md @@ -136,6 +136,10 @@ pytestmark = [pytest.mark.e2e, pytest.mark.huggingface, require_gpu(), require_r | `require_ram(min_gb=N)` | N GB+ system RAM | | `require_api_key("ENV_VAR")` | Specific API credentials | +Pass `--skip-resource-checks` to bypass `require_gpu` and `require_ram` gates — useful for running test logic on under-spec hardware or reproducing failures from higher-spec machines. API credential and Ollama checks are unaffected. On machines with no GPU at all, gated tests will run and may fail naturally. + +The env var `_MELLEA_SKIP_RESOURCE_CHECKS=1` has the same effect and can be used in CI environments without modifying the pytest invocation. + > **Deprecated:** The markers `requires_gpu`, `requires_heavy_ram`, `requires_api_key`, > and `requires_gpu_isolation` are deprecated. Existing tests using them still work > (conftest auto-skip handles them) but new tests must use predicates. Migrate legacy diff --git a/test/conftest.py b/test/conftest.py index a904a06ba..2bcd24209 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -209,6 +209,12 @@ def add_option_safe(option_name, **kwargs): default=False, help="Group tests by backend and run them together (reduces GPU memory fragmentation)", ) + add_option_safe( + "--skip-resource-checks", + action="store_true", + default=False, + help="Skip hardware capability gates (VRAM/RAM). API credential and Ollama checks are unaffected.", + ) BACKEND_MARKERS: dict[str, str] = { @@ -254,6 +260,14 @@ def pytest_configure(config): "markers", "llm: Tests that make LLM calls (deprecated — use e2e instead)" ) + # Propagate --skip-resource-checks as env var so predicates.py can read it + # at module-import time (before test collection begins). + try: + if config.getoption("--skip-resource-checks", default=False): + os.environ["_MELLEA_SKIP_RESOURCE_CHECKS"] = "1" + except (ValueError, AttributeError): + pass + # ============================================================================ # Heavy GPU Test Process Isolation diff --git a/test/predicates.py b/test/predicates.py index 26f34c507..a23c48696 100644 --- a/test/predicates.py +++ b/test/predicates.py @@ -94,6 +94,9 @@ def require_gpu(*, min_vram_gb: int | None = None): Args: min_vram_gb: Minimum VRAM in GB. When ``None``, any GPU suffices. """ + if os.environ.get("_MELLEA_SKIP_RESOURCE_CHECKS"): + return pytest.mark.skipif(False, reason="") + if not _gpu_available(): return pytest.mark.skipif(True, reason="No GPU available (CUDA/MPS)") @@ -124,6 +127,9 @@ def _system_ram_gb() -> float: def require_ram(min_gb: int): """Skip unless the system has at least *min_gb* GB of RAM.""" + if os.environ.get("_MELLEA_SKIP_RESOURCE_CHECKS"): + return pytest.mark.skipif(False, reason="") + ram = _system_ram_gb() if ram > 0 and ram < min_gb: return pytest.mark.skipif( From 31c450f011c1a689f51fe331781a72150e9a3108 Mon Sep 17 00:00:00 2001 From: Alex Bozarth Date: Tue, 21 Apr 2026 15:47:52 -0500 Subject: [PATCH 2/3] fix: address review feedback on --skip-resource-checks Assisted-by: Claude Code Signed-off-by: Alex Bozarth --- docs/examples/conftest.py | 13 ++++++++++++- test/conftest.py | 12 +++++++----- 2 files changed, 19 insertions(+), 6 deletions(-) diff --git a/docs/examples/conftest.py b/docs/examples/conftest.py index d4c3c22cb..3538b1326 100644 --- a/docs/examples/conftest.py +++ b/docs/examples/conftest.py @@ -187,6 +187,12 @@ def add_option_safe(option_name, **kwargs): default=False, help="Ignore all requirement checks (GPU, RAM, Ollama, API keys)", ) + add_option_safe( + "--skip-resource-checks", + action="store_true", + default=False, + help="Skip hardware capability gates (VRAM/RAM). API credential and Ollama checks are unaffected.", + ) def _collect_vllm_example_files(session) -> list[str]: @@ -564,7 +570,12 @@ def pytest_runtest_setup(item): # Get config options from CLI (matching test/conftest.py behavior) config = item.config ignore_all = config.getoption("--ignore-all-checks", default=False) - ignore_gpu = config.getoption("--ignore-gpu-check", default=False) or ignore_all + skip_resource = config.getoption("skip_resource_checks", default=False) + ignore_gpu = ( + config.getoption("--ignore-gpu-check", default=False) + or ignore_all + or skip_resource + ) ignore_ollama = ( config.getoption("--ignore-ollama-check", default=False) or ignore_all ) diff --git a/test/conftest.py b/test/conftest.py index 2bcd24209..b3e92f930 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -262,11 +262,13 @@ def pytest_configure(config): # Propagate --skip-resource-checks as env var so predicates.py can read it # at module-import time (before test collection begins). - try: - if config.getoption("--skip-resource-checks", default=False): - os.environ["_MELLEA_SKIP_RESOURCE_CHECKS"] = "1" - except (ValueError, AttributeError): - pass + if config.getoption("skip_resource_checks", default=False): + os.environ["_MELLEA_SKIP_RESOURCE_CHECKS"] = "1" + + +def pytest_unconfigure(_config): + """Clean up env var so repeated programmatic pytest invocations are unaffected.""" + os.environ.pop("_MELLEA_SKIP_RESOURCE_CHECKS", None) # ============================================================================ From 31ef184c6ae42ce72383bf0e503274c4059a5707 Mon Sep 17 00:00:00 2001 From: Alex Bozarth Date: Wed, 22 Apr 2026 09:40:48 -0500 Subject: [PATCH 3/3] fix: remove invalid _config arg from pytest_unconfigure hookimpl pluggy rejects hookimpl arguments that don't exist in the hookspec; pytest_unconfigure's spec has no _config parameter. Assisted-by: Claude Code Signed-off-by: Alex Bozarth --- test/conftest.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/conftest.py b/test/conftest.py index b3e92f930..e65f552e0 100644 --- a/test/conftest.py +++ b/test/conftest.py @@ -266,7 +266,7 @@ def pytest_configure(config): os.environ["_MELLEA_SKIP_RESOURCE_CHECKS"] = "1" -def pytest_unconfigure(_config): +def pytest_unconfigure(): """Clean up env var so repeated programmatic pytest invocations are unaffected.""" os.environ.pop("_MELLEA_SKIP_RESOURCE_CHECKS", None)