You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: pinecone/manage.py
+31-16Lines changed: 31 additions & 16 deletions
Original file line number
Diff line number
Diff line change
@@ -57,7 +57,7 @@ def _get_status(name: str):
57
57
defcreate_index(
58
58
name: str,
59
59
dimension: int,
60
-
wait: bool=True,
60
+
timeout: int=None,
61
61
index_type: str="approximated",
62
62
metric: str="cosine",
63
63
replicas: int=1,
@@ -69,8 +69,6 @@ def create_index(
69
69
:param name: the name of the index.
70
70
:type name: str
71
71
:param dimension: the dimension of vectors that would be inserted in the index
72
-
:param wait: wait for the index to deploy. Defaults to ``True``
73
-
:type wait: bool
74
72
:param index_type: type of index, one of {"approximated", "exact"}, defaults to "approximated".
75
73
The "approximated" index uses fast approximate search algorithms developed by Pinecone.
76
74
The "exact" index uses accurate exact search algorithms.
@@ -89,6 +87,8 @@ def create_index(
89
87
Use 1 shard per 1GB of vectors
90
88
:type shards: int,optional
91
89
:param index_config: Advanced configuration options for the index
90
+
:type timeout: int, optional
91
+
: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
92
92
"""
93
93
api_instance=_get_api_instance()
94
94
@@ -107,35 +107,50 @@ def is_ready():
107
107
ready=status['ready']
108
108
returnready
109
109
110
-
timeout=time.time() +300
111
-
ifwait:
112
-
while (notis_ready()) and (time.time() <=timeout):
110
+
iftimeout==-1:
111
+
return
112
+
iftimeoutisNone:
113
+
whilenotis_ready():
113
114
time.sleep(5)
114
-
iftime.time() >timeout:
115
-
raise (TimeoutError('Index created, but it did not get ready in time.'))
115
+
else:
116
+
while (notis_ready()) andtimeout>=0:
117
+
time.sleep(5)
118
+
timeout-=5
119
+
iftimeoutandtimeout<0:
120
+
raise (TimeoutError(
121
+
'Please call the describe_index API ({}) to confirm index status.'.format(
:param wait: wait for the index to deploy. Defaults to ``True``
125
-
:type wait: bool
131
+
: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
132
+
:type timeout: int, optional
126
133
"""
127
134
api_instance=_get_api_instance()
128
135
api_instance.delete_index(name)
129
136
130
137
defget_remaining():
131
138
returnnameinapi_instance.list_indexes()
132
139
133
-
timeout=time.time() +300
134
-
ifwait:
135
-
whileget_remaining() and (time.time() <=timeout):
140
+
iftimeout==-1:
141
+
return
142
+
143
+
iftimeoutisNone:
144
+
whileget_remaining():
145
+
time.sleep(5)
146
+
else:
147
+
whileget_remaining() andtimeout>=0:
136
148
time.sleep(5)
137
-
iftime.time() >timeout:
138
-
raise (TimeoutError('Index deletion timed out.'))
149
+
timeout-=5
150
+
iftimeoutandtimeout<0:
151
+
raise (TimeoutError(
152
+
'Please call the list_indexes API ({}) to confirm if index is deleted'.format(
0 commit comments