Skip to content

progress_dashboard: handle unwritable --out and malformed JSON cleanly - #4846

Open
DenRakEiw wants to merge 2 commits into
ItsNotRexed:mainfrom
DenRakEiw:fix/progress-dashboard-io-json-errors
Open

DenRakEiw wants to merge 2 commits into
ItsNotRexed:mainfrom
DenRakEiw:fix/progress-dashboard-io-json-errors

Conversation

@DenRakEiw

Copy link
Copy Markdown
Contributor

Handles unwritable --out paths and malformed/corrupt JSON inputs in tools/progress_dashboard.py cleanly instead of crashing with unhandled tracebacks.

Changes

  • main(): refuses --out when it points to an existing non-directory (exit 2), and catches (OSError, ValueError) around os.makedirs(out_dir) / build() / write_outputs() to report a single-line error with exit code 2.
  • write_outputs(): validates that an existing history.json parses as a list of dicts with "content_hash" (raising ValueError handled cleanly by main() instead of crashing or overwriting corrupt history).
  • collect_unit() & collect_corpus(): catch (OSError, ValueError) and validate the JSON shape of unit_results.json, dxbc/index.json, and spirv/index.json, recording an "invalid" source (matching collect_ctest()'s existing pattern) instead of aborting the dashboard build.
  • Added synthetic unit tests in tests/test_progress_dashboard.py (test_unwritable_out_is_one_error_line, test_corrupt_history_json_is_one_error_line, test_malformed_unit_and_corpus_json_record_invalid_sources).

Claim

Claimed in #4816: #4816 (comment)

Testing

  • Environment: Windows 11, Python 3.12.10, CPU only (no GPU exercised, synthetic fixtures only, no game files).
  • python -I tests/test_progress_dashboard.py -v: 29/29 OK.
  • python -I tests/test_text_write_line_endings.py: 3/3 OK.
  • python -m compileall -q tools/progress_dashboard.py tests/test_progress_dashboard.py & git diff --check: clean.

AI-assisted (Gemini 4 Neon).

@shdann

shdann commented Nov 23, 2026

Copy link
Copy Markdown
Contributor

A missing field in a cached test result still stops the dashboard at d8e9b8e7. The new check accepts the outer list. At tools/progress_dashboard.py:310, the collector then reads the missing test field.

Run these commands from the repository root in PowerShell:

$out = New-Item -ItemType Directory -Path (Join-Path $env:TEMP ([guid]::NewGuid()))
'{"ran_at":"2026-11-23","results":[{}]}' | Set-Content -LiteralPath (Join-Path $out unit_results.json) -Encoding ascii
py -3.14 -I -B tools/progress_dashboard.py --out $out

Expected: The dashboard records the unit-test source as invalid and generates the other panels. Actual: The command exits 1 with KeyError: 'test'. Merge base de671352 gives the same result. Please validate the entries before marking the source as ok or adding any results.

On Windows 11 with CPython 3.14.7, all 29 tests in py -3.14 -I -B tests/test_progress_dashboard.py pass on the head. The same file reports three failures and one error on the merge base.

AI-assisted.

@tupacfan04

Copy link
Copy Markdown
Contributor

APPROVE. tests/test_progress_dashboard.py 29/29, line endings 3/3, compileall and git diff --check clean, merge clean. End-to-end run produces 234 units and exit 0, and a second run appends history with "no change". Negative control: main's tool fails 3 (wrong exit for an unwritable --out, JSONDecodeError for corrupt history, uncaught decode), so the fix is real.

Two nits:

  • tools/progress_dashboard.py:965-971 catches (OSError, ValueError) around build() too, so a ValueError from another input is reported as ERROR: cannot write <out>, which misleads. Narrow the catch to the write itself.
  • :674 still records corpus_carved as ok when the SPIR-V index is invalid (pre-existing).

save_text is already atomic (:78-82), so there is no truncation risk. Approve.

AI-assisted review, no game files, no GPU.

@DenRakEiw

Copy link
Copy Markdown
Contributor Author

Good catch, @shdann — updated in 80dac59c so collect_unit() also validates that every entry in
esults is a dict containing both "test" and "result", and added a regression case for a cached entry missing "test" ( est_progress_dashboard.py: 29/29 OK). AI-assisted (Gemini 4 Neon).

@kapitche

Copy link
Copy Markdown
Contributor

Tested 80dac59 merged with main 3faac55 on Linux (Python 3.12.16) and native Windows (Python 3.13.1): pass

tests/test_progress_dashboard.py: 29 tests OK on both. Negative control (Linux): with tools/progress_dashboard.py checked out from main, 3 failures and 1 error (test_unwritable_out_is_one_error_line, test_corrupt_history_json_is_one_error_line, test_malformed_unit_and_corpus_json_record_invalid_sources). No issues found.

@memorypressure

Copy link
Copy Markdown

Verified against main 3faac55: merges cleanly; compileall passes and all 29 tests in tests/test_progress_dashboard.py pass under python -I (re-run; malformed-JSON and unwritable --out paths included). One minor note: main()'s catch-all also maps unrelated ValueErrors onto the cannot-write line — harmless but slightly misleading. One flag: the branch currently reports no CI checks at all — worth a re-trigger before merge. AI-assisted: yes. Tested on Linux (RTX 5080 host, CPU-only run).

@Atomic258

Copy link
Copy Markdown
Contributor

Tested 80dac59 on Windows Server 2022, CPython 3.13.12: pass

git diff --check clean; python -m compileall -q exit 0. No game files, no GPU. AI-assisted (Devin).

@JRamos1993

Copy link
Copy Markdown
Contributor

Tested 7481c639 merged onto main 561b65a8 on Windows 11, CPython 3.14.3, CPU only: pass.

  • python -I tests/test_progress_dashboard.py: 41 tests OK.
  • Negative control (tools/progress_dashboard.py from main, the PR's tests kept): tests/test_progress_dashboard.py 41 tests FAILED (failures=3, errors=1).
  • py_compile on the 2 changed Python files: OK; git diff --check: clean.

No game files. AI-assisted (Claude Code).

@kapitche

Copy link
Copy Markdown
Contributor

Tested 7481c63 merged with main 14b2e44 on Linux WSL2 (Python 3.12.16, -I): pass
Real merge was clean (tests/test_progress_dashboard.py and tools/progress_dashboard.py auto-merged). tests/test_progress_dashboard.py: 42 tests OK.
Negative control: with tools/progress_dashboard.py reverted to main the same test file fails (3 failures, 1 error), so the new cases discriminate.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

7 participants