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

Open
opened 2026-11-26 20:19:37 +01:00 by 4ld0 · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/ubiquitarianism/leonida/pull/917
Author: @TuroYT
Created: 11/24/2026
Status: 🔄 Open

Base: main ← Head: fix/ps-oracle-unavailable-exit


📝 Commits (1)

  • 9dde66b ps_oracle: exit 77 when the oracle becomes unavailable during run() (PS-ORACLE-UNAVAILABLE-EXIT)

📊 Changes

2 files changed (+41 additions, -0 deletions)

View changed files

📝 tests/test_ps_oracle.py (+38 -0)
📝 tools/ps_oracle.py (+3 -0)

📄 Description

Claimed in the coordination issue as: PS-ORACLE-UNAVAILABLE-EXIT (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135530775)

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).


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/ubiquitarianism/leonida/pull/917 **Author:** [@TuroYT](https://github.com/TuroYT) **Created:** 11/24/2026 **Status:** 🔄 Open **Base:** `main` ← **Head:** `fix/ps-oracle-unavailable-exit` --- ### 📝 Commits (1) - [`9dde66b`](https://github.com/ubiquitarianism/leonida/commit/9dde66b4323b10d454034ae8f894bd5d49395524) ps_oracle: exit 77 when the oracle becomes unavailable during run() (PS-ORACLE-UNAVAILABLE-EXIT) ### 📊 Changes **2 files changed** (+41 additions, -0 deletions) <details> <summary>View changed files</summary> 📝 `tests/test_ps_oracle.py` (+38 -0) 📝 `tools/ps_oracle.py` (+3 -0) </details> ### 📄 Description Claimed in the coordination issue as: PS-ORACLE-UNAVAILABLE-EXIT (https://github.com/ubiquitarianism/leonida/issues/14#issuecomment-7135530775) ## 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). --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
Sign in to join this conversation.
No labels
bug
pull-request
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
starred/leonida#956
No description provided.