fix(evals): extract bucket name from eval_storage_uri when a path is given - #6882
Open
chelsealong wants to merge 1 commit into
Open
fix(evals): extract bucket name from eval_storage_uri when a path is given#6882chelsealong wants to merge 1 commit into
chelsealong wants to merge 1 commit into
Conversation
…given create_gcs_eval_managers_from_uri() treated everything after `gs://` as the literal bucket name, so `gs://my-bucket/some/path` produced the invalid bucket name `my-bucket/some/path`, contradicting the docstring which says the bucket will be extracted if a path is provided. Fixes google#6881
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 #6881
Problem
create_gcs_eval_managers_from_uri()'s docstring says:But the implementation never extracted a bucket from a path — it treated
everything after
gs://as the literal bucket name:gs://my-bucket/some/pathproduced the invalid bucket namemy-bucket/some/path(slashes included), which is then passed toGcsEvalSetsManager/GcsEvalSetResultsManagerand fails later with amisleading "bucket does not exist" error, even when
my-bucketitselfexists.
Fix
Split off the first path segment so only the bucket name is used:
This matches the docstring's documented behavior for
gs://<bucket name>URIs. As noted in the issue, threading the remaining path through as a
storage prefix is a separate, larger change (the eval history/sets
directory helpers currently hard-code their paths) and is left out of this
minimal fix.
Testing plan
Added
test_create_gcs_eval_managers_from_uri_extracts_bucket_from_pathtotests/unittests/cli/utils/test_evals.py, asserting thatgs://test-bucket/some/pathresults inGcsEvalSetsManagerandGcsEvalSetResultsManagerbeing constructed withbucket_name='test-bucket'.Confirmed the new test fails against the old code:
And passes with the fix, along with the full existing suite for this module:
Also verified
pyink --checkandisort --checkare clean on both changedfiles.
AI disclosure
This change was authored with the assistance of an AI coding agent (Claude),
with the diff reviewed before submission.