Skip to content

Commit

Permalink
Sync models from pinecone-protos (#315)
Browse files Browse the repository at this point in the history
## Problem

See context in #313. This PR also includes other changes such as
renaming vector_operations_api to data_plane_api and updating
documentation.

## Solution

Followed steps to regenerate the python client from the protos.

## Type of Change

- [x] Bug fix (non-breaking change which fixes an issue)
- [ ] New feature (non-breaking change which adds functionality)
- [ ] Breaking change (fix or feature that would cause existing
functionality to not work as expected)
- [ ] This change requires a documentation update
- [ ] Infrastructure change (CI configs, etc)
- [ ] Non-code change (docs, etc)
- [ ] None of the above: (explain here)

---------

Co-authored-by: Jen Hamon <jhamon@pinecone.io>
  • Loading branch information
fsxfreak and jhamon committed Feb 22, 2024
1 parent 0d3cc45 commit e257894
Show file tree
Hide file tree
Showing 16 changed files with 333 additions and 214 deletions.
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -401,3 +401,4 @@ pc.delete_collection("example-collection")
# Contributing

If you'd like to make a contribution, or get setup locally to develop the Pinecone python client, please see our [contributing guide](./CONTRIBUTING.md)

2 changes: 1 addition & 1 deletion pinecone/core/client/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
# do not import all apis into this module because that uses a lot of memory and stack frames
# if you need the ability to import all apis from one package, import them with
# from pinecone.core.client.apis import ManageIndexesApi
# from pinecone.core.client.apis import DataPlaneApi

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions pinecone/core/client/api/manage_indexes_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -311,7 +311,7 @@ def __create_index(
):
"""Create an index # noqa: E501
This operation deploys a Pinecone index. This is where you specify the measure of similarity, the dimension of vectors to be stored in the index, which cloud provider you would like to deploy with, and more. # noqa: E501
This operation deploys a Pinecone index. This is where you specify the measure of similarity, the dimension of vectors to be stored in the index, which cloud provider you would like to deploy with, and more. For guidance and examples, see [Create an index](https://docs.pinecone.io/docs/manage-indexes#create-a-serverless-index). # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
Expand Down Expand Up @@ -436,7 +436,7 @@ def __delete_collection(
):
"""Delete a collection # noqa: E501
This operation deletes an existing collection. Serverless and starter indexes do not support collections. # noqa: E501
This operation deletes an existing collection. Serverless and starter indexes do not support collections. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
Expand Down Expand Up @@ -685,7 +685,7 @@ def __describe_collection(
):
"""Describe a collection # noqa: E501
This operation gets a description of a collection. Serverless and starter indexes do not support collections. # noqa: E501
This operation gets a description of a collection. Serverless and starter indexes do not support collections. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
Expand Down Expand Up @@ -932,7 +932,7 @@ def __list_collections(
):
"""List collections # noqa: E501
This operation returns a list of your Pinecone collections. Serverless and starter indexes do not support collections. # noqa: E501
This operation returns a list of all collections in a project. Serverless and starter indexes do not support collections. # noqa: E501
This method makes a synchronous HTTP request by default. To make an
asynchronous HTTP request, please pass async_req=True
Expand Down
8 changes: 4 additions & 4 deletions pinecone/core/client/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -762,11 +762,11 @@ def __call__(self, *args, **kwargs):
""" This method is invoked when endpoints are called
Example:
api_instance = ManageIndexesApi()
api_instance.configure_index # this is an instance of the class Endpoint
api_instance.configure_index() # this invokes api_instance.configure_index.__call__()
api_instance = DataPlaneApi()
api_instance.alt_delete # this is an instance of the class Endpoint
api_instance.alt_delete() # this invokes api_instance.alt_delete.__call__()
which then invokes the callable functions stored in that endpoint at
api_instance.configure_index.callable or self.callable in this class
api_instance.alt_delete.callable or self.callable in this class
"""
return self.callable(self, *args, **kwargs)
Expand Down
4 changes: 2 additions & 2 deletions pinecone/core/client/apis/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,13 +6,13 @@
# raise a `RecursionError`.
# In order to avoid this, import only the API that you directly need like:
#
# from .api.manage_indexes_api import ManageIndexesApi
# from .api.data_plane_api import DataPlaneApi
#
# or import this package, but before doing it, use:
#
# import sys
# sys.setrecursionlimit(n)

# Import APIs into API package:
from pinecone.core.client.api.data_plane_api import DataPlaneApi
from pinecone.core.client.api.manage_indexes_api import ManageIndexesApi
from pinecone.core.client.api.vector_operations_api import VectorOperationsApi
3 changes: 0 additions & 3 deletions pinecone/core/client/model/create_collection_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,6 @@ class CreateCollectionRequest(ModelNormal):
('name',): {
'max_length': 45,
'min_length': 1,
'regex': {
'pattern': r'^[A-Za-z0-9].*[A-Za-z0-9]$', # noqa: E501
},
},
}

Expand Down
7 changes: 2 additions & 5 deletions pinecone/core/client/model/create_index_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,6 @@ class CreateIndexRequest(ModelNormal):
('name',): {
'max_length': 45,
'min_length': 1,
'regex': {
'pattern': r'^[A-Za-z0-9].*[A-Za-z0-9]$', # noqa: E501
},
},
('dimension',): {
'inclusive_maximum': 20000,
Expand Down Expand Up @@ -129,7 +126,7 @@ def _from_openapi_data(cls, name, dimension, spec, *args, **kwargs): # noqa: E5
Args:
name (str): The name of the index. Resource name must be 1-45 characters long, start and end with an alphanumeric character, and consist only of lower case alphanumeric characters or '-'.
dimension (int): The dimensions of the vectors to be inserted in the index.
spec (dict): The spec object defines how the index should be deployed. For serverless indexes, you define only the cloud and region where the index should be hosted. For pod-based indexes, you define the environment where the index should be hosted, the pod type and size to use, and other index characteristics. Serverless indexes are in public preview and are available only on AWS in the us-west-2 region. Test thoroughly before using serverless indexes in production.
spec (dict): The spec object defines how the index should be deployed. For serverless indexes, you define only the cloud and region where the index should be hosted. For pod-based indexes, you define the environment where the index should be hosted, the pod type and size to use, and other index characteristics. Serverless indexes are in public preview and are available only on AWS in the us-west-2 region. Test thoroughly before using serverless indexes in production.
Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types
Expand Down Expand Up @@ -219,7 +216,7 @@ def __init__(self, name, dimension, spec, *args, **kwargs): # noqa: E501
Args:
name (str): The name of the index. Resource name must be 1-45 characters long, start and end with an alphanumeric character, and consist only of lower case alphanumeric characters or '-'.
dimension (int): The dimensions of the vectors to be inserted in the index.
spec (dict): The spec object defines how the index should be deployed. For serverless indexes, you define only the cloud and region where the index should be hosted. For pod-based indexes, you define the environment where the index should be hosted, the pod type and size to use, and other index characteristics. Serverless indexes are in public preview and are available only on AWS in the us-west-2 region. Test thoroughly before using serverless indexes in production.
spec (dict): The spec object defines how the index should be deployed. For serverless indexes, you define only the cloud and region where the index should be hosted. For pod-based indexes, you define the environment where the index should be hosted, the pod type and size to use, and other index characteristics. Serverless indexes are in public preview and are available only on AWS in the us-west-2 region. Test thoroughly before using serverless indexes in production.
Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types
Expand Down
17 changes: 8 additions & 9 deletions pinecone/core/client/model/index_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,9 +73,6 @@ class IndexModel(ModelNormal):
('name',): {
'max_length': 45,
'min_length': 1,
'regex': {
'pattern': r'^[A-Za-z0-9].*[A-Za-z0-9]$', # noqa: E501
},
},
('dimension',): {
'inclusive_maximum': 20000,
Expand Down Expand Up @@ -109,9 +106,9 @@ def openapi_types():
'name': (str,), # noqa: E501
'dimension': (int,), # noqa: E501
'metric': (str,), # noqa: E501
'host': (str,), # noqa: E501
'spec': (IndexModelSpec,), # noqa: E501
'status': (IndexModelStatus,), # noqa: E501
'host': (str,), # noqa: E501
}

@cached_property
Expand All @@ -123,9 +120,9 @@ def discriminator():
'name': 'name', # noqa: E501
'dimension': 'dimension', # noqa: E501
'metric': 'metric', # noqa: E501
'host': 'host', # noqa: E501
'spec': 'spec', # noqa: E501
'status': 'status', # noqa: E501
'host': 'host', # noqa: E501
}

read_only_vars = {
Expand All @@ -135,12 +132,13 @@ def discriminator():

@classmethod
@convert_js_args_to_python_args
def _from_openapi_data(cls, name, dimension, spec, status, *args, **kwargs): # noqa: E501
def _from_openapi_data(cls, name, dimension, host, spec, status, *args, **kwargs): # noqa: E501
"""IndexModel - a model defined in OpenAPI
Args:
name (str): The name of the index. Resource name must be 1-45 characters long, start and end with an alphanumeric character, and consist only of lower case alphanumeric characters or '-'.
dimension (int): The dimensions of the vectors to be inserted in the index.
host (str): The URL address where the index is hosted.
spec (IndexModelSpec):
status (IndexModelStatus):
Expand Down Expand Up @@ -176,7 +174,6 @@ def _from_openapi_data(cls, name, dimension, spec, status, *args, **kwargs): #
Animal class but this time we won't travel
through its discriminator because we passed in
_visited_composed_classes = (Animal,)
host (str): The URL address where the index is hosted.. [optional] # noqa: E501
"""

metric = kwargs.get('metric', "cosine")
Expand Down Expand Up @@ -208,6 +205,7 @@ def _from_openapi_data(cls, name, dimension, spec, status, *args, **kwargs): #
self.name = name
self.dimension = dimension
self.metric = metric
self.host = host
self.spec = spec
self.status = status
for var_name, var_value in kwargs.items():
Expand All @@ -230,12 +228,13 @@ def _from_openapi_data(cls, name, dimension, spec, status, *args, **kwargs): #
])

@convert_js_args_to_python_args
def __init__(self, name, dimension, spec, status, *args, **kwargs): # noqa: E501
def __init__(self, name, dimension, host, spec, status, *args, **kwargs): # noqa: E501
"""IndexModel - a model defined in OpenAPI
Args:
name (str): The name of the index. Resource name must be 1-45 characters long, start and end with an alphanumeric character, and consist only of lower case alphanumeric characters or '-'.
dimension (int): The dimensions of the vectors to be inserted in the index.
host (str): The URL address where the index is hosted.
spec (IndexModelSpec):
status (IndexModelStatus):
Expand Down Expand Up @@ -271,7 +270,6 @@ def __init__(self, name, dimension, spec, status, *args, **kwargs): # noqa: E50
Animal class but this time we won't travel
through its discriminator because we passed in
_visited_composed_classes = (Animal,)
host (str): The URL address where the index is hosted.. [optional] # noqa: E501
"""

metric = kwargs.get('metric', "cosine")
Expand Down Expand Up @@ -301,6 +299,7 @@ def __init__(self, name, dimension, spec, status, *args, **kwargs): # noqa: E50
self.name = name
self.dimension = dimension
self.metric = metric
self.host = host
self.spec = spec
self.status = status
for var_name, var_value in kwargs.items():
Expand Down
1 change: 0 additions & 1 deletion pinecone/core/client/model/index_model_status.py
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ class IndexModelStatus(ModelNormal):
'SCALINGDOWN': "ScalingDown",
'SCALINGUPPODSIZE': "ScalingUpPodSize",
'SCALINGDOWNPODSIZE': "ScalingDownPodSize",
'UPGRADING': "Upgrading",
'TERMINATING': "Terminating",
'READY': "Ready",
},
Expand Down
6 changes: 6 additions & 0 deletions pinecone/core/client/model/list_response.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,10 @@
def lazy_import():
from pinecone.core.client.model.list_item import ListItem
from pinecone.core.client.model.pagination import Pagination
from pinecone.core.client.model.usage import Usage
globals()['ListItem'] = ListItem
globals()['Pagination'] = Pagination
globals()['Usage'] = Usage


class ListResponse(ModelNormal):
Expand Down Expand Up @@ -93,6 +95,7 @@ def openapi_types():
'vectors': ([ListItem],), # noqa: E501
'pagination': (Pagination,), # noqa: E501
'namespace': (str,), # noqa: E501
'usage': (Usage,), # noqa: E501
}

@cached_property
Expand All @@ -104,6 +107,7 @@ def discriminator():
'vectors': 'vectors', # noqa: E501
'pagination': 'pagination', # noqa: E501
'namespace': 'namespace', # noqa: E501
'usage': 'usage', # noqa: E501
}

read_only_vars = {
Expand Down Expand Up @@ -150,6 +154,7 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501
vectors ([ListItem]): [optional] # noqa: E501
pagination (Pagination): [optional] # noqa: E501
namespace (str): The namespace of the vectors.. [optional] # noqa: E501
usage (Usage): [optional] # noqa: E501
"""

_check_type = kwargs.pop('_check_type', True)
Expand Down Expand Up @@ -234,6 +239,7 @@ def __init__(self, *args, **kwargs): # noqa: E501
vectors ([ListItem]): [optional] # noqa: E501
pagination (Pagination): [optional] # noqa: E501
namespace (str): The namespace of the vectors.. [optional] # noqa: E501
usage (Usage): [optional] # noqa: E501
"""

_check_type = kwargs.pop('_check_type', True)
Expand Down
8 changes: 4 additions & 4 deletions pinecone/core/client/model/sparse_values.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,8 +111,8 @@ def _from_openapi_data(cls, indices, values, *args, **kwargs): # noqa: E501
"""SparseValues - a model defined in OpenAPI
Args:
indices ([int]): The indices of the sparse data.
values ([float]): The corresponding values of the sparse data, which must be with the same length as the indices.
indices ([int]):
values ([float]):
Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types
Expand Down Expand Up @@ -198,8 +198,8 @@ def __init__(self, indices, values, *args, **kwargs): # noqa: E501
"""SparseValues - a model defined in OpenAPI
Args:
indices ([int]): The indices of the sparse data.
values ([float]): The corresponding values of the sparse data, which must be with the same length as the indices.
indices ([int]):
values ([float]):
Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types
Expand Down

0 comments on commit e257894

Please sign in to comment.