Skip to content
Closed
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
38 changes: 19 additions & 19 deletions pinecone/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,13 @@
]


class IndexDescription(NamedTuple):
name: str
metric: str
replicas: int
dimension: int
shards: int
pods: int
pod_type: str
status: None
metadata_config: None
source_collection: None
class IndexDescription(object):
def __init__(self, response: dict):
for k, v in response.items():
self.__dict__[k] = v

def __str__(self):
return str(self.__dict__)


class CollectionDescription(object):
Expand Down Expand Up @@ -194,14 +190,18 @@ def describe_index(name: str):
"""
api_instance = _get_api_instance()
response = api_instance.describe_index(name)
db = response['database']
ready = response['status']['ready']
state = response['status']['state']
return IndexDescription(name=db['name'], metric=db['metric'],
replicas=db['replicas'], dimension=db['dimension'], shards=db['shards'],
pods=db.get('pods', db['shards'] * db['replicas']), pod_type=db.get('pod_type', 'p1'),
Comment thread
rajat08 marked this conversation as resolved.
Resolved
status={'ready': ready, 'state': state}, metadata_config=db.get('metadata_config'),
source_collection=db.get('source_collection', ''))
db_status = response.get('status', {})
response = response['database'].to_dict()
state = db_status.get('state', None)
ready = db_status.get('ready', None)
status = {'state': state, 'ready': ready}
response['status'] = status
shards = response.get('shards', 1)
replicas = response.get('replicas', 1)
pods = shards * replicas
response['pods'] = pods
response_object = IndexDescription(response)
return response_object


def scale_index(name: str, replicas: int):
Expand Down