-
Notifications
You must be signed in to change notification settings - Fork 83
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Revise proxy configuration, add integration testing (#325)
## Problem We want to expose proxy configuration fields as top-level config params and move away from users passing an `OpenApiConfiguration` instance with `openapi_config` (as was done in 2.x versions of the sdk). Passing these objects is not something we documented or had shown as a named configuration param, but is something people assumed would work as a hangover from the way things were done in the old client. Currently OpenApi generated code is part of our implementation, but we may want to swap out something else in the future so it doesn't make sense to use this `OpenApiConfiguration` object as part of our public interface. And since the openapi config object also needs to be configured with api key and host, it competes with these other config params in a way that is pretty confusing. ## Solution - Add new configuration parameters for `proxy_url`, `proxy_headers`, `ssl_ca_certs`, and `ssl_verify`. - Document the use of these properties in the README and doc strings - Emit a warning message when users are passing `openapi_config` encouraging them to use the new properties. - Implement integration tests that run with [mitmproxy](https://mitmproxy.org/) docker image. For now these are only run in local development. ## Usage ```python from pinecone import Pinecone import urllib3 import make_headers pc = Pinecone( api_key="YOUR_API_KEY", proxy_url='https://your-proxy.com', proxy_headers=make_headers(proxy_basic_auth='username:password'), ssl_ca_certs='path/to/cert-bundle.pem' ) ``` This will work, but should emit a deprecation warning: ```python from pinecone import Pinecone from pinecone.core.client.configuration import OpenApiConfiguration import urllib3 import make_headers config = OpenApiConfiguration() config.ssl_ca_certs = 'path/to/cert-bundle.pem' config.proxy_headers = make_headers(proxy_basic_auth='username:password') config.proxy_url = 'https://your-proxy.com' pc = Pinecone( api_key="YOUR_API_KEY", openapi_config=config ) # emits deprecation notice ``` ## Future work We will need to figure out how to deploy the mitmproxy elsewhere (cloud run?) before running tests in CI because Github Actions seems to have a lot of issues with running these docker containers and debugging the errors has proven quite difficult. While GHA can run docker containers, mounting a volume with the required certs causes the container to crash. I'm guessing this is some kind of file permissions issue, but don't have much visibility for debugging. ## Type of Change - [x] Bug fix (non-breaking change which fixes an issue) - [x] New feature (non-breaking change which adds functionality) - [ ] Breaking change (fix or feature that would cause existing functionality to not work as expected) - [x] This change requires a documentation update - [ ] Infrastructure change (CI configs, etc) - [ ] Non-code change (docs, etc) - [ ] None of the above: (explain here) ## Test Plan Run new tests locally with `PINECONE_API_KEY='foo' PINECONE_INDEX_NAME='bar' poetry run pytest tests/integration/proxy_config/ -s -v`
- Loading branch information
Showing
27 changed files
with
738 additions
and
36 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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,3 +154,5 @@ dmypy.json | |
# Datasets | ||
*.hdf5 | ||
*~ | ||
|
||
tests/integration/proxy_config/logs |
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
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.