-
Notifications
You must be signed in to change notification settings - Fork 89
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
5 changed files
with
248 additions
and
153 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
class IndexClientInstantiationError(Exception): | ||
def __init__(self, index_args, index_kwargs): | ||
formatted_args = ", ".join(map(repr, index_args)) | ||
formatted_kwargs = ", ".join(f"{key}={repr(value)}" for key, value in index_kwargs.items()) | ||
combined_args = ", ".join([a for a in [formatted_args, formatted_kwargs] if a.strip()]) | ||
|
||
self.message = f"""You are attempting to access the Index client directly from the pinecone module. The Index client must be instantiated through the parent Pinecone client instance so that it can inherit shared configurations such as API key. | ||
INCORRECT USAGE: | ||
``` | ||
import pinecone | ||
pc = pinecone.Pinecone(api_key='your-api-key') | ||
index = pinecone.Index({combined_args}) | ||
``` | ||
CORRECT USAGE: | ||
``` | ||
from pinecone import Pinecone | ||
pc = Pinecone(api_key='your-api-key') | ||
index = pc.Index({combined_args}) | ||
``` | ||
""" | ||
super().__init__(self.message) | ||
|
||
|
||
class Index: | ||
def __init__(self, *args, **kwargs): | ||
raise IndexClientInstantiationError(args, kwargs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.