Repository navigation
Conversation
devnull34
left a comment
There was a problem hiding this comment.
Verified via Tier 2 Free Cloud (Groq gpt-oss-120b): Reporting individual unreadable inputs as actionable error lines while continuing batch translation ensures that an unreadable sidecar or container directory does not abort the entire batch with an unhandled traceback.
LAKSHYA-cmd-tech
left a comment
There was a problem hiding this comment.
Tested on Windows 11 (26100), CPython 3.14.7, CPU only, without spirv-as/spirv-val on PATH, no game files.
Tool Verification: Pass
The tool change in tools/rdna2spirv.py works as intended:
except OSError as e:correctly catches unreadable translation inputs (on Windows, opening a directory as a file raisesPermissionError, which inherits fromOSError).- The diagnostic
ERROR: <name>: cannot read translation input <path>: <reason>is printed without a traceback,unreadable_inputsis incremented, anddrop_stale(name)correctly purges the stale module and index entry.
Test Issue on Environments Without SPIRV-Tools: 3 Failures
In tests/test_rdna2spirv_cli.py:
UnreadableInput.run_tool() runs a subprocess that translates both the unreadable shader and ps_ok. Because ps_ok translates successfully, rdna2spirv.main() proceeds to invoke spirv-as. On environments without spirv-as on PATH:
rdna2spirv prints ERROR: spirv-as not found; install SPIRV-Tools (spirv-as, spirv-val) and put it on PATH and returns exit code 2 (rdna2spirv.py:18218), causing:
AssertionError: 2 != 1 : ERROR: ps_bad: cannot read translation input ...\ps_bad.dxbc: Permission denied
ERROR: spirv-as not found; install SPIRV-Tools (spirv-as, spirv-val) and put it on PATH
This causes test_an_unreadable_shader_retires_its_previous_module_and_index_entry and both directory subcases of test_each_unreadable_input_kind_is_one_error_line_and_the_run_continues to fail with AssertionError: 2 != 1.
Suggestion
Either:
- Add
@unittest.skipUnless(shutil.which("spirv-as") and shutil.which("spirv-val"), "requires SPIRV-Tools")to the tests that compileps_okvia subprocess (matching line 416 oftest_rdna2spirv_cli.py); OR - In
test_each_unreadable_input_kind_is_one_error_line_and_the_run_continues, acceptp.returncode in (1, 2)(or checkp.returncode == (1 if shutil.which("spirv-as") else 2)).
test_a_missing_input_keeps_the_message_it_had and test_a_readable_run_is_unchanged pass (the latter mocks spirv-as), and self.deny() properly skips on Windows where chmod 0 does not deny read.
compileall, check_no_game_data.py, and git diff --check are all clean.
AI-assisted.
|
Tested
AI-assisted (Claude Code). |
tupacfan04
left a comment
There was a problem hiding this comment.
The unreadable-input handler itself works when SPIRV-Tools is present; the no-SPIRV-Tools test failure is already covered by LAKSHYA-cmd-tech's review, so I won't repeat it. Two other gaps remain:
-
A truncated/short input can still traceback. The new handler is only
except OSErroraroundtranslate(p)(tools/rdna2spirv.py:18144-18151). A truncated.dxbcor FSSM sidecar is readable, so it does not raiseOSError; a shortstruct.unpackcan raisestruct.error, which is caught neither by the new handler nor by the existingexcept (IndexError, KeyError, ValueError)at:18156. Add a zero-byte/short.dxbcand FSSM test, and catchstruct.error(or validate lengths and raiseUnsupported) beside the translator-error handling. -
Output writes and stale cleanup are outside the handler.
translate(path)only reads, butopen(sa, "w")at:18165,drop_stale()at:18126-18131(a directory at the old.spvpath raisesIsADirectoryError), andwrite_index()at:18217can still traceback. The PR body's statement that an output-writeOSErroris reported as “cannot read translation input” is not accurate for these paths. Either narrow the read handler and add explicit write/cleanup handling, or add an unwritable-output test and document the behavior.
Checked: with tools present, a directory or permission-denied listing/container/sidecar produces one ERROR: ... cannot read translation input line, increments unreadable_inputs, calls drop_stale, continues to ps_ok, writes the index/part rule and returns 1; a missing input keeps its existing message; a shard with an unreadable input publishes no part/index; a valid run is unchanged. Synthetic only; no game files. AI-assisted (OpenCode).
…y run without SPIRV-Tools UnreadableInput.run_tool() translated a second, readable shader (ps_ok) through the real CLI, so the run reached spirv-as; with SPIRV-Tools absent that is the tool's 'spirv-as not found' setup error and exit 2, and three tests failed with 'AssertionError: 2 != 1'. Drive main() with subprocess.run stubbed for spirv-as/spirv-val, as the file's other in-process tests already do, so the whole class runs anywhere and still asserts exit 1, the single ERROR line, the good shader translated and the stale module retired. One new real-CLI test covers the unreadable path alone (no shader translates, so no assembler is needed).
|
Thanks, reproduced and fixed in With SPIRV-Tools off PATH the good shader in the same run still translates, the run reaches Re-run on Linux, CPython 3.14, CPU only, synthetic inputs:
Not run on Windows here, so a re-check there would be welcome. AI-assisted (DeepSeek V4.1 Flash; re-run with Claude Code). |
|
Tested b2b5ab4 on Windows 11 build 26300, CPython 3.12.9: pass.
Synthetic inputs only, no game files. AI-assisted (Claude Code). |
translate()reads a shader's listing, its container (<name>.dxbc) and its sidecars (fssm/<name>.fssm,fspx/<name>.json), butmain()caught onlyFileNotFoundError. An input that exists and cannot be read (a directory where a file belongs, or a file without read permission) raisedIsADirectoryError/PermissionErrorand ended the whole run in a traceback, so every shader after it went untranslated.It is now handled the way a missing required input already is (#6292): one
ERROR: <shader>: cannot read translation input <path>: <reason>line, the shader's previous module and index entry are retired, the run continues, a summary line counts the unreadable inputs, a--shardrun publishes no part, and the exit code is 1. A missing input keeps its existing message, and a readable run is unchanged. Onlymain()'s file handling changes; no translation rule.Two points for review:
except OSErroraround the per-shadertranslate(p)call, so anOSErrorraised while writing that shader's outputs would also be reported with the "cannot read translation input" wording. I did not narrow it; say if you want the read and write paths separated.PermissionError. The two do not touch the same lines; if rdna2spirv: read shader source and sidecars once per translation (-29.6%) #5827 lands first, the directory-sidecar expectation in the new test needs adjusting, and the container and permission cases are unaffected.The existing
test_missing_dispatch_invalidates_completed_shard(interrupted case) put a directory at the.dxbcpath and passed only because the traceback text contained that path; it now asserts the tool's own error line and no traceback.Tested on Linux, CPython 3.14, CPU only, synthetic listings and stubs:
python -I tests/test_rdna2spirv_cli.py39 OK (1 skipped); with only the tool reverted, 8 failures.tests/test_rdna2spirv_merge.py,compileall,check_no_game_data.pyandgit diff --checkare clean. Not run: the fulltests/semanticsuite. Independent of #8066, which touches the resume-index read.Claim: #8047.
AI-assisted (DeepSeek V4.1 Flash wrote it; reviewed and re-verified with Claude Code).