Skip to content

Commit

Permalink
Update generated client code (#215)
Browse files Browse the repository at this point in the history
## Problem

We need to update the generated core module to reflect upcoming API
changes

## Solution

- Migrate from v5 to v7 openapi generator to avoid generating code with
deprecated urllib3 usage.
- Regenerate contents of `pinecone.core` using pinecone-protos (private)
repo.
- Refactor to move all non-generated items out from under
`pinecone.core`. These never should have been under `pinecone.core` in
the first place.
  - Added `pinecone.utils`
  - Added `pinecone.grpc` to hold `GRPCIndex` and related code.
- Add new dependencies required by updated generated code (`pydantic`
for typechecking, `aenum` for enums)
- Disable legacy `integ` tests which won't work until we refactor
configuration.

## Type of Change

- [x] New feature (non-breaking change which adds functionality)
  • Loading branch information
jhamon authored Oct 16, 2023
1 parent 7ff4ed8 commit 17e0566
Show file tree
Hide file tree
Showing 100 changed files with 6,845 additions and 13,123 deletions.
4 changes: 1 addition & 3 deletions pinecone/__init__.py
Original file line number Diff line number Diff line change
@@ -1,15 +1,13 @@
"""
.. include:: ../README.md
"""
from pinecone.core.utils.constants import CLIENT_VERSION as __version__
from .config import *
from .exceptions import *
from .info import *
from .manage import *
from .index import *

try:
from .core.grpc.index_grpc import *
from .grpc.index_grpc import *
except ImportError:
pass # ignore for non-[grpc] installations

Expand Down
23 changes: 2 additions & 21 deletions pinecone/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,9 +11,8 @@
from urllib3.connection import HTTPConnection

from pinecone.core.client.exceptions import ApiKeyError
from pinecone.core.api_action import ActionAPI, WhoAmIResponse
from pinecone.core.utils import warn_deprecated, check_kwargs
from pinecone.core.utils.constants import (
from pinecone.utils import warn_deprecated, check_kwargs
from pinecone.utils.constants import (
CLIENT_VERSION,
PARENT_LOGGER_NAME,
DEFAULT_PARENT_LOGGER_LEVEL,
Expand Down Expand Up @@ -93,21 +92,6 @@ def reset(self, config_file=None, **kwargs):

self._config = config

# load project_name etc. from whoami api
action_api = ActionAPI(host=config.controller_host, api_key=config.api_key)
try:
whoami_response = action_api.whoami()
except requests.exceptions.RequestException:
# proceed with default values; reset() may be called later w/ correct values
whoami_response = WhoAmIResponse()

if not self._config.project_name:
config = config._replace(
**self._preprocess_and_validate_config({"project_name": whoami_response.projectname})
)

self._config = config

# Set OpenAPI client config
default_openapi_config = OpenApiConfiguration.get_default_copy()
default_openapi_config.ssl_ca_cert = certifi.where()
Expand Down Expand Up @@ -239,7 +223,6 @@ def init(
api_key: str = None,
host: str = None,
environment: str = None,
project_name: str = None,
log_level: str = None,
openapi_config: OpenApiConfiguration = None,
config: str = "~/.pinecone",
Expand All @@ -250,14 +233,12 @@ def init(
:param api_key: Required if not set in config file or by environment variable ``PINECONE_API_KEY``.
:param host: Optional. Controller host.
:param environment: Optional. Deployment environment.
:param project_name: Optional. Pinecone project name. Overrides the value that is otherwise looked up and used from the Pinecone backend.
:param openapi_config: Optional. Set OpenAPI client configuration.
:param config: Optional. An INI configuration file.
:param log_level: Deprecated since v2.0.2 [Will be removed in v3.0.0]; use the standard logging module to manage logger "pinecone" instead.
"""
check_kwargs(init, kwargs)
Config.reset(
project_name=project_name,
api_key=api_key,
controller_host=host,
environment=environment,
Expand Down
1 change: 0 additions & 1 deletion pinecone/core/__init__.py
Original file line number Diff line number Diff line change
@@ -1 +0,0 @@

37 changes: 0 additions & 37 deletions pinecone/core/api_action.py

This file was deleted.

35 changes: 0 additions & 35 deletions pinecone/core/api_base.py

This file was deleted.

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

# flake8: noqa

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


__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: 5 additions & 3 deletions pinecone/core/client/api/__init__.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# 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
# 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
Loading

0 comments on commit 17e0566

Please sign in to comment.