Skip to content

fix(bigframes): update GeminiTextGenerator default model to gemini-2.5-flash - #18060

Open
shuoweil wants to merge 4 commits into
mainfrom
shuowei-default-model-gemini-2-5-flash
Open

fix(bigframes): update GeminiTextGenerator default model to gemini-2.5-flash#18060
shuoweil wants to merge 4 commits into
mainfrom
shuowei-default-model-gemini-2-5-flash

Conversation

@shuoweil

Copy link
Copy Markdown
Contributor

Fixes #<544873054> 🦕

@shuoweil
shuoweil requested review from GarrettWu, sycai and tswast August 10, 2026 23:48
@shuoweil shuoweil self-assigned this Aug 10, 2026
@shuoweil
shuoweil requested review from a team as code owners August 10, 2026 23:48

@gemini-code-assist gemini-code-assist Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Code Review

This pull request updates the default model for GeminiTextGenerator from 'gemini-2.0-flash-001' to 'gemini-2.5-flash' in the bigframes library. It also introduces unit tests to verify the default model assignment and error handling for unsupported models. There are no review comments, and I have no additional feedback to provide.

@parthea

parthea commented Aug 11, 2026

Copy link
Copy Markdown
Contributor

Switching to draft since tests are failing. Please feel free to move it back to ready for review once they're green

@parthea
parthea marked this pull request as draft August 11, 2026 14:46
Comment on lines +25 to +63
def test_gemini_text_generator_unsupported_model_error():
# Create a mock session
mock_session = mock.create_autospec(spec=bigframes.session.Session)

# Mock _create_bq_connection to return a dummy connection
mock_session._create_bq_connection.return_value = (
"projects/test-project/locations/us-central1/connections/test-conn"
)

# Mock _anonymous_dataset which is used to create the temporary model reference
mock_session._anonymous_dataset = bigquery.DatasetReference(
"test-project", "test_dataset"
)

# Mock _start_query_ml_ddl to raise BadRequest (simulating BQML failure)
error_message = (
"Unsupported endpoint: Publisher model "
"projects/296675019294/locations/us-central1/publishers/google/models/gemini-3.5-flash "
"was not found or your project does not have access to it."
)
bq_error = google.api_core.exceptions.BadRequest(error_message)
mock_session._start_query_ml_ddl.side_effect = bq_error

# Attempting to create the model should raise the BadRequest exception
with pytest.raises(google.api_core.exceptions.BadRequest) as exc_info:
llm.GeminiTextGenerator(
model_name="gemini-3.5-flash",
session=mock_session,
connection_name="test-conn",
)

assert error_message in str(exc_info.value)

# Verify that the session's DDL execution method was called
mock_session._start_query_ml_ddl.assert_called_once()
generated_sql = mock_session._start_query_ml_ddl.call_args[0][0]
assert "CREATE OR REPLACE MODEL" in generated_sql
assert "gemini-3.5-flash" in generated_sql
assert "test-conn" in generated_sql

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this model validation logic is not handled by our code, right? If so, then we should probably not add test coverage for it.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good point, removed the redundant error-handling test case and kept only the default model resolution test.

Comment on lines +168 to +170
log_adapter.add_api_method("dataframe-max", session=session)
for _ in range(52):
df.head()
log_adapter.add_api_method("dataframe-head", session=session)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmmm why do we need this? It's not related to the default model change, right?

@shuoweil shuoweil Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted these changes to keep this PR focused purely on the default model update. I start a new branch to fix this.

job_config.labels = cur_labels

df.max()
log_adapter.add_api_method("dataframe-max", session=session)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Similar question here too: does the default model change break this test?

@shuoweil shuoweil Aug 11, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Reverted these changes to keep this PR focused purely on the default model update. I start a new branch to fix it.

@shuoweil
shuoweil force-pushed the shuowei-default-model-gemini-2-5-flash branch from 1e9393b to 89d87b2 Compare August 11, 2026 19:26
@shuoweil
shuoweil marked this pull request as ready for review August 11, 2026 19:55
@sycai sycai added the kokoro:force-run Add this label to force Kokoro to re-run the tests. label Aug 11, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kokoro:force-run Add this label to force Kokoro to re-run the tests.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants