fix(optimization): treat explicit empty eval case ID lists as empty in LocalEvalSampler - #7170
Open
chelsealong wants to merge 1 commit into
Open
chelsealong wants to merge 1 commit into
chelsealong wants to merge 1 commit into
Conversation
…n LocalEvalSampler LocalEvalSampler.__init__ used truthiness checks on train_eval_case_ids/validation_eval_case_ids, so an explicitly passed [] was indistinguishable from None and silently expanded to every eval case. Switch to `is not None` checks so only an omitted/None field falls back to "all cases", matching the documented behavior. Fixes google#7168
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #7168
Problem
LocalEvalSamplerConfigdocumentstrain_eval_case_idsandvalidation_eval_case_idsas optional lists where all cases areselected when a field is not provided. However,
LocalEvalSampler.__init__used truthiness checks (or/if config.x:),so an explicitly passed
[]was indistinguishable fromNoneandsilently expanded to every eval case in the set — turning a
"run zero cases" configuration into a full evaluation run.
Fix
Changed both checks in
LocalEvalSampler.__init__tois not None,so only an omitted/
Nonefield triggers the "use all eval cases"fallback. An explicitly empty list now stays empty, consistent with
the documented behavior and with
sample_and_score(batch=[]).Testing plan
Added two parametrized cases to the existing
test_local_eval_service_interface_inittest intests/unittests/optimization/local_eval_sampler_test.py, covering anexplicit empty
train_eval_case_idsand an explicit emptyvalidation_eval_case_ids.Confirmed the new cases fail without the fix (reverted only the
source file via
git checkout HEAD~1 -- src/google/adk/optimization/local_eval_sampler.py):With the fix restored, the full test file and the rest of the
optimization suite pass:
Also ran
isort --check-onlyandpyink --checkon both changedfiles — no issues.
AI assistance disclosure
This change was authored with the assistance of Claude Code (Anthropic).