feat: add --skip-resource-checks flag to bypass hardware capability g…#889
feat: add --skip-resource-checks flag to bypass hardware capability g…#889ajbozarth wants to merge 1 commit intogenerative-computing:mainfrom
Conversation
…ates 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 generative-computing#758 Assisted-by: Claude Code Signed-off-by: Alex Bozarth <ajbozart@us.ibm.com>
|
The PR description has been updated. Please fill out the template for your PR to be reviewed. |
|
@planetf1 what do you think? this spun out of one of our old discussions |
psschwei
left a comment
There was a problem hiding this comment.
Review Summary
Verdict: Request minor changes — the approach is sound but has a few gaps to address.
What's good
- Clean separation of concerns: flag registered in conftest, propagated as env var, consumed in predicates. The predicates don't need to know about pytest config.
- Correctly scoped — only bypasses GPU/RAM checks, leaving API key and Ollama checks alone.
- Early return placement avoids slow hardware detection (
sysctlsubprocess,torch.cudainit) when bypassed. - Docs honestly mention "tests may fail naturally" on machines with no GPU.
Issues to address
1. No tests for the new feature
A simple unit test with monkeypatch.setenv verifying the predicates return non-skipping markers would prevent regressions:
def test_require_gpu_bypass(monkeypatch):
monkeypatch.setenv("_MELLEA_SKIP_RESOURCE_CHECKS", "1")
marker = require_gpu(min_vram_gb=9999)
assert marker.args[0] is False2. docs/examples/conftest.py already has --ignore-gpu-check / --ignore-ram-check / --ignore-all-checks
The project now has two parallel mechanisms for skipping hardware checks. A user passing --skip-resource-checks won't get examples bypassed. At minimum, document the gap or file a follow-up issue to unify them.
3. test/MARKERS_GUIDE.md not updated
This is the canonical reference for resource gating predicates but has no mention of the new override flag.
4. Empty reason="" on bypass (predicates.py:97, predicates.py:130)
Consistent with existing pattern (line 108), but reason="resource check bypassed (--skip-resource-checks)" would help debugging with pytest -rs.
5. conftest.py:265-267 — try/except could be simplified
Using config.getoption("skip_resource_checks", default=False) (dest name, not flag name) avoids the need for the try/except block entirely.
6. Leading underscore on public env var (_MELLEA_SKIP_RESOURCE_CHECKS)
The docs present this as a user-facing CI escape hatch, but _ conventionally means internal. Consider MELLEA_SKIP_RESOURCE_CHECKS if it's a supported interface.
Minor / nice-to-have
- Add a
pytest_unconfigurehook to clean up the env var (matters if pytest is invoked programmatically multiple times in the same process). - One-line addition to
AGENTS.mdSection 1 quick reference.
Misc PR
Type of PR
Description
Adds a
--skip-resource-checkspytest flag that bypassesrequire_gpuandrequire_ramhardware-capability gates. When passed, tests that would normally be skipped due to insufficient VRAM or RAM will run regardless — useful for verifying test logic on under-spec machines or reproducing failures reported from higher-spec hardware.The flag is wired through
pytest_configure(which runs before test collection) by setting the_MELLEA_SKIP_RESOURCE_CHECKSenv var, which the predicates check at call time. The same env var can be set directly as a CI escape hatch. API credential and Ollama checks are intentionally unaffected.Testing
Attribution