Repository navigation
test_runtime_paths, tile_probe: git fallback exception guard and lazy numpy import - #6116
Conversation
|
There is also an allocation on the missing-NumPy path. Run this from the repository root with import os, runpy, sys, tempfile, tracemalloc
with tempfile.TemporaryDirectory() as tmp:
path = os.path.join(tmp, "sample.bin")
with open(path, "wb") as f:
f.truncate(16 * 1024**2)
sys.argv = ["tile_probe.py", path]
tracemalloc.start()
try:
runpy.run_path("tools/tile_probe.py", run_name="__main__")
except (SystemExit, ModuleNotFoundError) as e:
print(str(e), tracemalloc.get_traced_memory()[1])The missing-input, text-write line-ending and text-encoding suites pass on the head (7 tests total). AI-assisted. |
thiefyzheng
left a comment
There was a problem hiding this comment.
Code read at 05de7fa9 against base 561b65a8 (AI-assisted review, automated pass per AGENTS.md; driver + worker, see lrev).
Mechanical checks (run by the driver, not the model):
-
compileallon the changed Python: *** Error compiling 'tests/test_runtime_paths.py'...
Sorry: IndentationError: expected an indented block after 'if' statement on line 83 (test_runtime_paths.py, line 84) -
tests/test_tile_probe.py: ok — OK (skipped=1) -
compileall failed on changed files
Review
VERDICT: BLOCKING
WHY: tests/test_runtime_paths.py does not compile as committed (the if on line 83 has no indented body), and the tile_probe numpy guard is still defeated by the np.ndarray annotation on the project's CI Python 3.12, so the claimed exit-2 path never runs there.
FINDINGS:
tests/test_runtime_paths.py:83— the newif result.returncode == 0 and result.stdout:block is empty: thereturn [...]on line 84 is at theif's own indentation, so the module raisesIndentationErrorat line 84 (the driver's compileall already reports it). This breaks thepython -m compileall -q make_game.py tools testsstep in.github/workflows/ci.yml:75and thepython -I tests/test_runtime_paths.pyloop, contrary to the PR's "compileall clean, 5/5 OK" testing note.tools/tile_probe.py:80—def score(img: np.ndarray) -> float:evaluatesnp.ndarraywhen the function is defined, and there is nofrom __future__ import annotations(module header is onlyargparse/os/sys, lines 10-12). With the newnp = None(line 17) on Python ≤ 3.13 (ci.yml:71,129pin 3.12; the PR was tested on 3.14, where PEP 649 defers annotations), importing the tool raisesAttributeError: 'NoneType' object has no attribute 'ndarray'beforemain()/probe()runs, sopython -I tools/tile_probe.py <missing>still exits 1 with a traceback instead of 2, andtests/test_missing_input_exit_codes.py(which runs it in the no-numpy Windows stdlib loop) fails. Quote the annotation, addfrom __future__ import annotations, or drop it, astools/tex_headers.py:776-781avoids the problem by keeping numpy inside a function.
CHECKED: .lrev.diff; tests/test_runtime_paths.py (whole file); tools/tile_probe.py (whole file); tests/test_tile_probe.py; tests/test_missing_input_exit_codes.py; tests/test_docs_links.py:60-72; tools/tex_headers.py:775-781; .github/workflows/ci.yml (check job 60-117, compile step 216-217, python-version pins, stdlib-tests-linux loop); tests/requirements.txt. Also grepped the tree: neither test_tile_probe nor test_missing_input_exit_codes is explicitly wired in a workflow, so both run through the generic test_*.py loop. I could not execute anything (read-only tools), so the Python-version claim is from the language's annotation semantics, not a run.
|
FAIL: the changed tests/test_runtime_paths.py does not compile at your head 05de7fa — line 84 places return at its own if's indentation, so compileall is red and the suite collects zero tests (re-run here: IndentationError line 84). One-line re-indent makes it green (Ran 5 OK), so the change itself is fine. Second, bigger issue in tools/tile_probe.py: np = None at line 17 plus def score(img: np.ndarray) at line 80 — on CPython 3.11–3.13 (the range docs/testing.md requires; this host's 3.14 deferred-annotations evaluation hides it) the annotation evaluates at def time and importing the tool dies with AttributeError: 'NoneType' object has no attribute 'ndarray'. Import numpy inside the functions like tools/tex_headers.py:777 does. The behavior fix itself reproduces: with numpy hidden, main tracebacks ModuleNotFoundError while your head prints the one-line ERROR and exits 2. The branch reports no CI checks at all. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run). |
|
Independent native Windows/Python 3.15 without NumPy at 05de7fa: python -I tests/test_missing_input_exit_codes.py passes 2/2 in an isolated worktree. Main 8575d36 audit fails the tile_probe missing-input case during its eager NumPy import. This head reaches the expected exit-2 diagnostic without NumPy. The PR base is older than current main; this verifies its published head only. Synthetic CPU inputs, no GPU/game files. AI-assisted (Codex). |
|
Tested 05de7fa merged onto main In The AI-assisted (Claude Code); I read the diff before running it. |
Item:
test_runtime_pathsgit fallback exception guard andtile_probelazy numpy importClaimed in #5934.
Summary
tests/test_runtime_paths.py:tracked()invokesgit ls-fileswithout catchingOSError/subprocess.CalledProcessError. Whengitis absent or not inPATH(e.g. running from a source archive or clean environment), this raisesFileNotFoundError: [WinError 2]. Wrapped in a try/except matchingtest_ci_registration.pyandtest_docs_links.py, enabling the intended fallback directory walk.tools/tile_probe.py: importednumpyunconditionally at module top level. In a standard-library environment without numpy, runningpython -I tools/tile_probe.py <missing>raisedModuleNotFoundError(exit 1) instead of returning usage error 2 under BUILD-1046, failingtest_missing_input_exit_codes.py. Guardednumpyimport lazily matchingtex_headers.pyandrender().Testing
py -m compileall -q tools/tile_probe.py tests/test_runtime_paths.py(clean)py -I tests/test_runtime_paths.py(5/5 OK)py -I tests/test_missing_input_exit_codes.py(2/2 OK)py -I tests/test_text_write_line_endings.py(3/3 OK)py -I tests/test_text_encoding.py(2/2 OK)AI-assisted: yes.