You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
## Problem
Need to implement the new data plane list endpoint.
## Solution
- Update generated code. Pull in list endpoint. All changes under
`pinecone/core` are generated from spec files and can be ignored for
this review.
- Implement changes for list endpoint in:
- `pinecone/data/index.py` main implementation
- `pinecone/grpc/index_grpc.py` main implementation
- `tests/integration/data/conftest.py` adjustments to test setup, mainly
to generate a new namespace to hold vectors for list testing data.
- `tests/integration/data/seed.py` to upsert a larger number of vectors,
so I would have enough data to page through
- `tests/integration/data/test_list.py`
- `tests/integration/data/test_list_errors.py`
## Open questions
- Do we expect to ever return more data than just `{'id': '1'}` in the
vectors array? For convenience the `list()` method is currently
implemented as a generator function that abstracts the pagination steps
and yields a flat list of id values. For a use case where you were going
to immediately fetch those ids, this seems ideal. But would be limiting
if we ever wanted to return more than just ids here.
## Usage
Install the dev client version `install
"pinecone-client[grpc]"==3.1.0.dev1`
### REST
```python
from pinecone import Pinecone
pc = Pinecone(api_key='xxx')
index = pc.Index(host='hosturl')
# To iterate over all result pages using a generator function
for ids in index.list(prefix='pref', limit=3, namespace='foo'):
print(ids) // ['pref1', 'pref2', 'pref3']
# For manual control over pagination
results = index.list_paginated(
prefix='pref',
limit=3,
namespace='foo',
pagination_token='eyJza2lwX3Bhc3QiOiI5IiwicHJlZml4IjpudWxsfQ=='
)
print(results.namespace)
print([v.id for v in results.vectors])
print(results.pagination.next)
print(results.usage)
```
### GRPC
```python
from pinecone.grpc import PineconeGRPC
pc = PineconeGRPC(api_key='xxx')
index = pc.Index(host='hosturl')
# To iterate over all result pages using a generator function
for ids in index.list(prefix='pref', limit=3, namespace='foo'):
print(ids) // ['pref1', 'pref2', 'pref3']
# For manual control over pagination
results = index.list_paginated(
prefix='pref',
limit=3,
namespace='foo',
pagination_token='eyJza2lwX3Bhc3QiOiI5IiwicHJlZml4IjpudWxsfQ=='
)
print(results.namespace)
print([v.id for v in results.vectors])
print(results.pagination.next)
print(results.usage)
```
## Type of Change
- [x] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
## Testing
Try out the dev version.
```
pip install "pinecone-client[grpc]"==3.1.0.dev1
```
prefix (Optional[str]): The id prefix to match. If unspecified, an empty string prefix will
532
+
be used with the effect of listing all ids in a namespace [optional]
533
+
limit (Optional[int]): The maximum number of ids to return. If unspecified, the server will use a default value. [optional]
534
+
pagination_token (Optional[str]): A token needed to fetch the next page of results. This token is returned
535
+
in the response if additional results are available. [optional]
536
+
namespace (Optional[str]): The namespace to fetch vectors from. If not specified, the default namespace is used. [optional]
537
+
538
+
Returns: ListResponse object which contains the list of ids, the namespace name, pagination information, and usage showing the number of read_units consumed.
prefix (Optional[str]): The id prefix to match. If unspecified, an empty string prefix will
462
+
be used with the effect of listing all ids in a namespace [optional]
463
+
limit (Optional[int]): The maximum number of ids to return. If unspecified, the server will use a default value. [optional]
464
+
pagination_token (Optional[str]): A token needed to fetch the next page of results. This token is returned
465
+
in the response if additional results are available. [optional]
466
+
namespace (Optional[str]): The namespace to fetch vectors from. If not specified, the default namespace is used. [optional]
467
+
468
+
Returns: SimpleListResponse object which contains the list of ids, the namespace name, pagination information, and usage showing the number of read_units consumed.
0 commit comments