docs: clarify sampling raises#1214
Conversation
Assisted-by: Codex Signed-off-by: skywalker <skywalkerwang98@gmail.com>
|
Marking this ready for review. Local checks completed before opening the PR:
GitHub checks visible on the PR are currently green. |
planetf1
left a comment
There was a problem hiding this comment.
A couple of small consistency notes inline — nothing that should hold this up.
planetf1
left a comment
There was a problem hiding this comment.
A couple of small consistency notes inline — nothing that should hold this up.
|
|
||
| Raises: | ||
| AssertionError: Asserts that all required components (repair, select_from_failure, validate, and generate) are provided before proceeding with the sampling. | ||
| AssertionError: If `select_from_failure` returns an index outside |
There was a problem hiding this comment.
Thanks for the PR — removing that stale assertion text is a good catch.
One small thing on the AssertionError description: "outside the generated samples" doesn't quite say what the assertion checks. The actual check is result_index < len(sample_generations), so "out-of-range index into sample_generations" is more direct. Same for the second part — "has no generation log to mark as final" is a roundabout way of saying "_generate_log is None".
The convention in this file is If \condition`with backtick code references — you can see it in theValueError` entry just below, and in the class docstring at line 131. Suggestion to bring it in line:
| AssertionError: If `select_from_failure` returns an index outside | |
| AssertionError: If `select_from_failure` returns an out-of-range index | |
| into `sample_generations`, or if the selected result's | |
| `_generate_log` is `None`. |
| the generated samples, or if the selected result has no | ||
| generation log to mark as final. | ||
| ValueError: If a `SAMPLING_LOOP_START` hook returns a non-positive `loop_budget`. | ||
| Exception: Re-raised from a concurrent subsample if all subsamples |
There was a problem hiding this comment.
Same convention note here — all the other entries in this block start with If <condition>, but this one starts with "Re-raised from…".
The condition is also slightly imprecise: the exception only fires when no subsample produced a usable result. A subsample can raise and the call still succeeds if any other subsample came through — so "all subsamples fail" undersells the specificity of the trigger:
| Exception: Re-raised from a concurrent subsample if all subsamples | |
| Exception: If all subsamples raise without producing a result, | |
| the first non-cancellation exception is re-raised (e.g. a | |
| backend error). |
Signed-off-by: skywalker <skywalkerwang98@gmail.com>
02b1b0a to
dabdbd4
Compare
|
Thanks, updated both docstring entries to match the suggested wording and the local |
planetf1
left a comment
There was a problem hiding this comment.
Thanks for the improvement. LGTM
Summary
AssertionErrorentry forBaseSamplingStrategy.sample()so it matches the currentselect_from_failureand generation-log assertionsFixes #1213.
Checks
uv run ruff format --check mellea/stdlib/sampling/base.pyuv run ruff check mellea/stdlib/sampling/base.pyuv run pytest test/stdlib/sampling/test_sampling_base_unit.py -qgit diff --check