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
8 changes: 3 additions & 5 deletions pinecone/control/pinecone.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,6 @@
CreateCollectionRequest,
CreateIndexRequest,
ConfigureIndexRequest,
IndexMetric,
IndexDimension,
)
from pinecone.models import ServerlessSpec, PodSpec, IndexList, CollectionList

Expand Down Expand Up @@ -80,11 +78,11 @@ def create_index(
api_instance = self.index_api

if isinstance(spec, dict):
api_instance.create_index(create_index_request=CreateIndexRequest(name=name, dimension=IndexDimension(dimension), metric=IndexMetric(metric), spec=spec))
api_instance.create_index(create_index_request=CreateIndexRequest(name=name, dimension=dimension, metric=metric, spec=spec))
elif isinstance(spec, ServerlessSpec):
api_instance.create_index(create_index_request=CreateIndexRequest(name=name, dimension=IndexDimension(dimension), metric=IndexMetric(metric), spec=spec.asdict()))
api_instance.create_index(create_index_request=CreateIndexRequest(name=name, dimension=dimension, metric=metric, spec=spec.asdict()))
elif isinstance(spec, PodSpec):
api_instance.create_index(create_index_request=CreateIndexRequest(name=name, dimension=IndexDimension(dimension), metric=IndexMetric(metric), spec=spec.asdict()))
api_instance.create_index(create_index_request=CreateIndexRequest(name=name, dimension=dimension, metric=metric, spec=spec.asdict()))

def is_ready():
status = self._get_status(name)
Expand Down
37 changes: 23 additions & 14 deletions pinecone/core/client/model/configure_index_request_spec_pod.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@
from pinecone.core.client.exceptions import ApiAttributeError


def lazy_import():
from pinecone.core.client.model.pod_spec_pod_type import PodSpecPodType
from pinecone.core.client.model.pod_spec_replicas import PodSpecReplicas
globals()['PodSpecPodType'] = PodSpecPodType
globals()['PodSpecReplicas'] = PodSpecReplicas


class ConfigureIndexRequestSpecPod(ModelNormal):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand All @@ -61,9 +55,26 @@ class ConfigureIndexRequestSpecPod(ModelNormal):
"""

allowed_values = {
('pod_type',): {
'S1.X1': "s1.x1",
'S1.X2': "s1.x2",
'S1.X4': "s1.x4",
'S1.X8': "s1.x8",
'P1.X1': "p1.x1",
'P1.X2': "p1.x2",
'P1.X4': "p1.x4",
'P1.X8': "p1.x8",
'P2.X1': "p2.x1",
'P2.X2': "p2.x2",
'P2.X4': "p2.x4",
'P2.X8': "p2.x8",
},
}

validations = {
('replicas',): {
'inclusive_minimum': 1,
},
}

@cached_property
Expand All @@ -72,7 +83,6 @@ def additional_properties_type():
This must be a method because a model may have properties that are
of type self, this must run after the class is loaded
"""
lazy_import()
return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501

_nullable = False
Expand All @@ -87,10 +97,9 @@ def openapi_types():
openapi_types (dict): The key is attribute name
and the value is attribute type.
"""
lazy_import()
return {
'replicas': (PodSpecReplicas,), # noqa: E501
'pod_type': (PodSpecPodType,), # noqa: E501
'replicas': (int,), # noqa: E501
'pod_type': (str,), # noqa: E501
}

@cached_property
Expand Down Expand Up @@ -144,8 +153,8 @@ 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,)
replicas (PodSpecReplicas): [optional] # noqa: E501
pod_type (PodSpecPodType): [optional] # noqa: E501
replicas (int): The number of replicas. Replicas duplicate your index. They provide higher availability and throughput. Replicas can be scaled up or down as your needs change.. [optional] if omitted the server will use the default value of 1 # noqa: E501
pod_type (str): The type of pod to use. One of `s1`, `p1`, or `p2` appended with `.` and one of `x1`, `x2`, `x4`, or `x8`.. [optional] if omitted the server will use the default value of "p1.x1" # noqa: E501
"""

_check_type = kwargs.pop('_check_type', True)
Expand Down Expand Up @@ -227,8 +236,8 @@ 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,)
replicas (PodSpecReplicas): [optional] # noqa: E501
pod_type (PodSpecPodType): [optional] # noqa: E501
replicas (int): The number of replicas. Replicas duplicate your index. They provide higher availability and throughput. Replicas can be scaled up or down as your needs change.. [optional] if omitted the server will use the default value of 1 # noqa: E501
pod_type (str): The type of pod to use. One of `s1`, `p1`, or `p2` appended with `.` and one of `x1`, `x2`, `x4`, or `x8`.. [optional] if omitted the server will use the default value of "p1.x1" # noqa: E501
"""

_check_type = kwargs.pop('_check_type', True)
Expand Down
35 changes: 18 additions & 17 deletions pinecone/core/client/model/create_index_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,12 +29,6 @@
from pinecone.core.client.exceptions import ApiAttributeError


def lazy_import():
from pinecone.core.client.model.index_dimension import IndexDimension
from pinecone.core.client.model.index_metric import IndexMetric
globals()['IndexDimension'] = IndexDimension
globals()['IndexMetric'] = IndexMetric


class CreateIndexRequest(ModelNormal):
"""NOTE: This class is auto generated by OpenAPI Generator.
Expand All @@ -61,9 +55,18 @@ class CreateIndexRequest(ModelNormal):
"""

allowed_values = {
('metric',): {
'COSINE': "cosine",
'EUCLIDEAN': "euclidean",
'DOTPRODUCT': "dotproduct",
},
}

validations = {
('dimension',): {
'inclusive_maximum': 20000,
'inclusive_minimum': 1,
},
}

@cached_property
Expand All @@ -72,7 +75,6 @@ def additional_properties_type():
This must be a method because a model may have properties that are
of type self, this must run after the class is loaded
"""
lazy_import()
return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501

_nullable = False
Expand All @@ -87,12 +89,11 @@ def openapi_types():
openapi_types (dict): The key is attribute name
and the value is attribute type.
"""
lazy_import()
return {
'name': (str,), # noqa: E501
'dimension': (IndexDimension,), # noqa: E501
'metric': (IndexMetric,), # noqa: E501
'spec': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501
'dimension': (int,), # noqa: E501
'metric': (str,), # noqa: E501
'spec': (dict,), # noqa: E501
}

@cached_property
Expand All @@ -119,9 +120,9 @@ def _from_openapi_data(cls, name, dimension, metric, spec, *args, **kwargs): #

Args:
name (str): The name of the index. The maximum length is 45 characters. It may contain lowercase alphanumeric characters or hyphens, and must not begin or end with a hyphen.
dimension (IndexDimension):
metric (IndexMetric):
spec ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): Spec objects describe how the index should be deployed
dimension (int): The dimensions of the vectors to be inserted in the index
metric (str): The distance metric to be used for similarity search. You can use 'euclidean', 'cosine', or 'dotproduct'.
spec (dict): Spec objects describe how the index should be deployed

Keyword Args:
_check_type (bool): if True, values for parameters in openapi_types
Expand Down Expand Up @@ -210,9 +211,9 @@ def __init__(self, name, dimension, metric, spec, *args, **kwargs): # noqa: E50

Args:
name (str): The name of the index. The maximum length is 45 characters. It may contain lowercase alphanumeric characters or hyphens, and must not begin or end with a hyphen.
dimension (IndexDimension):
metric (IndexMetric):
spec ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): Spec objects describe how the index should be deployed
dimension (int): The dimensions of the vectors to be inserted in the index
metric (str): The distance metric to be used for similarity search. You can use 'euclidean', 'cosine', or 'dotproduct'.
spec (dict): Spec objects describe how the index should be deployed

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