ps_oracle: exit 77 when the oracle becomes unavailable during run() (PS-ORACLE-UNAVAILABLE-EXIT) #917

Open
github-bot wants to merge 1 commit from github-bot/gh-917 into main AGit
Owner

@⁠TuroYT on GitHub · 2026-11-24 15:10 UTC · original
TuroYT:fix/ps-oracle-unavailable-exit → main · +41 −0 · 2 files · 1 commits · open

Claimed in the coordination issue as: PS-ORACLE-UNAVAILABLE-EXIT (#14)

What was wrong

tools/ps_oracle.py documents exit code 77 for a missing tool. main() catches Unavailable only around the Oracle(...) constructor (line 822). The o.run(...) call in the next try block does not catch it. assemble() raises Unavailable when no AMD clang is found (line 629), and run_harness() raises it when vk_harness returns 77 (line 618). Both happen during run(), so the user gets a traceback and exit 1.

Reproduction on origin/main, with the oracle constructor stubbed (no vk_harness build here) and PATH reduced:

$ env -i PATH=/nonexistent /usr/bin/python3 -I driver.py; echo exit=$?
pixel stage wave64 on stub
Traceback (most recent call last):
  ...
ps_oracle.Unavailable: no AMD clang (set LEONIDA_AMD_CLANG; `pip install rocm-sdk-core` from https://stable.repo.amd.com/rocm/whl-next/ provides one)
exit=1

What changed

main() gets a first handler on the o.run(...) try block: except Unavailable as e: prints ps_oracle unavailable: {e} to stderr and returns 77. This is the same message the constructor handler already prints. The ValueError/KeyError/IndexError/TypeError and RuntimeError handlers are unchanged.

tests/test_ps_oracle.py (class Cli): test_unavailable_during_run_is_77 makes Oracle.run raise Unavailable and checks exit 77 and the exact stderr line. test_value_error_during_run_is_still_2 checks that a ValueError still returns 2.

Tested

  • Same driver as above, after the fix: ps_oracle unavailable: no AMD clang (...) on stderr, then exit=77.
  • python3 -I tests/test_ps_oracle.py Cli on the fixed code: OK (5 tests).
  • test_unavailable_during_run_is_77 on the unfixed tools/ps_oracle.py (checked out from origin/main): ERROR with the same ps_oracle.Unavailable: no AMD clang (test) traceback.
  • python3 -I tests/test_ps_oracle.py: 25 tests, OK, 2 skipped (hardware tests need LEONIDA_PS_ORACLE_BUILD).
  • python3 -I tests/test_ps_helper_probe.py: 6 tests, OK, 1 skipped.
  • python3 -m unittest discover -s tests/semantic -p test_export_valid_mask.py: 24 tests, OK.
  • python3 -I tests/test_text_write_line_endings.py: 3 tests, OK.
  • python3 -I scripts/check_no_game_data.py tools/ps_oracle.py tests/test_ps_oracle.py: no issues.
  • python3 -m compileall -q tools tests: OK. git diff --check: clean.

Not tested

  • A real vk_harness exit 77 reaching run_harness (the test raises Unavailable from run() directly, not through subprocess).
  • Any run with a real AMD clang or GPU.
  • --show-template on RADV with a missing llvm-mc. That path is outside run() and was not changed.

AI-assisted (Claude Code).

**@⁠TuroYT** on GitHub · 2026-11-24 15:10 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/917) `TuroYT:fix/ps-oracle-unavailable-exit` → `main` · +41 −0 · 2 files · 1 commits · open Claimed in the coordination issue as: PS-ORACLE-UNAVAILABLE-EXIT (https://git.gtahub.st/github/ubiquitarianism--leonida/issues/14) ## What was wrong `tools/ps_oracle.py` documents exit code 77 for a missing tool. `main()` catches `Unavailable` only around the `Oracle(...)` constructor (line 822). The `o.run(...)` call in the next try block does not catch it. `assemble()` raises `Unavailable` when no AMD clang is found (line 629), and `run_harness()` raises it when vk_harness returns 77 (line 618). Both happen during `run()`, so the user gets a traceback and exit 1. Reproduction on origin/main, with the oracle constructor stubbed (no vk_harness build here) and PATH reduced: ``` $ env -i PATH=/nonexistent /usr/bin/python3 -I driver.py; echo exit=$? pixel stage wave64 on stub Traceback (most recent call last): ... ps_oracle.Unavailable: no AMD clang (set LEONIDA_AMD_CLANG; `pip install rocm-sdk-core` from https://stable.repo.amd.com/rocm/whl-next/ provides one) exit=1 ``` ## What changed `main()` gets a first handler on the `o.run(...)` try block: `except Unavailable as e:` prints `ps_oracle unavailable: {e}` to stderr and returns 77. This is the same message the constructor handler already prints. The `ValueError`/`KeyError`/`IndexError`/`TypeError` and `RuntimeError` handlers are unchanged. `tests/test_ps_oracle.py` (class `Cli`): `test_unavailable_during_run_is_77` makes `Oracle.run` raise `Unavailable` and checks exit 77 and the exact stderr line. `test_value_error_during_run_is_still_2` checks that a `ValueError` still returns 2. ## Tested - Same driver as above, after the fix: `ps_oracle unavailable: no AMD clang (...)` on stderr, then `exit=77`. - `python3 -I tests/test_ps_oracle.py Cli` on the fixed code: `OK` (5 tests). - `test_unavailable_during_run_is_77` on the unfixed `tools/ps_oracle.py` (checked out from origin/main): ERROR with the same `ps_oracle.Unavailable: no AMD clang (test)` traceback. - `python3 -I tests/test_ps_oracle.py`: 25 tests, OK, 2 skipped (hardware tests need LEONIDA_PS_ORACLE_BUILD). - `python3 -I tests/test_ps_helper_probe.py`: 6 tests, OK, 1 skipped. - `python3 -m unittest discover -s tests/semantic -p test_export_valid_mask.py`: 24 tests, OK. - `python3 -I tests/test_text_write_line_endings.py`: 3 tests, OK. - `python3 -I scripts/check_no_game_data.py tools/ps_oracle.py tests/test_ps_oracle.py`: no issues. - `python3 -m compileall -q tools tests`: OK. `git diff --check`: clean. ## Not tested - A real vk_harness exit 77 reaching `run_harness` (the test raises `Unavailable` from `run()` directly, not through `subprocess`). - Any run with a real AMD clang or GPU. - `--show-template` on RADV with a missing llvm-mc. That path is outside `run()` and was not changed. AI-assisted (Claude Code).
main() caught Unavailable only around the Oracle constructor. A missing AMD clang
(assemble) or a vk_harness exit 77 raised from run() escaped as a traceback with exit 1.
run() now returns 77 with the message on stderr, as the module docstring documents.
Test: Cli.test_unavailable_during_run_is_77 (fails on the old code), plus a ValueError case that still returns 2.
github-bot locked as GitHub sync and limited conversation to collaborators 2026-11-26 09:28:11 +00:00
Author
Owner

@⁠MoonEyes on GitHub · 2026-11-24 17:39 UTC · original · approved these changes

LGTM. Measured on Windows 11, Python 3.14, against main cf4c00cba:

  • python -I tests/test_ps_oracle.py: main Ran 23, OK (skipped=2); this PR and a local merge into main Ran 25, OK (skipped=2).
  • Mutation: with main's tools/ps_oracle.py and this PR's tests, test_unavailable_during_run_is_77 errors, because Unavailable escapes run(). The new handler (tools/ps_oracle.py:836) sits before the ValueError / RuntimeError ones, and the other Unavailable paths already returned 77.

AI-assisted: yes (Claude Code ran the checks; I read them).

**@⁠MoonEyes** on GitHub · 2026-11-24 17:39 UTC · [original](https://github.com/ubiquitarianism/leonida/pull/917#pullrequestreview-6044345078) · **approved these changes** LGTM. Measured on Windows 11, Python 3.14, against main cf4c00cba: - `python -I tests/test_ps_oracle.py`: main `Ran 23, OK (skipped=2)`; this PR and a local merge into main `Ran 25, OK (skipped=2)`. - Mutation: with main's `tools/ps_oracle.py` and this PR's tests, `test_unavailable_during_run_is_77` errors, because `Unavailable` escapes `run()`. The new handler (`tools/ps_oracle.py:836`) sits before the `ValueError` / `RuntimeError` ones, and the other `Unavailable` paths already returned 77. AI-assisted: yes (Claude Code ran the checks; I read them).
This pull request can be merged automatically.
This branch is out-of-date with the base branch
You are not authorized to merge this pull request.
View command line instructions

Checkout

From your project repository, check out a new branch and test the changes.
git fetch -u origin '+refs/pull/917/head:github-bot/gh-917'
git switch 'github-bot/gh-917'

Merge

Merge the changes and update on Forgejo.
git switch 'main'
git merge --no-ff 'github-bot/gh-917'
git switch 'github-bot/gh-917'
git rebase 'main'
git switch 'main'
git merge --ff-only 'github-bot/gh-917'
git switch 'github-bot/gh-917'
git rebase 'main'
git switch 'main'
git merge --no-ff 'github-bot/gh-917'
git switch 'main'
git merge --squash 'github-bot/gh-917'
git switch 'main'
git merge --ff-only 'github-bot/gh-917'
git switch 'main'
git merge 'github-bot/gh-917'
git push origin 'main'
This discussion has been locked. Commenting is limited to contributors.
No description provided.