Skip to content
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

[Fix] Configuring SSL proxy via openapi_config object #321

Merged
merged 6 commits into from
Mar 14, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Copy openapi config object before modifying it
  • Loading branch information
jhamon committed Mar 14, 2024
commit dbefd52f9ec3e222e072dfbd22397a4dd534a7aa
2 changes: 2 additions & 0 deletions pinecone/config/config.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
from typing import NamedTuple, Optional, Dict
import os
import copy

from pinecone.exceptions import PineconeConfigurationError
from pinecone.config.openapi import OpenApiConfigFactory
Expand Down Expand Up @@ -47,6 +48,7 @@ def build(
raise PineconeConfigurationError("You haven't specified a host.")

if openapi_config:
openapi_config = copy.deepcopy(openapi_config)
openapi_config.host = host
openapi_config.api_key = {"ApiKeyAuth": api_key}
else:
Expand Down
21 changes: 20 additions & 1 deletion tests/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -106,4 +106,23 @@ def test_ssl_config_passed_to_index_client(self):

idx = pc.Index(host='host')
assert idx._vector_api.api_client.configuration.ssl_ca_cert == 'path/to/cert'
assert idx._vector_api.api_client.configuration.proxy_headers == proxy_headers
assert idx._vector_api.api_client.configuration.proxy_headers == proxy_headers

def test_host_config_not_clobbered_by_index(self):
oai_config = OpenApiConfiguration()
oai_config.ssl_ca_cert = 'path/to/cert'
proxy_headers = make_headers(proxy_basic_auth='asdf')
oai_config.proxy_headers = proxy_headers

pc = Pinecone(api_key='key', openapi_config=oai_config)

assert pc.config.openapi_config.ssl_ca_cert == 'path/to/cert'
assert pc.config.openapi_config.proxy_headers == proxy_headers
assert pc.config.openapi_config.host == 'https://api.pinecone.io'

idx = pc.Index(host='host')
assert idx._vector_api.api_client.configuration.ssl_ca_cert == 'path/to/cert'
assert idx._vector_api.api_client.configuration.proxy_headers == proxy_headers
assert idx._vector_api.api_client.configuration.host == 'https://host'

assert pc.config.openapi_config.host == 'https://api.pinecone.io'
Loading