Skip to content

Commit

Permalink
Downgrade to openapi 5.2, add template overrides (#229)
Browse files Browse the repository at this point in the history
## Problem

Recent versions of openapi generator have added dependencies we don't
want to take on, especially `pydantic` v1. Pydantic v2 has been out for
a while and we think this is very likely to lead to dependency clashes
for some users.

## Solution

The reason we updated in the first place was to avoid generating code
that emitted urllib3 deprecation notices. In this PR, I downgrade to the
previously used 5.2.0 generator version and address the urllib3 error
using [template
overrides](https://openapi-generator.tech/docs/templating/) in the
generation step.

In this diff:
- Go back to generating the core with openapi 5.2.0 (same version as
before, e.g. on main)
- Everything under `pinecone/core` is generated using openapi and don't
need to be specifically reviewed. This is like 90% of the files changed.
- Use a template override in the generation step (handled in a private
repo) to adjust the urllib3 getheaders() usage and avoid spamming those
deprecation notices.
- Notice that generated `rest.py` is using [correct
syntax](https://stackoverflow.com/questions/75382508/deprecationwarning-httpresponse-getheader-is-deprecated-and-will-be-removed-i)
for getting headers in urllib3
- Fix tests that broke along the way, mostly due to changes in package
structure used by the generated code.
- Remove dependencies from `pyproject.toml` that were added when
previously going from openapi 5.2.0 => 7.0.1 (pydantic, aenum)


## Type of Change

- [x] None of the above: Update generated code, change dependencies

## Follow-up needed

- Docs build broken. By the looks of it, it seems related to numpy. But
I want to remove numpy in a follow-up diff anyway so I may merge with
this build failing for now.
  • Loading branch information
jhamon authored Oct 31, 2023
1 parent 2981ab4 commit 70c80a8
Show file tree
Hide file tree
Showing 81 changed files with 13,853 additions and 8,620 deletions.
2 changes: 1 addition & 1 deletion pinecone/config/openapi.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
class OpenApiConfigFactory:
@classmethod
def build(cls, api_key: str, host: str = None, **kwargs):
openapi_config = OpenApiConfiguration.get_default()
openapi_config = OpenApiConfiguration()
openapi_config.host = host
openapi_config.ssl_ca_cert = certifi.where()
openapi_config.socket_options = cls._get_socket_options()
Expand Down
4 changes: 1 addition & 3 deletions pinecone/control/pinecone.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,7 @@

from pinecone.core.client.api.index_operations_api import IndexOperationsApi
from pinecone.core.client.api_client import ApiClient
from pinecone.core.client.models.create_request import CreateRequest
from pinecone.core.client.models.patch_request import PatchRequest
from pinecone.core.client.models.create_collection_request import CreateCollectionRequest
from pinecone.core.client.models import CreateCollectionRequest, CreateRequest, PatchRequest
from pinecone.utils import get_user_agent

from pinecone.data import Index
Expand Down
53 changes: 8 additions & 45 deletions pinecone/core/client/__init__.py
Original file line number Diff line number Diff line change
@@ -1,65 +1,28 @@
# coding: utf-8

# flake8: noqa

"""
Pinecone API
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator)
No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501
The version of the OpenAPI document: version not set
Contact: [email protected]
Generated by OpenAPI Generator (https://openapi-generator.tech)
Do not edit the class manually.
""" # noqa: E501
Generated by: https://openapi-generator.tech
"""


__version__ = "1.0.0"

# import apis into sdk package
from pinecone.core.client.api.index_operations_api import IndexOperationsApi
from pinecone.core.client.api.vector_operations_api import VectorOperationsApi

# import ApiClient
from pinecone.core.client.api_response import ApiResponse
from pinecone.core.client.api_client import ApiClient

# import Configuration
from pinecone.core.client.configuration import Configuration

# import exceptions
from pinecone.core.client.exceptions import OpenApiException
from pinecone.core.client.exceptions import ApiAttributeError
from pinecone.core.client.exceptions import ApiTypeError
from pinecone.core.client.exceptions import ApiValueError
from pinecone.core.client.exceptions import ApiKeyError
from pinecone.core.client.exceptions import ApiAttributeError
from pinecone.core.client.exceptions import ApiException

# import models into sdk package
from pinecone.core.client.models.approximated_config import ApproximatedConfig
from pinecone.core.client.models.collection_meta import CollectionMeta
from pinecone.core.client.models.create_collection_request import CreateCollectionRequest
from pinecone.core.client.models.create_request import CreateRequest
from pinecone.core.client.models.create_request_index_config import CreateRequestIndexConfig
from pinecone.core.client.models.delete_request import DeleteRequest
from pinecone.core.client.models.describe_index_stats_request import DescribeIndexStatsRequest
from pinecone.core.client.models.describe_index_stats_response import DescribeIndexStatsResponse
from pinecone.core.client.models.fetch_response import FetchResponse
from pinecone.core.client.models.hnsw_config import HnswConfig
from pinecone.core.client.models.index_meta import IndexMeta
from pinecone.core.client.models.index_meta_database import IndexMetaDatabase
from pinecone.core.client.models.index_meta_database_index_config import IndexMetaDatabaseIndexConfig
from pinecone.core.client.models.index_meta_status import IndexMetaStatus
from pinecone.core.client.models.list_indexes200_response import ListIndexes200Response
from pinecone.core.client.models.namespace_summary import NamespaceSummary
from pinecone.core.client.models.patch_request import PatchRequest
from pinecone.core.client.models.protobuf_any import ProtobufAny
from pinecone.core.client.models.protobuf_null_value import ProtobufNullValue
from pinecone.core.client.models.query_request import QueryRequest
from pinecone.core.client.models.query_response import QueryResponse
from pinecone.core.client.models.query_vector import QueryVector
from pinecone.core.client.models.rpc_status import RpcStatus
from pinecone.core.client.models.scored_vector import ScoredVector
from pinecone.core.client.models.single_query_results import SingleQueryResults
from pinecone.core.client.models.sparse_values import SparseValues
from pinecone.core.client.models.update_request import UpdateRequest
from pinecone.core.client.models.upsert_request import UpsertRequest
from pinecone.core.client.models.upsert_response import UpsertResponse
from pinecone.core.client.models.vector import Vector
8 changes: 3 additions & 5 deletions pinecone/core/client/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
# flake8: noqa

# import apis into api package
from pinecone.core.client.api.index_operations_api import IndexOperationsApi
from pinecone.core.client.api.vector_operations_api import VectorOperationsApi
# do not import all apis into this module because that uses a lot of memory and stack frames
# if you need the ability to import all apis from one package, import them with
# from pinecone.core.client.apis import IndexOperationsApi
Loading

0 comments on commit 70c80a8

Please sign in to comment.