-
Notifications
You must be signed in to change notification settings - Fork 84
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Detect plugins for Index and IndexGRPC classes #402
Merged
Merged
Changes from all commits
Commits
Show all changes
5 commits
Select commit
Hold shift + click to select a range
838c59b
Install plugins on Index and IndexGRPC
jhamon d93f597
Fix import issue
jhamon 65d5197
access self._config rather than self.config in Index
austin-denoble a0fb287
thread openapi_config and pool_threads through as well
austin-denoble 90df955
rebase + swap to using Index.config instead of Index._config since th…
austin-denoble File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 |
---|---|---|
@@ -1,11 +1,11 @@ | ||
from tqdm.autonotebook import tqdm | ||
|
||
import logging | ||
from typing import Union, List, Optional, Dict, Any | ||
|
||
from pinecone.config import ConfigBuilder | ||
|
||
from pinecone.core.openapi.shared import API_VERSION | ||
from pinecone.core.openapi.data.models import SparseValues | ||
from pinecone.core.openapi.data import ApiClient | ||
from pinecone.core.openapi.data.models import ( | ||
FetchResponse, | ||
|
@@ -22,12 +22,22 @@ | |
UpdateRequest, | ||
DescribeIndexStatsRequest, | ||
ListResponse, | ||
SparseValues, | ||
) | ||
from .features.bulk_import import ImportFeatureMixin | ||
from pinecone.core.openapi.data.api.data_plane_api import DataPlaneApi | ||
from ..utils import setup_openapi_client, parse_non_empty_args | ||
from ..utils import ( | ||
setup_openapi_client, | ||
parse_non_empty_args, | ||
build_plugin_setup_client, | ||
validate_and_convert_errors, | ||
) | ||
from .features.bulk_import import ImportFeatureMixin | ||
from .vector_factory import VectorFactory | ||
|
||
from pinecone_plugin_interface import load_and_install as install_plugins | ||
|
||
logger = logging.getLogger(__name__) | ||
|
||
__all__ = [ | ||
"Index", | ||
"FetchResponse", | ||
|
@@ -47,8 +57,6 @@ | |
"SparseValues", | ||
] | ||
|
||
from ..utils.error_handling import validate_and_convert_errors | ||
|
||
_OPENAPI_ENDPOINT_PARAMS = ( | ||
"_return_http_data_only", | ||
"_preload_content", | ||
|
@@ -89,20 +97,38 @@ def __init__( | |
**kwargs, | ||
) | ||
|
||
self._config = ConfigBuilder.build( | ||
self.config = ConfigBuilder.build( | ||
api_key=api_key, host=host, additional_headers=additional_headers, **kwargs | ||
) | ||
openapi_config = ConfigBuilder.build_openapi_config(self._config, openapi_config) | ||
self._openapi_config = ConfigBuilder.build_openapi_config(self.config, openapi_config) | ||
self._pool_threads = pool_threads | ||
|
||
self._vector_api = setup_openapi_client( | ||
api_client_klass=ApiClient, | ||
api_klass=DataPlaneApi, | ||
config=self._config, | ||
openapi_config=openapi_config, | ||
pool_threads=pool_threads, | ||
config=self.config, | ||
openapi_config=self._openapi_config, | ||
pool_threads=self._pool_threads, | ||
api_version=API_VERSION, | ||
) | ||
|
||
self._load_plugins() | ||
|
||
def _load_plugins(self): | ||
"""@private""" | ||
try: | ||
# I don't expect this to ever throw, but wrapping this in a | ||
# try block just in case to make sure a bad plugin doesn't | ||
# halt client initialization. | ||
openapi_client_builder = build_plugin_setup_client( | ||
config=self.config, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I think this needs to be
|
||
openapi_config=self._openapi_config, | ||
pool_threads=self._pool_threads, | ||
) | ||
install_plugins(self, openapi_client_builder) | ||
except Exception as e: | ||
logger.error(f"Error loading plugins in Index: {e}") | ||
|
||
def __enter__(self): | ||
return self | ||
|
||
|
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
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.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Most of these import changes are just cosmetic