|
3 | 3 | #
|
4 | 4 |
|
5 | 5 | import time
|
6 |
| -from typing import NamedTuple |
| 6 | +from typing import NamedTuple, Optional |
7 | 7 |
|
8 | 8 | import pinecone
|
9 | 9 | from pinecone.config import Config
|
@@ -41,7 +41,7 @@ def __init__(self, keys, values):
|
41 | 41 | self.__dict__[k] = v
|
42 | 42 |
|
43 | 43 | def __str__(self):
|
44 |
| - return str(self.__dict__) |
| 44 | + return str(self.__dict__) |
45 | 45 |
|
46 | 46 |
|
47 | 47 | def _get_api_instance():
|
@@ -202,7 +202,8 @@ def describe_index(name: str):
|
202 | 202 | replicas=db['replicas'], dimension=db['dimension'], shards=db['shards'],
|
203 | 203 | pods=db.get('pods', db['shards'] * db['replicas']), pod_type=db.get('pod_type', 'p1'),
|
204 | 204 | 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', '')) |
206 | 207 |
|
207 | 208 |
|
208 | 209 | def scale_index(name: str, replicas: int):
|
@@ -255,15 +256,17 @@ def describe_collection(name: str):
|
255 | 256 | return response_object
|
256 | 257 |
|
257 | 258 |
|
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] = ""): |
259 | 260 | """Changes current configuration of the index.
|
260 | 261 | :param: name: the name of the Index
|
261 | 262 | :param: replicas: the desired number of replicas, lowest value is 0.
|
262 | 263 | :param: pod_type: the new pod_type for the index.
|
263 | 264 | """
|
264 | 265 | api_instance = _get_api_instance()
|
| 266 | + config_args = {} |
| 267 | + if pod_type != "": |
| 268 | + config_args.update(pod_type=pod_type) |
265 | 269 | 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) |
269 | 272 | api_instance.configure_index(name, patch_request=patch_request)
|
0 commit comments