Repository navigation
docs(rocke): add an error-handling policy to the Python style guide - #13964
Conversation
✅ All Checks Passed — Ready for Review
📖 Need help? See the Policy FAQ for details on every check and how to fix failures. |
|
🎉 All checks passed! This PR is ready for review. |
a889e29 to
004927d
Compare
Add section 13 to PYTHON_STYLE.md: fail-fast validation at the public boundary, a standard error-message template, which exception to raise (ValueError, TypeError, KeyError, NotImplementedError, RuntimeError and its ComgrError/HipError subclasses; never `assert` for input checks), where checks go (__post_init__ for field invariants, is_valid_spec for arch-dependent ones, duck typing over blanket isinstance), parity with the C++ engine's rocke_i_set_err idiom, and mandatory error-condition tests that pin both the exception type and the message. Section 7 and section 11 now point to the new section instead of restating exception choice and rejection testing, and the checklist gains an error-test item. Co-Authored-By: Claude <noreply@anthropic.com>
…ssages
rocke_qk_scale_spec_validate returned fixed strings that dropped the value
the Python QkScaleSpec messages name ("got ..."), so the two engines'
messages differed although the header said they matched. It now writes the
Python message, bad value included, into a caller buffer (reason,
reason_cap), the convention other C++ validators use. The layout is an enum
in C, so an unknown layout is reported by its integer value. The function
had no callers.
Tests: the Python rejections are pinned with pytest.raises(ValueError,
match=...), and a new native test, registered in the CTest tiers, pins the
same texts in the C++ engine.
Co-Authored-By: Claude <noreply@anthropic.com>
004927d to
6bbd4f1
Compare
|
Automated review: Model - qwen3.6:35b-a3b-coding-mtp-q4_K_M, effort: max PR #13964 — add an error-handling policy to the Python style guide — 🟢 First-round: no closer look needed — policy + safe ABI change, parity tests pass
Net-new: none. Utility: 🟢 Positive — adds a concrete, example-driven error-handling policy (exception choice, message templates, validation placement, C++/Python parity, mandatory error tests) and lands a matching caller-free ABI tweak with Python+C++ parity tests. Legend: 🔴 blocking · 🟠 should-fix · 🟡 minor nit · 🟢 info/good · ⚪ retracted First-round review: a local qwen3.6 model made the independent first pass; the orchestrator (Claude Opus 4.8) verified it on hardware — native build + C++ ctest + caller analysis — and owns this merge-worthiness call. It flags whether a closer look is needed; it is not an approval or a rejection. |
CongMa13
left a comment
There was a problem hiding this comment.
No new P0 or P1 issues were identified during this review. The changes are approved.
TheRock Submodule Bump ActivityNewest first
|
Motivation
The Python style guide said little about how code should report bad input: one sentence on
ValueErrorvsNotImplementedErrorand a one-line testing reminder. Authors and coding agents had no shared rule for which exception to raise, how to word the message, where checks belong, or how a Python check lines up with the C++ engine's error channel.Applying the parity rule found one pair that did not match: the C++
QkScaleSpecvalidation dropped the bad value the Python messages name. That is fixed here too.ISSUE ID : AICK-1705
Technical Details
style/PYTHON_STYLE.md, written as discrete, self-contained rules, with one sample rule in a RULE / WHEN / DO / DON'T / WHY form:{what failed} - {param}={bad value}, expected {constraint}, with a good and a banned example.ValueError(default),TypeError,KeyError,NotImplementedError,RuntimeError(and the existingComgrError/HipErrorsubclasses); neverassertfor public input validation.__post_init__for field invariants,is_valid_specfor arch-dependent checks, when a private helper may skip, duck typing over blanketisinstance, numeric parameters first.rocke_i_set_err, which throws through theextern "C"guard), and the exception-to-status-code mapping; the C++ side stays owned byCPP_STYLE.mdsection 6.rocke_qk_scale_spec_validate(C++) now writes the PythonQkScaleSpecmessage, bad value included, into a caller buffer (reason,reason_cap), the convention other C++ validators use; it used to return fixed strings without the value. The layout is an enum in C, so an unknown layout is reported by its integer value. The function had no callers. No LLVM IR changes.Test Plan
tests/core/test_qk_scale_spec.py(the section's "after" example as a real test) pins the Python rejections; the new native testrocke_qk_scale_spec_validate, registered in the CTest tiers, pins the same texts in the C++ engine.Test Result
Submission Checklist
🤖 Generated with Claude Code