Skip to content

Commit b89d903

Browse files
committed
Refactoring
1 parent 9404ead commit b89d903

File tree

4 files changed

+12
-6
lines changed

4 files changed

+12
-6
lines changed

pinecone/control/pinecone.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ def Index(self, name: str = "", host: str = "", **kwargs) -> "Index":
238238
index_host = normalize_host(host)
239239
else:
240240
# Otherwise, get host url from describe_index using the index name
241-
index_host = self.index_host_store.get_host(self.index_api, self.config, name)
241+
index_host = self.db.index._get_host(name)
242242

243243
return _Index(
244244
host=index_host,

pinecone/control/resources/index.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -131,10 +131,10 @@ def delete(self, name: str, timeout: Optional[int] = None):
131131
return
132132

133133
if timeout is None:
134-
while self.has_index(name):
134+
while self.has(name):
135135
time.sleep(5)
136136
else:
137-
while self.has_index(name) and timeout >= 0:
137+
while self.has(name) and timeout >= 0:
138138
time.sleep(5)
139139
timeout -= 5
140140
if timeout and timeout < 0:
@@ -183,3 +183,9 @@ def configure(
183183
tags=tags,
184184
)
185185
api_instance.configure_index(name, configure_index_request=req)
186+
187+
def _get_host(self, name: str) -> str:
188+
"""@private"""
189+
return self.index_host_store.get_host(
190+
api=self.index_api, config=self.config, index_name=name
191+
)

pinecone/control/resources_asyncio/index.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,8 +16,8 @@
1616
GcpRegion,
1717
AzureRegion,
1818
)
19-
from .types import CreateIndexForModelEmbedTypedDict
20-
from .request_factory import PineconeDBControlRequestFactory
19+
from pinecone.control.types import CreateIndexForModelEmbedTypedDict
20+
from pinecone.control.request_factory import PineconeDBControlRequestFactory
2121

2222
logger = logging.getLogger(__name__)
2323
""" @private """

pinecone/grpc/pinecone.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ def Index(self, name: str = "", host: str = "", **kwargs):
122122
raise ValueError("Either name or host must be specified")
123123

124124
# Use host if it is provided, otherwise get host from describe_index
125-
index_host = host or self.index_host_store.get_host(self.index_api, self.config, name)
125+
index_host = host or self.db.index._get_host(name)
126126

127127
pt = kwargs.pop("pool_threads", None) or self.pool_threads
128128

0 commit comments

Comments
 (0)