Skip to content

Commit

Permalink
feat!: Remove skip_project_and_location_in_path from async models.list
Browse files Browse the repository at this point in the history
PiperOrigin-RevId: 720592971
  • Loading branch information
hkt74 authored and copybara-github committed Jan 28, 2025
1 parent c7dba47 commit d788626
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 8 deletions.
10 changes: 2 additions & 8 deletions google/genai/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
from . import _extra_utils
from . import _transformers as t
from . import types
from ._api_client import ApiClient, HttpOptionsDict
from ._api_client import ApiClient
from ._common import get_value_by_path as getv
from ._common import set_value_by_path as setv
from .pagers import AsyncPager, Pager
Expand Down Expand Up @@ -5739,13 +5739,7 @@ async def list(
)
if self._api_client.vertexai:
config = config.copy()
if config.query_base:
http_options = (
config.http_options if config.http_options else HttpOptionsDict()
)
http_options['skip_project_and_location_in_path'] = True
config.http_options = http_options
else:
if not config.query_base:
# Filter for tuning jobs artifacts by labels.
filter_value = config.filter
config.filter = (
Expand Down
15 changes: 15 additions & 0 deletions google/genai/tests/models/test_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -124,3 +124,18 @@ async def test_async_pager(client):
pass
with pytest.raises(IndexError, match='No more pages to fetch.'):
await pager.next_page()


@pytest.mark.asyncio
async def test_base_models_async_pager(client):
pager = await client.aio.models.list(config={'page_size': 10, 'query_base': True})

assert pager.name == 'models'
assert pager.page_size == 10
assert len(pager) <= 10

# Iterate through all the pages. Then next_page() should raise an exception.
async for _ in pager:
pass
with pytest.raises(IndexError, match='No more pages to fetch.'):
await pager.next_page()

0 comments on commit d788626

Please sign in to comment.