Skip to content

Remove openapi_config property #369

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

Merged
merged 2 commits into from
Jul 19, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
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
5 changes: 2 additions & 3 deletions pinecone/control/pinecone.py
Original file line number Diff line number Diff line change
Expand Up @@ -214,9 +214,8 @@ def __init__(
)

if kwargs.get("openapi_config", None):
warnings.warn(
"Passing openapi_config is deprecated and will be removed in a future release. Please pass settings such as proxy_url, proxy_headers, ssl_ca_certs, and ssl_verify directly to the Pinecone constructor as keyword arguments. See the README at https://github.com/pinecone-io/pinecone-python-client for examples.",
DeprecationWarning,
raise Exception(
Comment on lines 216 to +217
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, so the part that checks for the kwarg of this is part of the underlying generated code implementation? That's annoying.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The whole bucket of kwargs gets passed around in various places, so to be sure nobody has formed a dependency on these internals (so we can safely refactor later) we need to explicitly check and throw right at the entry point.

"Passing openapi_config is no longer supported. Please pass settings such as proxy_url, proxy_headers, ssl_ca_certs, and ssl_verify directly to the Pinecone constructor as keyword arguments. See the README at https://github.com/pinecone-io/pinecone-python-client for examples.",
)

self.openapi_config = ConfigBuilder.build_openapi_config(self.config, **kwargs)
Expand Down
19 changes: 0 additions & 19 deletions tests/integration/data/test_openapi_configuration.py

This file was deleted.

17 changes: 2 additions & 15 deletions tests/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,18 +98,9 @@ def test_config_pool_threads(self):
idx = pc.Index(host="my-index-host", name="my-index-name")
assert idx._vector_api.api_client.pool_threads == 10

def test_config_when_openapi_config_is_passed_merges_api_key(self):
oai_config = OpenApiConfiguration()
pc = Pinecone(api_key="asdf", openapi_config=oai_config)
assert pc.openapi_config.api_key == {"ApiKeyAuth": "asdf"}

def test_ssl_config_passed_to_index_client(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)
pc = Pinecone(api_key="key", ssl_ca_certs="path/to/cert", proxy_headers=proxy_headers)

assert pc.openapi_config.ssl_ca_cert == "path/to/cert"
assert pc.openapi_config.proxy_headers == proxy_headers
Expand All @@ -119,12 +110,8 @@ def test_ssl_config_passed_to_index_client(self):
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)
pc = Pinecone(api_key="key", ssl_ca_certs="path/to/cert", proxy_headers=proxy_headers)

assert pc.openapi_config.ssl_ca_cert == "path/to/cert"
assert pc.openapi_config.proxy_headers == proxy_headers
Expand Down
4 changes: 0 additions & 4 deletions tests/unit/test_control.py
Original file line number Diff line number Diff line change
Expand Up @@ -215,10 +215,6 @@ def test_list_indexes_returns_iterable(self, mocker, index_list_response):
response = p.list_indexes()
assert [i.name for i in response] == ["index1", "index2", "index3"]

def test_api_key_and_openapi_config(self, mocker):
p = Pinecone(api_key="123", openapi_config=OpenApiConfiguration.get_default_copy())
assert p.config.api_key == "123"


class TestIndexConfig:
def test_default_pool_threads(self):
Expand Down
Loading