Repository navigation
fix(test): fail the run when a check fails, and fix the NVMLError contract - #19
Conversation
yeahdongcn
left a comment
There was a problem hiding this comment.
Merge verdict: no blocking findings — ready to merge.
Reviewed c026ef4 (+25/−0, test-only). The eight suppressed names are exactly the eight collection errors; the remaining 24 collected items match the author's 24 passed. Mechanism checked in the pytest 9.0.1 source; make test was not re-run here (no MTML hardware).
CI: Unit-test-job is pending in both runs — not in yet, nothing failed, so merge waits on the runner.
Findings: 0 blocking · 2 nit
| nit | location | problem | fix |
|---|---|---|---|
| nit | .github/workflows/main.yml:15 |
make test runs in no CI job and skips both suite classes |
run the three scripts from make test; add CI --collect-only |
| nit | test_pymtml.py:373 |
same three-line rationale copied into three files; one clause narrates the past | collapse to # Helper for main(); not a pytest case. |
Diff map · verification · what I could not verify
Diff map (one commit, three files, additions only)
test_pymtml.py:373-376— module-leveltest_error.__test__ = False; helper isdef test_error(name, func)at :25.test_pynvml.py:397-399— module-leveltest_api.__test__ = False; helper isdef test_api(name, func)at :27.test_sglang_compat.py:271-282— loop over the six probes that take required parameters::61,:117,:152,:177,:200,:217.
Verified statically
__test__ = Falsesuppresses collection silently:_pytest/python.py:243readselif getattr(obj, "__test__", True):and returnsNone, so no item, no fixture lookup, noPytestCollectionWarning.- Every function pytest would collect with a required argument is covered. Outside the six probes, the only module-level
test_*names aretest_error(marked) intest_pymtml.pyandtest_api(marked) intest_pynvml.py;test_init_shutdown_cycleandtest_p2p_constantstake no arguments. - Item arithmetic: 10 (
test_abi_layout.py) + 7 (test_library_lifecycle.py) + 3 (test_library_loading.py) + 2 (test_mtlink_visibility.py) + 1 + 1 = 24. Noparametrizeand noimport pytestin any of the seven files, so 24 is exact, and 6 + 1 + 1 = the 8 reported errors. MtmlTestSuite/PynvmlTestSuiteare still not collected: pytest'spython_classesdefault is["Test"](prefix match), so theirtest_*methods were never items and this diff does not silence any of them.- Script entrypoints unchanged: the markers are attribute writes;
main()andif __name__ == "__main__"are untouched, so the three CI steps that run the scripts behave identically. - No
pyproject.toml,setup.cfg,pytest.iniorconftest.pyin the head tree (checked the full blob list viagit/trees/c026ef43…?recursive=1), so nothing else re-enables collection here. setup.pyshipspy_modules=["pymtml", "example"]; the test scripts are not in the wheel, so the new comments are not shipped artifacts.
Mechanical evidence — the four # ==== banners at test_sglang_compat.py:231/234/263/265 are context lines (the hunk starts at 268), i.e. pre-existing at the base commit, not introduced by this PR; .pre-commit-config.yaml:40 ignores E266 deliberately so banners stay legal here. Not a finding.
Gate — 10/10 hooks passed @ c026ef4.
Considered and rejected — scoping collection with --ignore/testpaths would also drop the two genuine tests living inside these files; moving the probes into a non-Test-prefixed class would move every call site in main(); a module-level __test__ = False would drop test_p2p_constants.
Could not verify — the author's runtime evidence (24 passed in 0.18s, the three scripts exiting 0 on the S5000 container): no MUSA/MTML host in this session and CI has not reported yet. Both Unit-test-job runs are pending.
This round ends auto-review for c026ef4; a later push starts a fresh cycle at round 1.
auto-review round 1/3 · verdict: clean
`make test` ran `pytest test_*.py`, which collected functions that are not pytest cases (two helpers and six device probes that take their arguments from `main()`), so it stopped with "fixture 'devices' not found": 24 passed, 8 errors. The scripts behind the other CI steps had the opposite problem: they printed every failed API and still exited 0, so a broken binding left CI green. `test_error` and `test_api` counted nothing and their 77 return values were dropped on the floor. - Mark the helpers `__test__ = False` (pytest's documented opt-out), so `make test` is 24 passed. - Count every check in `test_error` / `test_api`, print a summary, and exit 1 when one failed. `Not Supported` is the platform answering rather than a defect, so it counts as skipped and keeps CI green. - Fix the exception contract the pynvml side documents: `NVMLError` was a subclass of `MTMLError`, while `_mtmlCheckReturn` raises `MTMLError`, so `except pynvml.NVMLError` - the pattern `test_pynvml.py` itself uses - caught nothing and fell through to `except Exception`. MANUAL.md already documents `NVMLError = MTMLError`; the code now matches it, which also makes every `NVMLError_*` a subclass of `NVMLError` as pynvml guarantees. Evidence on an MTT S5000 (vllm:v0.32.0-ph1-5.2.0-torch2.13.0): make test 24 passed test_pymtml.py exit 0 646 passed, 120 skipped (not supported), 0 failed test_pynvml.py exit 0 57 passed, 2 skipped (not supported), 0 failed test_sglang_compat.py exit 0 nvmlDeviceGetMaxClockInfo (GRAPHICS): [NVMLError: Not Supported] (not supported) Injecting a RuntimeError into one API makes `main()` return 1, so the gate fires.
c026ef4 to
fc39110
Compare
Three things were wrong with the test surface, all of them visible only when
the suite is read closely:
1.
make testcollected functions that are not tests. The two helpers(
test_error,test_api) and the six device probes intest_sglang_compat.pytake their arguments from
main(), so pytest stopped withfixture 'devices' not found: 24 passed, 8 errors.2. The scripts never failed.
test_error/test_apicounted nothing andtheir 77 return values were dropped, and
main()returned 1 only when thelibrary failed to initialize. A broken API printed a line and the script exited
0, so the CI steps could not see it. Measured on an S5000 before this change:
test_pymtml.pyprinted 120[MTMLError: Not Supported]lines and exited 0.3. The pynvml exception contract did not hold.
NVMLErrorwas a subclassof
MTMLError, while_mtmlCheckReturnraisesMTMLError, soexcept pynvml.NVMLError— the patterntest_pynvml.pyitself uses — caughtnothing and fell through to
except Exception. The wrong branch is visible inthe output:
nvmlDeviceGetMaxClockInfo (GRAPHICS): [Error: Not Supported].MANUAL.md already documents
NVMLError = MTMLError; the code now matches, whichalso makes every
NVMLError_*a subclass ofNVMLErroras pynvml guarantees.What changed
__test__ = False(pytest's documented opt-out) — names andcall sites unchanged;
test_error/test_apicount passed / skipped / failed, the run prints asummary, and
main()returns 1 when anything failed;Not Supportedcounts as skipped, not failed: those APIs are absent onthis hardware (ECC, MPC/virtualization, memory vendor…), and turning a
platform answer into a red build would train everyone to ignore it;
NVMLError = MTMLError.Verification (MTT S5000,
vllm:v0.32.0-ph1-5.2.0-torch2.13.0)The gate fires: injecting a
RuntimeErrorinto one API makesmain()return 1.