Repository navigation
tests: four numpy gates decided in the wrong process, so their cases judged the exit code instead - #2672
Conversation
|
Verified by OreoFR on macOS 27.2.1, Apple M5, Python 3.12.16, main 40e7fe6, PR head of this PR (test-only, so "main" = main's test files, "PR" = this PR's, both on main's tools). MEASURED in two environments:
AI-assisted: Claude Code |
|
I tested the user-site setup that was missing from the macOS verification. On CachyOS / Python 3.14.10 I put NumPy and Pillow in an isolated
AI-assisted with OpenAI Codex. |
|
Re-check by OreoFR on the new head 46086f4, same Mac (macOS 27.2.1, Apple M5, Python 3.12.16), main 1d22590. MEASURED, main's test files vs this PR's, on main's tools:
No regression in either environment; merges cleanly with main and with #2566. The AI-assisted: Claude Code |
|
You are right again, and this one was a coverage regression rather than a red one: five cases that pass on The reasoning I missed, in your words and now in the diff:
Verified here after applying it: What I would have caught with your matrix and did not, stated plainly: my "0 failed" was measured in exactly one dependency configuration - numpy hidden from Together with the Written with an AI assistant. |
|
Re-check by OreoFR on head 46ce12b, same Mac, main 1d22590. MEASURED, green (main + this PR):
AI-assisted: Claude Code |
|
Rebased with the one commit Verified after adding it, on this branch: If #2633 merges first this fifth commit becomes a duplicate and can be dropped; if this lands first, #2633 becomes a no-op. A note on how this branch was pushed, because I broke one today: the last two pushes of mine went through a Written with an AI assistant. |
|
Note by OreoFR on head 7691389: the new commit adds the SHADER-468 change to AI-assisted: Claude Code |
|
Thank you - and the conflict you found is not what I would have guessed. I diffed the two sides: #2566 carries a different implementation of the same interp fix, not the same edit.
So "resolve by taking either side" is wrong here: it is a choice between two oracles, and only one of them can be the one that ends up describing SHADER-468 in What the commit in this branch is, precisely: On the rest of your re-check: thank you for the no-numpy case. Written with an AI assistant. |
|
Correction to what I wrote above: I diffed the wrong thing. It is one change, not two. I compared the two files at their own branch heads and read "504 of 566 lines differ" as two implementations. Those files come from different bases, so most of that was drift. Compared properly - the added lines of each patch, and the file So your report was right and my escalation of it was wrong: the conflict is the same edit on both sides, and taking either resolves it. The duplicate is still real - whichever of #2633 / #2566 lands first, the other's copy is dropped - and the copy in this branch is exactly Thank you for finding the conflict; the part I got wrong after that was mine, not yours. Written with an AI assistant. |
|
Update by OreoFR: the conflict with #2566 I reported here is gone. AI-assisted: Claude Code |
HAVE_NUMPY used importlib.util.find_spec in this process, while the tests run the tool with python -I, which hides the --user install this machine has. The gate opened and four cases died on "needs numpy" instead of testing what they name. The file already did this correctly for Pillow (HAVE_PIL_ISOLATED); this applies the same probe to numpy and gates the four cases that reach it, keeping the eleven that test behaviour before numpy. Measured on main b8bd371, Windows 11, Python 3.13: 5 failed, 12 passed before; 11 passed, 4 skipped after. Where -I sees numpy the probe returns true and the four run as before. Written with an AI assistant.
The same in-process numpy check, in the file whose CLI tests spawn `python -I`: HAVE_NUMPY stayed for the tests that call numpy here, and the nine CLI gates now use NUMPY_VISIBLE_TO_TOOL, the isolated probe. Measured on main b8bd371, Windows 11, Python 3.13: 3 failed, 23 passed, 5 skipped before; 21 passed, 10 skipped after. Where -I sees numpy the probe returns true and every gate opens as before. Written with an AI assistant.
test_each_sibling_importing_tool_starts skipped a NUMERIC list when numpy was missing, but it asked find_spec in this process while the tools run with -I, so the skip never fired here; and a list of names cannot cover calibrated_texture and tex_export, which are not numeric themselves and import one that is. The probe now matches how the tools run, and a child that fails with "No module named 'numpy'" is skipped rather than failing the startup check. Measured on main b8bd371, Windows 11, Python 3.13: 2 failed, 2 passed, 218 subtests before; 2 passed, 214 subtests after (the four are the two numpy-dependent subtests, skipped). With numpy visible to -I nothing changes. Written with an AI assistant.
Applied from merzleckeier's follow-up (f9456e0), unchanged: the two render() calls use the parent's numpy and Pillow, and the three CLI validation checks finish before the child needs numpy, so all five should run rather than skip. The two PNG preview subprocesses need Pillow in the child, which the isolated probe now checks. Written with an AI assistant.
7691389 to
b3b064b
Compare
|
Re-verified after the rebase onto What I did not test: the rest of the change, and anything the rebase did not touch. This confirms the rebase kept the change working, not that the change is correct - that is what the review and the CI are for. Written with an AI assistant. |
|
VERIFY-2672 — PASS (with one stated limit)
|
No content change.
|
Independent check on Windows (not the author), at
Environment: Windows 11 Pro 10.0.26200.9711, Python 3.12.10, no numpy required for these runs. AI-assisted: yes (opencode). |
aslan2142
left a comment
There was a problem hiding this comment.
LGTM. Checking numpy/PIL visibility inside an isolated python -I subprocess in tests/test_swizzle_search.py, tests/test_tile_probe.py, and tests/test_tool_startup.py fixes false skips/failures when packages are only in user-site, and un-gates CLI validation tests that run before numpy import. Clean-room verified, 5/5 CI green, and independently verified. Merging.
(AI-assisted review.)
Four files, one bug, one review. Each decides "is numpy usable?" from this process, while the test it gates launches the tool as
python -I- and-Iimplies-s, which hides a--userinstall. On a machine where numpy came frompip install --userthe gate opens and the child dies withModuleNotFoundError: No module named 'numpy', so the test judges the child's exit code instead of the behaviour it names.The files
tests/test_tile_probe.py-find_spec-> the isolated probe, gating the four cases that reach numpy. The other eleven keep running: they exercise the tool's file and argument checks, which happen before numpy is touched. (Skipping the whole class turned 12 passing tests into 12 skips; the class docstring's "those tests skip without it" was already an overstatement.)tests/test_swizzle_search.py- same shape:HAVE_NUMPYstays for the tests that call numpy here, the nine CLI gates use the newNUMPY_VISIBLE_TO_TOOL.tests/test_tool_startup.py- this one had a second, subtler gap. It skipped aNUMERIClist when numpy was missing, but:have_numpywas the in-process question, so the skip never fired on this machine;calibrated_textureandtex_exportare not numeric themselves. (amd_swizzlewas a third, until amd_swizzle: validate arguments before needing numpy, and gate the tests the way the tool runs #2671 made its import late.)So the probe matches how the tools run, and a child that fails with
"No module named 'numpy'"is skipped rather than called a startup failure.Measured,
mainb8bd37111, Windows 11, Python 3.13.14And with #2667 and #2671 applied on top, the whole Python suite went from 22 failed / 11,853 passed to 0 failed / 11,858 passed (
tests/excludingtests/semantic, which has to be a separate run:test_address_guard.pyexists in both directories and pytest refuses to collect both).Where
-Ican see numpy - CI - both probes return true, every gate opens, and the cases run exactly as before. Test-only: no tool behaviour moves.Not in this PR
#2671 also changes
tools/amd_swizzle.py, because there the tool reported "needs numpy" before validating arguments. These three files have no such problem.A correction from the review, applied as its own commit (
46ce12bb9)The first version of the
test_swizzle_search.pygates over-skipped: five cases that pass onmainin a user-site environment were being skipped, becauseNUMPY_VISIBLE_TO_TOOLwas the wrong gate for all of them.merzleckeier measured exactly which, and the reasons differ:
render()calls (BC1, BC3) use the parent's numpy and Pillow, soHAVE_NUMPY and HAVE_PILwas right and my gate was too strict;maintoo.Their follow-up (
f9456e020) is applied unchanged as its own commit:PIL_VISIBLE_TO_TOOLjoins the probe, the five cases run again, and the two PNG tests are gated on the child's Pillow. The numbers above are after it.What that says about my own measurement: I measured in exactly one dependency configuration - numpy hidden from
-I- and in that configuration over-skipping looks identical to correct skipping. "0 failed" was true and was not enough.The extra commit at the tip (no longer carried)
The branch used to carry
a3b5ebea1(test(semantic): align computed-I/J f16 interp oracle…), added only becausesemantic-testswas red onmainfor that oracle and every branch cut frommaininherited it.mainnow has the same edit asc717967d0, so a rebase drops the commit and this pull request no longer touchestests/semantic/test_interp_computed_ij_fallback.py- the diff is only what this change actually needs.AI-assisted: yes - DeepSeek v4.1 (flash) as the coding agent, with a separate reviewer agent reading the change before submission. Where and on what: the measurements above were taken on Windows 11 with MSVC 19.44.35226 on an RTX 4090 (NVIDIA driver 621.24) where a C++ or GPU path is involved; Python and docs cases need none of it.
Written with an AI assistant.