Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 14 additions & 20 deletions pinecone/control/pinecone.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,15 @@ def create_index(
cloud: str,
region: str,
capacity_mode: str,
environment: Optional[str] = None,
timeout: Optional[int] = None,
index_type: str = "approximated",
metric: str = "cosine",
replicas: int = 1,
shards: int = 1,
pods: int = 1,
pod_type: str = "p1",
index_config: Optional[dict] = None,
index_config: Optional[dict] = {},
metadata_config: Optional[dict] = None,
source_collection: str = "",
):
Expand All @@ -65,9 +66,15 @@ def create_index(
:param name: the name of the index.
:type name: str
:param dimension: the dimension of vectors that would be inserted in the index
:type dimension: int
:param cloud: The cloud where you would like your index hosted. One of `{"aws", "gcp"}`.
:type cloud: str
:param region: The region where you would like your index hosted.
:type region: str
:param capacity_mode: The capacity mode for the index. One of `{"pod"}`.
:type capacity_mode: str
:param environment: The environment where you would like your index hosted, e.g. 'us-east1-gcp'. Find this value in the Pinecone web console along with your API keys.
:type environment: str, optional
:param index_type: type of index, one of `{"approximated", "exact"}`, defaults to "approximated".
The "approximated" index uses fast approximate search algorithms developed by Pinecone.
The "exact" index uses accurate exact search algorithms.
Expand Down Expand Up @@ -98,26 +105,13 @@ def create_index(
:param timeout: Timeout for wait until index gets ready. If None, wait indefinitely; if >=0, time out after this many seconds;
if -1, return immediately and do not wait. Default: None
"""
api_instance = self.index_api
create_args = locals()
del create_args["self"]
if environment is None:
del create_args["environment"]

api_instance.create_index(
create_request=CreateRequest(
name=name,
dimension=dimension,
cloud=cloud,
region=region,
capacity_mode=capacity_mode,
index_type=index_type,
metric=metric,
replicas=replicas,
shards=shards,
pods=pods,
pod_type=pod_type,
index_config=index_config or {},
metadata_config=metadata_config,
source_collection=source_collection,
)
)
api_instance = self.index_api
api_instance.create_index(create_request=CreateRequest(**create_args))

def is_ready():
status = self._get_status(name)
Expand Down
35 changes: 18 additions & 17 deletions pinecone/core/client/api/index_operations_api.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@
from pinecone.core.client.model.create_collection_request import CreateCollectionRequest
from pinecone.core.client.model.create_request import CreateRequest
from pinecone.core.client.model.index_meta import IndexMeta
from pinecone.core.client.model.inline_response200 import InlineResponse200
from pinecone.core.client.model.patch_request import PatchRequest


Expand Down Expand Up @@ -81,7 +82,7 @@ def __configure_index(
async_req (bool): execute request asynchronously

Returns:
str
IndexMeta
If the method is called asynchronously, returns the request
thread.
"""
Expand Down Expand Up @@ -110,7 +111,7 @@ def __configure_index(

self.configure_index = _Endpoint(
settings={
'response_type': (str,),
'response_type': (IndexMeta,),
'auth': [
'ApiKeyAuth'
],
Expand All @@ -119,7 +120,7 @@ def __configure_index(
'http_method': 'PATCH',
'servers': [
{
'url': "https://controller.{environment}.pinecone.io",
'url': "https://api.pinecone.io",
'description': "No description provided",
'variables': {
'environment': {
Expand Down Expand Up @@ -168,7 +169,7 @@ def __configure_index(
},
headers_map={
'accept': [
'text/plain'
'application/json'
],
'content_type': [
'application/json'
Expand Down Expand Up @@ -251,7 +252,7 @@ def __create_collection(
'http_method': 'POST',
'servers': [
{
'url': "https://controller.{environment}.pinecone.io",
'url': "https://api.pinecone.io",
'description': "No description provided",
'variables': {
'environment': {
Expand Down Expand Up @@ -340,7 +341,7 @@ def __create_index(
async_req (bool): execute request asynchronously

Returns:
str
IndexMeta
If the method is called asynchronously, returns the request
thread.
"""
Expand All @@ -367,7 +368,7 @@ def __create_index(

self.create_index = _Endpoint(
settings={
'response_type': (str,),
'response_type': (IndexMeta,),
'auth': [
'ApiKeyAuth'
],
Expand All @@ -376,7 +377,7 @@ def __create_index(
'http_method': 'POST',
'servers': [
{
'url': "https://controller.{environment}.pinecone.io",
'url': "https://api.pinecone.io",
'description': "No description provided",
'variables': {
'environment': {
Expand Down Expand Up @@ -418,7 +419,7 @@ def __create_index(
},
headers_map={
'accept': [
'text/plain'
'application/json'
],
'content_type': [
'application/json'
Expand Down Expand Up @@ -505,7 +506,7 @@ def __delete_collection(
'http_method': 'DELETE',
'servers': [
{
'url': "https://controller.{environment}.pinecone.io",
'url': "https://api.pinecone.io",
'description': "No description provided",
'variables': {
'environment': {
Expand Down Expand Up @@ -635,7 +636,7 @@ def __delete_index(
'http_method': 'DELETE',
'servers': [
{
'url': "https://controller.{environment}.pinecone.io",
'url': "https://api.pinecone.io",
'description': "No description provided",
'variables': {
'environment': {
Expand Down Expand Up @@ -765,7 +766,7 @@ def __describe_collection(
'http_method': 'GET',
'servers': [
{
'url': "https://controller.{environment}.pinecone.io",
'url': "https://api.pinecone.io",
'description': "No description provided",
'variables': {
'environment': {
Expand Down Expand Up @@ -895,7 +896,7 @@ def __describe_index(
'http_method': 'GET',
'servers': [
{
'url': "https://controller.{environment}.pinecone.io",
'url': "https://api.pinecone.io",
'description': "No description provided",
'variables': {
'environment': {
Expand Down Expand Up @@ -1020,7 +1021,7 @@ def __list_collections(
'http_method': 'GET',
'servers': [
{
'url': "https://controller.{environment}.pinecone.io",
'url': "https://api.pinecone.io",
'description': "No description provided",
'variables': {
'environment': {
Expand Down Expand Up @@ -1102,7 +1103,7 @@ def __list_indexes(
async_req (bool): execute request asynchronously

Returns:
[str]
InlineResponse200
If the method is called asynchronously, returns the request
thread.
"""
Expand All @@ -1129,7 +1130,7 @@ def __list_indexes(

self.list_indexes = _Endpoint(
settings={
'response_type': ([str],),
'response_type': (InlineResponse200,),
'auth': [
'ApiKeyAuth'
],
Expand All @@ -1138,7 +1139,7 @@ def __list_indexes(
'http_method': 'GET',
'servers': [
{
'url': "https://controller.{environment}.pinecone.io",
'url': "https://api.pinecone.io",
'description': "No description provided",
'variables': {
'environment': {
Expand Down
38 changes: 26 additions & 12 deletions pinecone/core/client/model/collection_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -109,9 +109,16 @@ def discriminator():

@classmethod
@convert_js_args_to_python_args
def _from_openapi_data(cls, *args, **kwargs): # noqa: E501
def _from_openapi_data(cls, name, size, status, dimension, vector_count, *args, **kwargs): # noqa: E501
"""CollectionMeta - a model defined in OpenAPI

Args:
name (str):
size (int): The size of the collection in bytes.
status (str): The status of the collection.
dimension (int): The dimension of the records stored in the collection
vector_count (int): The number of records stored in the collection

Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types
will be type checked and a TypeError will be
Expand Down Expand Up @@ -143,11 +150,6 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501
Animal class but this time we won't travel
through its discriminator because we passed in
_visited_composed_classes = (Animal,)
name (str): [optional] # noqa: E501
size (int): The size of the collection in bytes.. [optional] # noqa: E501
status (str): The status of the collection.. [optional] # noqa: E501
dimension (int): [optional] # noqa: E501
vector_count (int): [optional] # noqa: E501
"""

_check_type = kwargs.pop('_check_type', True)
Expand Down Expand Up @@ -175,6 +177,11 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501
self._configuration = _configuration
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)

self.name = name
self.size = size
self.status = status
self.dimension = dimension
self.vector_count = vector_count
for var_name, var_value in kwargs.items():
if var_name not in self.attribute_map and \
self._configuration is not None and \
Expand All @@ -195,9 +202,16 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501
])

@convert_js_args_to_python_args
def __init__(self, *args, **kwargs): # noqa: E501
def __init__(self, name, size, status, dimension, vector_count, *args, **kwargs): # noqa: E501
"""CollectionMeta - a model defined in OpenAPI

Args:
name (str):
size (int): The size of the collection in bytes.
status (str): The status of the collection.
dimension (int): The dimension of the records stored in the collection
vector_count (int): The number of records stored in the collection

Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types
will be type checked and a TypeError will be
Expand Down Expand Up @@ -229,11 +243,6 @@ def __init__(self, *args, **kwargs): # noqa: E501
Animal class but this time we won't travel
through its discriminator because we passed in
_visited_composed_classes = (Animal,)
name (str): [optional] # noqa: E501
size (int): The size of the collection in bytes.. [optional] # noqa: E501
status (str): The status of the collection.. [optional] # noqa: E501
dimension (int): [optional] # noqa: E501
vector_count (int): [optional] # noqa: E501
"""

_check_type = kwargs.pop('_check_type', True)
Expand All @@ -259,6 +268,11 @@ def __init__(self, *args, **kwargs): # noqa: E501
self._configuration = _configuration
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)

self.name = name
self.size = size
self.status = status
self.dimension = dimension
self.vector_count = vector_count
for var_name, var_value in kwargs.items():
if var_name not in self.attribute_map and \
self._configuration is not None and \
Expand Down
4 changes: 2 additions & 2 deletions pinecone/core/client/model/create_collection_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ def _from_openapi_data(cls, name, source, *args, **kwargs): # noqa: E501

Args:
name (str): The name of the collection to be created.
source (str): The name of the source index to be used as the source for the collection.
source (str): The name of the index to be used as the source for the collection.

Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types
Expand Down Expand Up @@ -195,7 +195,7 @@ def __init__(self, name, source, *args, **kwargs): # noqa: E501

Args:
name (str): The name of the collection to be created.
source (str): The name of the source index to be used as the source for the collection.
source (str): The name of the index to be used as the source for the collection.

Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types
Expand Down
Loading