Skip to content

Commit e683d30

Browse files
committed
manage.py edits for configure_index
1 parent 78f54a8 commit e683d30

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

pinecone/manage.py

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
#
44

55
import time
6-
from typing import NamedTuple
6+
from typing import NamedTuple, Optional
77

88
import pinecone
99
from pinecone.config import Config
@@ -41,7 +41,7 @@ def __init__(self, keys, values):
4141
self.__dict__[k] = v
4242

4343
def __str__(self):
44-
return str(self.__dict__)
44+
return str(self.__dict__)
4545

4646

4747
def _get_api_instance():
@@ -202,7 +202,8 @@ def describe_index(name: str):
202202
replicas=db['replicas'], dimension=db['dimension'], shards=db['shards'],
203203
pods=db.get('pods', db['shards'] * db['replicas']), pod_type=db.get('pod_type', 'p1'),
204204
index_config=db['index_config'], status={'ready': ready, 'state': state},
205-
metadata_config=db.get('metadata_config'), source_collection=db.get('source_collection',''))
205+
metadata_config=db.get('metadata_config'),
206+
source_collection=db.get('source_collection', ''))
206207

207208

208209
def scale_index(name: str, replicas: int):
@@ -255,15 +256,17 @@ def describe_collection(name: str):
255256
return response_object
256257

257258

258-
def configure_index(name: str, replicas: int = None, pod_type: str = ""):
259+
def configure_index(name: str, replicas: Optional[int] = None, pod_type: Optional[str] = ""):
259260
"""Changes current configuration of the index.
260261
:param: name: the name of the Index
261262
:param: replicas: the desired number of replicas, lowest value is 0.
262263
:param: pod_type: the new pod_type for the index.
263264
"""
264265
api_instance = _get_api_instance()
266+
config_args = {}
267+
if pod_type != "":
268+
config_args.update(pod_type=pod_type)
265269
if replicas:
266-
patch_request = PatchRequest(replicas=replicas, pod_type=pod_type)
267-
else:
268-
patch_request = PatchRequest(pod_type=pod_type)
270+
config_args.update(replicas=replicas)
271+
patch_request = PatchRequest(**config_args)
269272
api_instance.configure_index(name, patch_request=patch_request)

0 commit comments

Comments
 (0)