Skip to content

Commit 35b6470

Browse files
Remove unnecessary project_id == creds_id check for vertex (#862)
1 parent 22eef2d commit 35b6470

File tree

2 files changed

+0
-29
lines changed

2 files changed

+0
-29
lines changed

pydantic_ai_slim/pydantic_ai/models/vertexai.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -128,11 +128,6 @@ async def ainit(self) -> None:
128128
raise UserError(f'No project_id provided and none found in {creds_source}')
129129
project_id = creds_project_id
130130
else:
131-
if creds_project_id is not None and self.project_id != creds_project_id:
132-
raise UserError(
133-
f'The project_id you provided does not match the one from {creds_source}: '
134-
f'{self.project_id!r} != {creds_project_id!r}'
135-
)
136131
project_id = self.project_id
137132

138133
self._url = self.url_template.format(

tests/models/test_vertexai.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -92,30 +92,6 @@ async def test_init_right_project_id(tmp_path: Path, allow_model_requests: None)
9292
assert model.auth is not None
9393

9494

95-
async def test_init_service_account_wrong_project_id(tmp_path: Path, allow_model_requests: None):
96-
service_account_path = tmp_path / 'service_account.json'
97-
save_service_account(service_account_path, 'my-project-id')
98-
99-
model = VertexAIModel('gemini-1.5-flash', service_account_file=service_account_path, project_id='different')
100-
101-
with pytest.raises(UserError) as exc_info:
102-
await model.ainit()
103-
assert str(exc_info.value) == snapshot(
104-
"The project_id you provided does not match the one from service account file: 'different' != 'my-project-id'"
105-
)
106-
107-
108-
async def test_init_env_wrong_project_id(mocker: MockerFixture, allow_model_requests: None):
109-
mocker.patch('pydantic_ai.models.vertexai.google.auth.default', return_value=(NoOpCredentials(), 'my-project-id'))
110-
model = VertexAIModel('gemini-1.5-flash', project_id='different')
111-
112-
with pytest.raises(UserError) as exc_info:
113-
await model.ainit()
114-
assert str(exc_info.value) == snapshot(
115-
"The project_id you provided does not match the one from `google.auth.default()`: 'different' != 'my-project-id'"
116-
)
117-
118-
11995
async def test_init_env_no_project_id(mocker: MockerFixture, allow_model_requests: None):
12096
mocker.patch(
12197
'pydantic_ai.models.vertexai.google.auth.default',

0 commit comments

Comments
 (0)