diff --git a/.github/actions/build-docs/action.yml b/.github/actions/build-docs/action.yml index 63181c448..e9d2f4607 100644 --- a/.github/actions/build-docs/action.yml +++ b/.github/actions/build-docs/action.yml @@ -1,15 +1,22 @@ name: 'Build client documentation' description: 'Generates client documentation using pdoc' +inputs: + python-version: + description: 'Python version to use' + required: true + default: '3.x' runs: using: 'composite' steps: - name: Setup Python uses: actions/setup-python@v4 with: - python-version: 3.x + python-version: ${{ inputs.python-version }} - name: Setup Poetry uses: ./.github/actions/setup-poetry + with: + include_grpc: 'true' - name: Build html documentation shell: bash diff --git a/.github/actions/setup-poetry/action.yml b/.github/actions/setup-poetry/action.yml index dae526e65..1b8f6e1b9 100644 --- a/.github/actions/setup-poetry/action.yml +++ b/.github/actions/setup-poetry/action.yml @@ -1,5 +1,10 @@ name: 'Setup Poetry' description: 'Installs Poetry and dependencies' +inputs: + include_grpc: + description: 'Install gRPC dependencies' + required: true + default: 'false' runs: using: 'composite' steps: @@ -7,6 +12,7 @@ runs: uses: snok/install-poetry@v1 - name: Install dependencies + if: ${{ inputs.include_grpc == 'false' }} shell: bash run: | poetry install @@ -16,6 +22,7 @@ runs: # The dependencies that are specific to gRPC are defined in pyproject.toml # under tool.poetry.extras - name: Install gRPC dependencies + if: ${{ inputs.include_grpc == 'true' }} shell: bash run: | poetry install --extras "grpc" diff --git a/.github/workflows/merge.yaml b/.github/workflows/merge.yaml index 5528aaa41..0b7585130 100644 --- a/.github/workflows/merge.yaml +++ b/.github/workflows/merge.yaml @@ -15,6 +15,8 @@ jobs: - name: Generate pdoc documentation uses: ./.github/actions/build-docs + with: + python-version: 3.11 - name: Deploy documentation to gh-pages uses: s0/git-publish-subdir-action@develop diff --git a/.github/workflows/pr.yaml b/.github/workflows/pr.yaml index d92cbc1ee..d61f74946 100644 --- a/.github/workflows/pr.yaml +++ b/.github/workflows/pr.yaml @@ -19,3 +19,5 @@ jobs: uses: actions/checkout@v3 - name: Build docs with pdoc uses: './.github/actions/build-docs' + with: + python-version: 3.11 \ No newline at end of file diff --git a/.github/workflows/testing.yaml b/.github/workflows/testing.yaml index 61b7ec05d..4e868ab9c 100644 --- a/.github/workflows/testing.yaml +++ b/.github/workflows/testing.yaml @@ -4,8 +4,8 @@ on: workflow_call: {} jobs: - run-tests: - name: Run tests + units-no-grpc: + name: Run tests (REST) runs-on: ubuntu-latest strategy: matrix: @@ -22,11 +22,58 @@ jobs: - name: Setup Poetry uses: ./.github/actions/setup-poetry - - name: Run tests - run: make tests + - name: Run unit tests + run: poetry run pytest --cov=pinecone --timeout=120 tests/unit + + - name: mypy check + run: | + # Still lots of errors when running on the whole package (especially + # in the generated core module), but we can check these subpackages + # so we don't add new regressions. + poetry run mypy pinecone/config + poetry run mypy pinecone/control + poetry run mypy pinecone/utils - - name: Build Python client - run: make package + units-grpc: + name: Run tests (GRPC) + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8, 3.9, '3.10', 3.11] + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Setup Poetry + uses: ./.github/actions/setup-poetry + with: + include_grpc: true + + - name: Run unit tests (GRPC) + run: poetry run pytest --cov=pinecone --timeout=120 tests/unit_grpc + + package: + name: Check packaging + runs-on: ubuntu-latest + strategy: + matrix: + python-version: [3.8, 3.9, '3.10', 3.11] + + steps: + - uses: actions/checkout@v3 + + - name: Set up Python ${{ matrix.python-version }} + uses: actions/setup-python@v4 + with: + python-version: ${{ matrix.python-version }} + + - name: Setup Poetry + uses: ./.github/actions/setup-poetry - - name: Build docs - run: make docs + - name: Package + run: poetry build diff --git a/Makefile b/Makefile index 62df52dd3..3f36bbf5a 100644 --- a/Makefile +++ b/Makefile @@ -9,12 +9,14 @@ image: develop: poetry install -E grpc -tests: - @echo "Installing dependencies..." - poetry install +test-unit: @echo "Running tests..." poetry run pytest --cov=pinecone --timeout=120 tests/unit +test-grpc-unit: + @echo "Running tests..." + poetry run pytest --cov=pinecone --timeout=120 tests/unit_grpc + version: poetry version diff --git a/pinecone/__init__.py b/pinecone/__init__.py index f3909e0b8..fbacdaddd 100644 --- a/pinecone/__init__.py +++ b/pinecone/__init__.py @@ -1,26 +1,7 @@ """ .. 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 * -except ImportError: - pass # ignore for non-[grpc] installations - -# Kept for backwards-compatibility -UpsertResult = None -"""@private""" -DeleteResult = None -"""@private""" -QueryResult = None -"""@private""" -FetchResult = None -"""@private""" -InfoResult = None -"""@private""" +from .control.pinecone import Pinecone +from .data.index import * \ No newline at end of file diff --git a/pinecone/config.py b/pinecone/config.py deleted file mode 100644 index dfde4b97f..000000000 --- a/pinecone/config.py +++ /dev/null @@ -1,279 +0,0 @@ -import logging -import sys -from typing import NamedTuple, List -import os - -import certifi -import requests -import configparser -import socket - -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 ( - CLIENT_VERSION, - PARENT_LOGGER_NAME, - DEFAULT_PARENT_LOGGER_LEVEL, - TCP_KEEPIDLE, - TCP_KEEPINTVL, - TCP_KEEPCNT, -) -from pinecone.core.client.configuration import Configuration as OpenApiConfiguration - -__all__ = ["Config", "init"] - -_logger = logging.getLogger(__name__) -_parent_logger = logging.getLogger(PARENT_LOGGER_NAME) -_parent_logger.setLevel(DEFAULT_PARENT_LOGGER_LEVEL) - - -class ConfigBase(NamedTuple): - environment: str = "" - api_key: str = "" - project_name: str = "" - controller_host: str = "" - openapi_config: OpenApiConfiguration = None - - -class _CONFIG: - """ - - Order of configs to load: - - - configs specified explicitly in reset - - environment variables - - configs specified in the INI file - - default configs - """ - - def __init__(self): - self.reset() - - def validate(self): - if not self._config.api_key: # None or empty string invalid - raise ApiKeyError("You haven't specified an Api-Key.") - - def reset(self, config_file=None, **kwargs): - config = ConfigBase() - - # Load config from file - file_config = self._load_config_file(config_file) - - # Get the environment first. Make sure that it is not overwritten in subsequent config objects. - environment = ( - kwargs.pop("environment", None) - or os.getenv("PINECONE_ENVIRONMENT") - or file_config.pop("environment", None) - or "us-west1-gcp" - ) - config = config._replace(environment=environment) - - # Set default config - default_config = ConfigBase( - controller_host="https://controller.{0}.pinecone.io".format(config.environment), - ) - config = config._replace(**self._preprocess_and_validate_config(default_config._asdict())) - - # Set INI file config - config = config._replace(**self._preprocess_and_validate_config(file_config)) - - # Set environment config - env_config = ConfigBase( - project_name=os.getenv("PINECONE_PROJECT_NAME"), - api_key=os.getenv("PINECONE_API_KEY"), - controller_host=os.getenv("PINECONE_CONTROLLER_HOST"), - ) - config = config._replace(**self._preprocess_and_validate_config(env_config._asdict())) - - # Set explicit config - config = config._replace(**self._preprocess_and_validate_config(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() - openapi_config = kwargs.pop("openapi_config", None) or default_openapi_config - - openapi_config.socket_options = self._get_socket_options() - - config = config._replace(openapi_config=openapi_config) - self._config = config - - def _preprocess_and_validate_config(self, config: dict) -> dict: - """Normalize, filter, and validate config keys/values. - - Trims whitespace, removes invalid keys (and the "environment" key), - and raises ValueError in case an invalid value was specified. - """ - # general preprocessing and filtering - result = {k: v for k, v in config.items() if k in ConfigBase._fields if v is not None} - result.pop("environment", None) - # validate api key - api_key = result.get("api_key") - # if api_key: - # try: - # uuid.UUID(api_key) - # except ValueError as e: - # raise ValueError(f"Pinecone API key \"{api_key}\" appears invalid. " - # f"Did you specify it correctly?") from e - return result - - def _load_config_file(self, config_file: str) -> dict: - """Load from INI config file.""" - config_obj = {} - if config_file: - full_path = os.path.expanduser(config_file) - if os.path.isfile(full_path): - parser = configparser.ConfigParser() - parser.read(full_path) - if "default" in parser.sections(): - config_obj = {**parser["default"]} - return config_obj - - @staticmethod - def _get_socket_options( - do_keep_alive: bool = True, - keep_alive_idle_sec: int = TCP_KEEPIDLE, - keep_alive_interval_sec: int = TCP_KEEPINTVL, - keep_alive_tries: int = TCP_KEEPCNT, - ) -> List[tuple]: - """ - Returns the socket options to pass to OpenAPI's Rest client - Args: - do_keep_alive: Whether to enable TCP keep alive mechanism - keep_alive_idle_sec: Time in seconds of connection idleness before starting to send keep alive probes - keep_alive_interval_sec: Interval time in seconds between keep alive probe messages - keep_alive_tries: Number of failed keep alive tries (unanswered KA messages) before terminating the connection - - Returns: - A list of socket options for the Rest client's connection pool - """ - # Source: https://www.finbourne.com/blog/the-mysterious-hanging-client-tcp-keep-alives - - socket_params = HTTPConnection.default_socket_options - if not do_keep_alive: - return socket_params - - socket_params += [(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)] - - # TCP Keep Alive Probes for different platforms - platform = sys.platform - # TCP Keep Alive Probes for Linux - if ( - platform == "linux" - and hasattr(socket, "TCP_KEEPIDLE") - and hasattr(socket, "TCP_KEEPINTVL") - and hasattr(socket, "TCP_KEEPCNT") - ): - socket_params += [(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, keep_alive_idle_sec)] - socket_params += [(socket.IPPROTO_TCP, socket.TCP_KEEPINTVL, keep_alive_interval_sec)] - socket_params += [(socket.IPPROTO_TCP, socket.TCP_KEEPCNT, keep_alive_tries)] - - # TCP Keep Alive Probes for Windows OS - # NOTE: Changing TCP KA params on windows is done via a different mechanism which OpenAPI's Rest client doesn't expose. - # Since the default values work well, it seems setting `(socket.SO_KEEPALIVE, 1)` is sufficient. - # Leaving this code here for future reference. - # elif platform == 'win32' and hasattr(socket, "SIO_KEEPALIVE_VALS"): - # socket.ioctl((socket.SIO_KEEPALIVE_VALS, (1, keep_alive_idle_sec * 1000, keep_alive_interval_sec * 1000))) - - # TCP Keep Alive Probes for Mac OS - elif platform == "darwin": - TCP_KEEPALIVE = 0x10 - socket_params += [(socket.IPPROTO_TCP, TCP_KEEPALIVE, keep_alive_interval_sec)] - - return socket_params - - @property - def ENVIRONMENT(self): - return self._config.environment - - @property - def API_KEY(self): - return self._config.api_key - - @property - def PROJECT_NAME(self): - return self._config.project_name - - @property - def CONTROLLER_HOST(self): - return self._config.controller_host - - @property - def OPENAPI_CONFIG(self): - return self._config.openapi_config - - @property - def LOG_LEVEL(self): - """ - Deprecated since v2.0.2 [Will be removed in v3.0.0]; use the standard logging module logger "pinecone" instead. - """ - warn_deprecated( - description='LOG_LEVEL is deprecated. Use the standard logging module logger "pinecone" instead.', - deprecated_in="2.0.2", - removal_in="3.0.0", - ) - return logging.getLevelName(logging.getLogger("pinecone").level) - - -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", - **kwargs -): - """Initializes the Pinecone client. - - :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, - openapi_config=openapi_config, - config_file=config, - **kwargs - ) - if log_level: - warn_deprecated( - description='log_level is deprecated. Use the standard logging module to manage logger "pinecone" instead.', - deprecated_in="2.0.2", - removal_in="3.0.0", - ) - - -Config = _CONFIG() - -# Init -init() diff --git a/pinecone/config/__init__.py b/pinecone/config/__init__.py new file mode 100644 index 000000000..42784d1ed --- /dev/null +++ b/pinecone/config/__init__.py @@ -0,0 +1,2 @@ +from .config import Config +from .pinecone_config import PineconeConfig diff --git a/pinecone/config/config.py b/pinecone/config/config.py new file mode 100644 index 000000000..0b31e10f3 --- /dev/null +++ b/pinecone/config/config.py @@ -0,0 +1,54 @@ +from typing import NamedTuple, Optional +import os + +from pinecone.exceptions import PineconeConfigurationError +from pinecone.core.client.exceptions import ApiKeyError +from pinecone.config.openapi import OpenApiConfigFactory +from pinecone.core.client.configuration import Configuration as OpenApiConfiguration + + +class Config(NamedTuple): + api_key: str = "" + host: str = "" + openapi_config: Optional[OpenApiConfiguration] = None + + +class ConfigBuilder: + """ + + Configurations are resolved in the following order: + + - configs passed as keyword parameters + - configs specified in environment variables + - default values (if applicable) + """ + + """Initializes the Pinecone client. + + :param api_key: Required if not set in config file or by environment variable ``PINECONE_API_KEY``. + :param host: Optional. Controller host. + :param openapi_config: Optional. Set OpenAPI client configuration. + """ + + @staticmethod + def build( + api_key: Optional[str] = None, + host: Optional[str] = None, + openapi_config: Optional[OpenApiConfiguration] = None, + **kwargs, + ) -> Config: + api_key = api_key or kwargs.pop("api_key", None) or os.getenv("PINECONE_API_KEY") + host = host or kwargs.pop("host", None) + + if not api_key: + raise PineconeConfigurationError("You haven't specified an Api-Key.") + if not host: + raise PineconeConfigurationError("You haven't specified a host.") + + openapi_config = ( + openapi_config + or kwargs.pop("openapi_config", None) + or OpenApiConfigFactory.build(api_key=api_key, host=host) + ) + + return Config(api_key, host, openapi_config) \ No newline at end of file diff --git a/pinecone/config/logging.py b/pinecone/config/logging.py new file mode 100644 index 000000000..51c788553 --- /dev/null +++ b/pinecone/config/logging.py @@ -0,0 +1,8 @@ +import logging + +PARENT_LOGGER_NAME = "pinecone" +DEFAULT_PARENT_LOGGER_LEVEL = "ERROR" + +_logger = logging.getLogger(__name__) +_parent_logger = logging.getLogger(PARENT_LOGGER_NAME) +_parent_logger.setLevel(DEFAULT_PARENT_LOGGER_LEVEL) diff --git a/pinecone/config/openapi.py b/pinecone/config/openapi.py new file mode 100644 index 000000000..cca504bc1 --- /dev/null +++ b/pinecone/config/openapi.py @@ -0,0 +1,79 @@ +import sys +from typing import List, Optional + +import certifi +import requests +import socket + +from urllib3.connection import HTTPConnection + +from pinecone.core.client.configuration import Configuration as OpenApiConfiguration + +TCP_KEEPINTVL = 60 # Sec +TCP_KEEPIDLE = 300 # Sec +TCP_KEEPCNT = 4 + + +class OpenApiConfigFactory: + @classmethod + def build(cls, api_key: str, host: Optional[str] = None, **kwargs): + openapi_config = OpenApiConfiguration() + openapi_config.host = host + openapi_config.ssl_ca_cert = certifi.where() + openapi_config.socket_options = cls._get_socket_options() + openapi_config.api_key = {"ApiKeyAuth": api_key} + return openapi_config + + @classmethod + def _get_socket_options( + self, + do_keep_alive: bool = True, + keep_alive_idle_sec: int = TCP_KEEPIDLE, + keep_alive_interval_sec: int = TCP_KEEPINTVL, + keep_alive_tries: int = TCP_KEEPCNT, + ) -> List[tuple]: + """ + Returns the socket options to pass to OpenAPI's Rest client + Args: + do_keep_alive: Whether to enable TCP keep alive mechanism + keep_alive_idle_sec: Time in seconds of connection idleness before starting to send keep alive probes + keep_alive_interval_sec: Interval time in seconds between keep alive probe messages + keep_alive_tries: Number of failed keep alive tries (unanswered KA messages) before terminating the connection + + Returns: + A list of socket options for the Rest client's connection pool + """ + # Source: https://www.finbourne.com/blog/the-mysterious-hanging-client-tcp-keep-alives + + socket_params = HTTPConnection.default_socket_options + if not do_keep_alive: + return socket_params + + socket_params += [(socket.SOL_SOCKET, socket.SO_KEEPALIVE, 1)] + + # TCP Keep Alive Probes for different platforms + platform = sys.platform + # TCP Keep Alive Probes for Linux + if ( + platform == "linux" + and hasattr(socket, "TCP_KEEPIDLE") + and hasattr(socket, "TCP_KEEPINTVL") + and hasattr(socket, "TCP_KEEPCNT") + ): + socket_params += [(socket.IPPROTO_TCP, socket.TCP_KEEPIDLE, keep_alive_idle_sec)] + socket_params += [(socket.IPPROTO_TCP, socket.TCP_KEEPINTVL, keep_alive_interval_sec)] + socket_params += [(socket.IPPROTO_TCP, socket.TCP_KEEPCNT, keep_alive_tries)] + + # TCP Keep Alive Probes for Windows OS + # NOTE: Changing TCP KA params on windows is done via a different mechanism which OpenAPI's Rest client doesn't expose. + # Since the default values work well, it seems setting `(socket.SO_KEEPALIVE, 1)` is sufficient. + # Leaving this code here for future reference. + # elif platform == 'win32' and hasattr(socket, "SIO_KEEPALIVE_VALS"): + # socket.ioctl((socket.SIO_KEEPALIVE_VALS, (1, keep_alive_idle_sec * 1000, keep_alive_interval_sec * 1000))) + + # TCP Keep Alive Probes for Mac OS + elif platform == "darwin": + TCP_KEEPALIVE = 0x10 + socket_params += [(socket.IPPROTO_TCP, TCP_KEEPALIVE, keep_alive_interval_sec)] + + return socket_params diff --git a/pinecone/config/pinecone_config.py b/pinecone/config/pinecone_config.py new file mode 100644 index 000000000..024431ed8 --- /dev/null +++ b/pinecone/config/pinecone_config.py @@ -0,0 +1,12 @@ +from typing import Optional +import os +from .config import ConfigBuilder, Config + +DEFAULT_CONTROLLER_HOST = "https://api.pinecone.io" + + +class PineconeConfig(): + @staticmethod + def build(api_key: Optional[str] = None, host: Optional[str] = None, **kwargs) -> Config: + host = host or kwargs.get("host") or os.getenv("PINECONE_CONTROLLER_HOST") or DEFAULT_CONTROLLER_HOST + return ConfigBuilder.build(api_key=api_key, host=host, **kwargs) diff --git a/pinecone/control/index_host_store.py b/pinecone/control/index_host_store.py new file mode 100644 index 000000000..dc15a0a92 --- /dev/null +++ b/pinecone/control/index_host_store.py @@ -0,0 +1,40 @@ +from typing import Dict +from pinecone.config import Config +from pinecone.core.client.api.index_operations_api import IndexOperationsApi + + +class SingletonMeta(type): + _instances: Dict[str, str] = {} + + def __call__(cls, *args, **kwargs): + if cls not in cls._instances: + instance = super().__call__(*args, **kwargs) + cls._instances[cls] = instance + return cls._instances[cls] + + +class IndexHostStore(metaclass=SingletonMeta): + def __init__(self): + self._indexHosts = {} + + def _key(self, config: Config, index_name: str) -> str: + return ":".join([config.api_key, index_name]) + + def delete_host(self, config: Config, index_name: str): + key = self._key(config, index_name) + if key in self._indexHosts: + del self._indexHosts[key] + + def set_host(self, config: Config, index_name: str, host: str): + if host: + key = self._key(config, index_name) + self._indexHosts[key] = "https://" + host + + def get_host(self, api: IndexOperationsApi, config: Config, index_name: str) -> str: + key = self._key(config, index_name) + if key in self._indexHosts: + return self._indexHosts[key] + else: + description = api.describe_index(index_name) + self.set_host(config, index_name, description.status.host) + return self._indexHosts[key] diff --git a/pinecone/control/models/collection_description.py b/pinecone/control/models/collection_description.py new file mode 100644 index 000000000..ff3f4b41a --- /dev/null +++ b/pinecone/control/models/collection_description.py @@ -0,0 +1,7 @@ +class CollectionDescription(object): + def __init__(self, keys, values): + for k, v in zip(keys, values): + self.__dict__[k] = v + + def __str__(self): + return str(self.__dict__) diff --git a/pinecone/control/models/index_description.py b/pinecone/control/models/index_description.py new file mode 100644 index 000000000..e86ffbd59 --- /dev/null +++ b/pinecone/control/models/index_description.py @@ -0,0 +1,13 @@ +from typing import NamedTuple + + +class IndexDescription(NamedTuple): + name: str + metric: str + replicas: int + dimension: int + shards: int + pods: int + pod_type: str + status: None + metadata_config: None diff --git a/pinecone/control/pinecone.py b/pinecone/control/pinecone.py new file mode 100644 index 000000000..7f95bff3d --- /dev/null +++ b/pinecone/control/pinecone.py @@ -0,0 +1,274 @@ +import time +from typing import Optional, Dict, Any, cast + +from .index_host_store import IndexHostStore + +from pinecone.config import PineconeConfig, Config + +from pinecone.control.models.index_description import IndexDescription +from pinecone.control.models.collection_description import CollectionDescription + +from pinecone.core.client.api.index_operations_api import IndexOperationsApi +from pinecone.core.client.api_client import ApiClient +from pinecone.core.client.models import CreateCollectionRequest, CreateRequest, PatchRequest +from pinecone.utils import get_user_agent + +from pinecone.data import Index + +class Pinecone: + def __init__( + self, + api_key: Optional[str] = None, + host: Optional[str] = None, + config: Optional[Config] = None, + index_api: Optional[IndexOperationsApi] = None, + **kwargs, + ): + if config or kwargs.get("config"): + configKwarg = config or kwargs.get("config") + if not isinstance(configKwarg, Config): + raise TypeError("config must be of type pinecone.config.Config") + else: + self.config = configKwarg + else: + self.config = PineconeConfig.build(api_key=api_key, host=host, **kwargs) + + if index_api: + self.index_api = index_api + else: + api_client = ApiClient(configuration=self.config.openapi_config) + api_client.user_agent = get_user_agent() + self.index_api = IndexOperationsApi(api_client) + + self.index_host_store = IndexHostStore() + + def create_index( + self, + name: str, + dimension: int, + cloud: str, + region: str, + capacity_mode: str, + timeout: Optional[int] = None, + index_type: str = "approximated", + metric: str = "cosine", + replicas: int = 1, + shards: int = 1, + pods: int = 1, + pod_type: str = "p1", + index_config: Optional[dict] = None, + metadata_config: Optional[dict] = None, + source_collection: str = "", + ): + """Creates a Pinecone index. + + :param name: the name of the index. + :type name: str + :param dimension: the dimension of vectors that would be inserted in the index + :param cloud: The cloud where you would like your index hosted. One of `{"aws", "gcp"}`. + :param region: The region where you would like your index hosted. + :param capacity_mode: The capacity mode for the index. One of `{"pod"}`. + :param index_type: type of index, one of `{"approximated", "exact"}`, defaults to "approximated". + The "approximated" index uses fast approximate search algorithms developed by Pinecone. + The "exact" index uses accurate exact search algorithms. + It performs exhaustive searches and thus it is usually slower than the "approximated" index. + :type index_type: str, optional + :param metric: type of metric used in the vector index, one of `{"cosine", "dotproduct", "euclidean"}`, defaults to "cosine". + Use "cosine" for cosine similarity, + "dotproduct" for dot-product, + and "euclidean" for euclidean distance. + :type metric: str, optional + :param replicas: the number of replicas, defaults to 1. + Use at least 2 replicas if you need high availability (99.99% uptime) for querying. + For additional throughput (QPS) your index needs to support, provision additional replicas. + :type replicas: int, optional + :param shards: the number of shards per index, defaults to 1. + Use 1 shard per 1GB of vectors + :type shards: int,optional + :param pods: Total number of pods to be used by the index. pods = shard*replicas + :type pods: int,optional + :param pod_type: the pod type to be used for the index. can be one of p1 or s1. + :type pod_type: str,optional + :param index_config: Advanced configuration options for the index + :param metadata_config: Configuration related to the metadata index + :type metadata_config: dict, optional + :param source_collection: Collection name to create the index from + :type metadata_config: str, optional + :type timeout: int, optional + :param timeout: Timeout for wait until index gets ready. If None, wait indefinitely; if >=0, time out after this many seconds; + if -1, return immediately and do not wait. Default: None + """ + api_instance = self.index_api + + api_instance.create_index( + create_request=CreateRequest( + name=name, + dimension=dimension, + cloud=cloud, + region=region, + capacity_mode=capacity_mode, + index_type=index_type, + metric=metric, + replicas=replicas, + shards=shards, + pods=pods, + pod_type=pod_type, + index_config=index_config or {}, + metadata_config=metadata_config, + source_collection=source_collection, + ) + ) + + def is_ready(): + status = self._get_status(name) + ready = status["ready"] + return ready + + if timeout == -1: + return + if timeout is None: + while not is_ready(): + time.sleep(5) + else: + while (not is_ready()) and timeout >= 0: + time.sleep(5) + timeout -= 5 + if timeout and timeout < 0: + raise ( + TimeoutError( + "Please call the describe_index API ({}) to confirm index status.".format( + "https://www.pinecone.io/docs/api/operation/describe_index/" + ) + ) + ) + + def delete_index(self, name: str, timeout: Optional[int] = None): + """Deletes a Pinecone index. + + :param name: the name of the index. + :type name: str + :param timeout: Timeout for wait until index gets ready. If None, wait indefinitely; if >=0, time out after this many seconds; + if -1, return immediately and do not wait. Default: None + :type timeout: int, optional + """ + api_instance = self.index_api + api_instance.delete_index(name) + self.index_host_store.delete_host(self.config, name) + + def get_remaining(): + return name in api_instance.list_indexes() + + if timeout == -1: + return + + if timeout is None: + while get_remaining(): + time.sleep(5) + else: + while get_remaining() and timeout >= 0: + time.sleep(5) + timeout -= 5 + if timeout and timeout < 0: + raise ( + TimeoutError( + "Please call the list_indexes API ({}) to confirm if index is deleted".format( + "https://www.pinecone.io/docs/api/operation/list_indexes/" + ) + ) + ) + + def list_indexes(self): + """Lists all indexes.""" + response = self.index_api.list_indexes() + return response + + def describe_index(self, name: str): + """Describes a Pinecone index. + + :param name: the name of the index to describe. + :return: Returns an `IndexDescription` object + """ + api_instance = self.index_api + response = api_instance.describe_index(name) + db = response.database + host = response.status.host + + self.index_host_store.set_host(self.config, name, host) + + return IndexDescription( + name=db.name, + metric=db.metric, + replicas=db.replicas, + dimension=db.dimension, + shards=db.shards, + pods=db.pods, + pod_type=db.pod_type, + status=response.status, + metadata_config=db.metadata_config, + ) + + def configure_index(self, name: str, replicas: Optional[int] = None, pod_type: Optional[str] = ""): + """Changes current configuration of the index. + :param: name: the name of the Index + :param: replicas: the desired number of replicas, lowest value is 0. + :param: pod_type: the new pod_type for the index. + """ + api_instance = self.index_api + config_args: Dict[str, Any] = {} + if pod_type != "": + config_args.update(pod_type=pod_type) + if replicas: + config_args.update(replicas=replicas) + patch_request = PatchRequest(**config_args) + api_instance.configure_index(name, patch_request=patch_request) + + def scale_index(self, name: str, replicas: int): + """Increases number of replicas for the index. + + :param name: the name of the Index + :type name: str + :param replicas: the number of replicas in the index now, lowest value is 0. + :type replicas: int + """ + api_instance = self.index_api + api_instance.configure_index(name, patch_request=PatchRequest(replicas=replicas, pod_type="")) + + def create_collection(self, name: str, source: str): + """Create a collection + :param name: Name of the collection + :param source: Name of the source index + """ + api_instance = self.index_api + api_instance.create_collection(create_collection_request=CreateCollectionRequest(name=name, source=source)) + + def list_collections(self): + """List all collections""" + api_instance = self.index_api + response = api_instance.list_collections() + return response + + def delete_collection(self, name: str): + """Deletes a collection. + :param: name: The name of the collection + """ + api_instance = self.index_api + api_instance.delete_collection(name) + + def describe_collection(self, name: str): + """Describes a collection. + :param: The name of the collection + :return: Description of the collection + """ + api_instance = self.index_api + response = api_instance.describe_collection(name).to_dict() + response_object = CollectionDescription(response.keys(), response.values()) + return response_object + + def _get_status(self, name: str): + api_instance = self.index_api + response = api_instance.describe_index(name) + return response["status"] + + def Index(self, name: str): + index_host = self.index_host_store.get_host(self.index_api, self.config, name) + return Index(api_key=self.config.api_key, host=index_host) diff --git a/pinecone/core/__init__.py b/pinecone/core/__init__.py index 8b1378917..e69de29bb 100644 --- a/pinecone/core/__init__.py +++ b/pinecone/core/__init__.py @@ -1 +0,0 @@ - diff --git a/pinecone/core/api_action.py b/pinecone/core/api_action.py deleted file mode 100644 index 12fc74f37..000000000 --- a/pinecone/core/api_action.py +++ /dev/null @@ -1,37 +0,0 @@ -from typing import NamedTuple -from pinecone.core.api_base import BaseAPI - -__all__ = ["ActionAPI", "VersionResponse", "WhoAmIResponse"] - -from pinecone.core.utils import get_version - - -class WhoAmIResponse(NamedTuple): - username: str = "UNKNOWN" - user_label: str = "UNKNOWN" - projectname: str = "UNKNOWN" - - -class VersionResponse(NamedTuple): - server: str - client: str - - -class ActionAPI(BaseAPI): - """User related API calls.""" - - client_version = get_version() - - def whoami(self) -> WhoAmIResponse: - """Returns user information.""" - response = self.get("/actions/whoami") - return WhoAmIResponse( - username=response.get("user_name", "UNDEFINED"), - projectname=response.get("project_name", "UNDEFINED"), - user_label=response.get("user_label", "UNDEFINED"), - ) - - def version(self) -> VersionResponse: - """Returns version information.""" - response = self.get("/actions/version") - return VersionResponse(server=response.get("version", "UNKNOWN"), client=self.client_version) diff --git a/pinecone/core/api_base.py b/pinecone/core/api_base.py deleted file mode 100644 index 93a3a7aec..000000000 --- a/pinecone/core/api_base.py +++ /dev/null @@ -1,35 +0,0 @@ -import requests -from requests.exceptions import HTTPError - - -class BaseAPI: - """Base class for HTTP API calls.""" - - def __init__(self, host: str, api_key: str = None): - self.host = host - self.api_key = api_key - - @property - def headers(self): - return {"api-key": self.api_key} - - def _send_request(self, request_handler, url, **kwargs): - response = request_handler("{0}{1}".format(self.host, url), headers=self.headers, **kwargs) - try: - response.raise_for_status() - except HTTPError as e: - e.args = e.args + (response.text,) - raise e - return response.json() - - def get(self, url: str, params: dict = None): - return self._send_request(requests.get, url, params=params) - - def post(self, url: str, json: dict = None): - return self._send_request(requests.post, url, json=json) - - def patch(self, url: str, json: dict = None): - return self._send_request(requests.patch, url, json=json) - - def delete(self, url: str): - return self._send_request(requests.delete, url) diff --git a/pinecone/core/client/api/index_operations_api.py b/pinecone/core/client/api/index_operations_api.py index 5da15f3e1..152af5ad2 100644 --- a/pinecone/core/client/api/index_operations_api.py +++ b/pinecone/core/client/api/index_operations_api.py @@ -1,9 +1,11 @@ """ - Pinecone index operations API + Pinecone API - # noqa: E501 + 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: support@pinecone.io + Generated by: https://openapi-generator.tech """ @@ -18,7 +20,7 @@ datetime, file_type, none_type, - validate_and_convert_types, + validate_and_convert_types ) from pinecone.core.client.model.collection_meta import CollectionMeta from pinecone.core.client.model.create_collection_request import CreateCollectionRequest @@ -39,7 +41,11 @@ def __init__(self, api_client=None): api_client = ApiClient() self.api_client = api_client - def __configure_index(self, index_name, **kwargs): + def __configure_index( + self, + index_name, + **kwargs + ): """configure_index # noqa: E501 This operation specifies the pod type and number of replicas for an index. # noqa: E501 @@ -79,73 +85,106 @@ def __configure_index(self, index_name, **kwargs): If the method is called asynchronously, returns the request thread. """ - kwargs["async_req"] = kwargs.get("async_req", False) - kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True) - kwargs["_preload_content"] = kwargs.get("_preload_content", True) - kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) - kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) - kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) - kwargs["_host_index"] = kwargs.get("_host_index") - kwargs["index_name"] = index_name + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['index_name'] = \ + index_name return self.call_with_http_info(**kwargs) self.configure_index = _Endpoint( settings={ - "response_type": (str,), - "auth": ["ApiKeyAuth"], - "endpoint_path": "/databases/{indexName}", - "operation_id": "configure_index", - "http_method": "PATCH", - "servers": [ + 'response_type': (str,), + 'auth': [ + 'ApiKeyAuth' + ], + 'endpoint_path': '/databases/{indexName}', + 'operation_id': 'configure_index', + 'http_method': 'PATCH', + 'servers': [ { - "url": "https://controller.{environment}.pinecone.io", - "description": "No description provided", - "variables": { - "environment": { - "description": "No description provided", - "default_value": "unknown", + 'url': "https://controller.{environment}.pinecone.io", + 'description': "No description provided", + 'variables': { + 'environment': { + 'description': "No description provided", + 'default_value': "unknown", + } } - }, }, - ], + ] }, params_map={ - "all": [ - "index_name", - "patch_request", + 'all': [ + 'index_name', + 'patch_request', + ], + 'required': [ + 'index_name', ], - "required": [ - "index_name", + 'nullable': [ ], - "nullable": [], - "enum": [], - "validation": [], + 'enum': [ + ], + 'validation': [ + ] }, root_map={ - "validations": {}, - "allowed_values": {}, - "openapi_types": { - "index_name": (str,), - "patch_request": (PatchRequest,), + 'validations': { + }, + 'allowed_values': { }, - "attribute_map": { - "index_name": "indexName", + 'openapi_types': { + 'index_name': + (str,), + 'patch_request': + (PatchRequest,), }, - "location_map": { - "index_name": "path", - "patch_request": "body", + 'attribute_map': { + 'index_name': 'indexName', }, - "collection_format_map": {}, + 'location_map': { + 'index_name': 'path', + 'patch_request': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'text/plain' + ], + 'content_type': [ + 'application/json' + ] }, - headers_map={"accept": ["text/plain"], "content_type": ["application/json"]}, api_client=api_client, - callable=__configure_index, + callable=__configure_index ) - def __create_collection(self, **kwargs): + def __create_collection( + self, + **kwargs + ): """create_collection # noqa: E501 - This operation creates a Pinecone collection from an existing index. # noqa: E501 + This operation creates a Pinecone collection. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True @@ -180,65 +219,97 @@ def __create_collection(self, **kwargs): If the method is called asynchronously, returns the request thread. """ - kwargs["async_req"] = kwargs.get("async_req", False) - kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True) - kwargs["_preload_content"] = kwargs.get("_preload_content", True) - kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) - kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) - kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) - kwargs["_host_index"] = kwargs.get("_host_index") + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') return self.call_with_http_info(**kwargs) self.create_collection = _Endpoint( settings={ - "response_type": (str,), - "auth": ["ApiKeyAuth"], - "endpoint_path": "/collections", - "operation_id": "create_collection", - "http_method": "POST", - "servers": [ + 'response_type': (str,), + 'auth': [ + 'ApiKeyAuth' + ], + 'endpoint_path': '/collections', + 'operation_id': 'create_collection', + 'http_method': 'POST', + 'servers': [ { - "url": "https://controller.{environment}.pinecone.io", - "description": "No description provided", - "variables": { - "environment": { - "description": "No description provided", - "default_value": "unknown", + 'url': "https://controller.{environment}.pinecone.io", + 'description': "No description provided", + 'variables': { + 'environment': { + 'description': "No description provided", + 'default_value': "unknown", + } } - }, }, - ], + ] }, params_map={ - "all": [ - "create_collection_request", + 'all': [ + 'create_collection_request', + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ ], - "required": [], - "nullable": [], - "enum": [], - "validation": [], + 'validation': [ + ] }, root_map={ - "validations": {}, - "allowed_values": {}, - "openapi_types": { - "create_collection_request": (CreateCollectionRequest,), + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'create_collection_request': + (CreateCollectionRequest,), }, - "attribute_map": {}, - "location_map": { - "create_collection_request": "body", + 'attribute_map': { }, - "collection_format_map": {}, + 'location_map': { + 'create_collection_request': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'text/plain' + ], + 'content_type': [ + 'application/json' + ] }, - headers_map={"accept": ["text/plain"], "content_type": ["application/json"]}, api_client=api_client, - callable=__create_collection, + callable=__create_collection ) - def __create_index(self, **kwargs): + def __create_index( + self, + **kwargs + ): """create_index # noqa: E501 - This operation creates a Pinecone index. Specify the distance metric, the dimension of vectors to be stored in the index, the numbers replicas to use, and the collection from which to create the index, if applicable. # noqa: E501 + This operation creates a Pinecone index. You can use it to specify the measure of similarity, the dimension of vectors to be stored in the index, the numbers of shards and replicas to use, and more. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True @@ -273,62 +344,95 @@ def __create_index(self, **kwargs): If the method is called asynchronously, returns the request thread. """ - kwargs["async_req"] = kwargs.get("async_req", False) - kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True) - kwargs["_preload_content"] = kwargs.get("_preload_content", True) - kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) - kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) - kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) - kwargs["_host_index"] = kwargs.get("_host_index") + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') return self.call_with_http_info(**kwargs) self.create_index = _Endpoint( settings={ - "response_type": (str,), - "auth": ["ApiKeyAuth"], - "endpoint_path": "/databases", - "operation_id": "create_index", - "http_method": "POST", - "servers": [ + 'response_type': (str,), + 'auth': [ + 'ApiKeyAuth' + ], + 'endpoint_path': '/databases', + 'operation_id': 'create_index', + 'http_method': 'POST', + 'servers': [ { - "url": "https://controller.{environment}.pinecone.io", - "description": "No description provided", - "variables": { - "environment": { - "description": "No description provided", - "default_value": "unknown", + 'url': "https://controller.{environment}.pinecone.io", + 'description': "No description provided", + 'variables': { + 'environment': { + 'description': "No description provided", + 'default_value': "unknown", + } } - }, }, - ], + ] }, params_map={ - "all": [ - "create_request", + 'all': [ + 'create_request', + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ ], - "required": [], - "nullable": [], - "enum": [], - "validation": [], + 'validation': [ + ] }, root_map={ - "validations": {}, - "allowed_values": {}, - "openapi_types": { - "create_request": (CreateRequest,), + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'create_request': + (CreateRequest,), }, - "attribute_map": {}, - "location_map": { - "create_request": "body", + 'attribute_map': { }, - "collection_format_map": {}, + 'location_map': { + 'create_request': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'text/plain' + ], + 'content_type': [ + 'application/json' + ] }, - headers_map={"accept": ["text/plain"], "content_type": ["application/json"]}, api_client=api_client, - callable=__create_index, + callable=__create_index ) - def __delete_collection(self, collection_name, **kwargs): + def __delete_collection( + self, + collection_name, + **kwargs + ): """delete_collection # noqa: E501 This operation deletes an existing collection. # noqa: E501 @@ -367,70 +471,98 @@ def __delete_collection(self, collection_name, **kwargs): If the method is called asynchronously, returns the request thread. """ - kwargs["async_req"] = kwargs.get("async_req", False) - kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True) - kwargs["_preload_content"] = kwargs.get("_preload_content", True) - kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) - kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) - kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) - kwargs["_host_index"] = kwargs.get("_host_index") - kwargs["collection_name"] = collection_name + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['collection_name'] = \ + collection_name return self.call_with_http_info(**kwargs) self.delete_collection = _Endpoint( settings={ - "response_type": (str,), - "auth": ["ApiKeyAuth"], - "endpoint_path": "/collections/{collectionName}", - "operation_id": "delete_collection", - "http_method": "DELETE", - "servers": [ + 'response_type': (str,), + 'auth': [ + 'ApiKeyAuth' + ], + 'endpoint_path': '/collections/{collectionName}', + 'operation_id': 'delete_collection', + 'http_method': 'DELETE', + 'servers': [ { - "url": "https://controller.{environment}.pinecone.io", - "description": "No description provided", - "variables": { - "environment": { - "description": "No description provided", - "default_value": "unknown", + 'url': "https://controller.{environment}.pinecone.io", + 'description': "No description provided", + 'variables': { + 'environment': { + 'description': "No description provided", + 'default_value': "unknown", + } } - }, }, - ], + ] }, params_map={ - "all": [ - "collection_name", + 'all': [ + 'collection_name', + ], + 'required': [ + 'collection_name', + ], + 'nullable': [ ], - "required": [ - "collection_name", + 'enum': [ ], - "nullable": [], - "enum": [], - "validation": [], + 'validation': [ + ] }, root_map={ - "validations": {}, - "allowed_values": {}, - "openapi_types": { - "collection_name": (str,), + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'collection_name': + (str,), }, - "attribute_map": { - "collection_name": "collectionName", + 'attribute_map': { + 'collection_name': 'collectionName', }, - "location_map": { - "collection_name": "path", + 'location_map': { + 'collection_name': 'path', }, - "collection_format_map": {}, + 'collection_format_map': { + } }, headers_map={ - "accept": ["text/plain"], - "content_type": [], + 'accept': [ + 'text/plain' + ], + 'content_type': [], }, api_client=api_client, - callable=__delete_collection, + callable=__delete_collection ) - def __delete_index(self, index_name, **kwargs): + def __delete_index( + self, + index_name, + **kwargs + ): """delete_index # noqa: E501 This operation deletes an existing index. # noqa: E501 @@ -469,73 +601,101 @@ def __delete_index(self, index_name, **kwargs): If the method is called asynchronously, returns the request thread. """ - kwargs["async_req"] = kwargs.get("async_req", False) - kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True) - kwargs["_preload_content"] = kwargs.get("_preload_content", True) - kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) - kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) - kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) - kwargs["_host_index"] = kwargs.get("_host_index") - kwargs["index_name"] = index_name + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['index_name'] = \ + index_name return self.call_with_http_info(**kwargs) self.delete_index = _Endpoint( settings={ - "response_type": (str,), - "auth": ["ApiKeyAuth"], - "endpoint_path": "/databases/{indexName}", - "operation_id": "delete_index", - "http_method": "DELETE", - "servers": [ + 'response_type': (str,), + 'auth': [ + 'ApiKeyAuth' + ], + 'endpoint_path': '/databases/{indexName}', + 'operation_id': 'delete_index', + 'http_method': 'DELETE', + 'servers': [ { - "url": "https://controller.{environment}.pinecone.io", - "description": "No description provided", - "variables": { - "environment": { - "description": "No description provided", - "default_value": "unknown", + 'url': "https://controller.{environment}.pinecone.io", + 'description': "No description provided", + 'variables': { + 'environment': { + 'description': "No description provided", + 'default_value': "unknown", + } } - }, }, - ], + ] }, params_map={ - "all": [ - "index_name", + 'all': [ + 'index_name', + ], + 'required': [ + 'index_name', + ], + 'nullable': [ ], - "required": [ - "index_name", + 'enum': [ ], - "nullable": [], - "enum": [], - "validation": [], + 'validation': [ + ] }, root_map={ - "validations": {}, - "allowed_values": {}, - "openapi_types": { - "index_name": (str,), + 'validations': { }, - "attribute_map": { - "index_name": "indexName", + 'allowed_values': { }, - "location_map": { - "index_name": "path", + 'openapi_types': { + 'index_name': + (str,), }, - "collection_format_map": {}, + 'attribute_map': { + 'index_name': 'indexName', + }, + 'location_map': { + 'index_name': 'path', + }, + 'collection_format_map': { + } }, headers_map={ - "accept": ["text/plain"], - "content_type": [], + 'accept': [ + 'text/plain' + ], + 'content_type': [], }, api_client=api_client, - callable=__delete_index, + callable=__delete_index ) - def __describe_collection(self, collection_name, **kwargs): + def __describe_collection( + self, + collection_name, + **kwargs + ): """describe_collection # noqa: E501 - Get a description of a collection, including the name, size, and status. # noqa: E501 + Get a description of a collection. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True @@ -571,73 +731,101 @@ def __describe_collection(self, collection_name, **kwargs): If the method is called asynchronously, returns the request thread. """ - kwargs["async_req"] = kwargs.get("async_req", False) - kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True) - kwargs["_preload_content"] = kwargs.get("_preload_content", True) - kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) - kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) - kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) - kwargs["_host_index"] = kwargs.get("_host_index") - kwargs["collection_name"] = collection_name + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['collection_name'] = \ + collection_name return self.call_with_http_info(**kwargs) self.describe_collection = _Endpoint( settings={ - "response_type": (CollectionMeta,), - "auth": ["ApiKeyAuth"], - "endpoint_path": "/collections/{collectionName}", - "operation_id": "describe_collection", - "http_method": "GET", - "servers": [ + 'response_type': (CollectionMeta,), + 'auth': [ + 'ApiKeyAuth' + ], + 'endpoint_path': '/collections/{collectionName}', + 'operation_id': 'describe_collection', + 'http_method': 'GET', + 'servers': [ { - "url": "https://controller.{environment}.pinecone.io", - "description": "No description provided", - "variables": { - "environment": { - "description": "No description provided", - "default_value": "unknown", + 'url': "https://controller.{environment}.pinecone.io", + 'description': "No description provided", + 'variables': { + 'environment': { + 'description': "No description provided", + 'default_value': "unknown", + } } - }, }, - ], + ] }, params_map={ - "all": [ - "collection_name", + 'all': [ + 'collection_name', ], - "required": [ - "collection_name", + 'required': [ + 'collection_name', ], - "nullable": [], - "enum": [], - "validation": [], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] }, root_map={ - "validations": {}, - "allowed_values": {}, - "openapi_types": { - "collection_name": (str,), + 'validations': { + }, + 'allowed_values': { }, - "attribute_map": { - "collection_name": "collectionName", + 'openapi_types': { + 'collection_name': + (str,), }, - "location_map": { - "collection_name": "path", + 'attribute_map': { + 'collection_name': 'collectionName', }, - "collection_format_map": {}, + 'location_map': { + 'collection_name': 'path', + }, + 'collection_format_map': { + } }, headers_map={ - "accept": ["application/json"], - "content_type": [], + 'accept': [ + 'application/json' + ], + 'content_type': [], }, api_client=api_client, - callable=__describe_collection, + callable=__describe_collection ) - def __describe_index(self, index_name, **kwargs): + def __describe_index( + self, + index_name, + **kwargs + ): """describe_index # noqa: E501 - Get a description of an index, including dimension, distance metric, number of replicas, and more. # noqa: E501 + Get a description of an index. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True @@ -673,70 +861,97 @@ def __describe_index(self, index_name, **kwargs): If the method is called asynchronously, returns the request thread. """ - kwargs["async_req"] = kwargs.get("async_req", False) - kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True) - kwargs["_preload_content"] = kwargs.get("_preload_content", True) - kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) - kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) - kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) - kwargs["_host_index"] = kwargs.get("_host_index") - kwargs["index_name"] = index_name + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['index_name'] = \ + index_name return self.call_with_http_info(**kwargs) self.describe_index = _Endpoint( settings={ - "response_type": (IndexMeta,), - "auth": ["ApiKeyAuth"], - "endpoint_path": "/databases/{indexName}", - "operation_id": "describe_index", - "http_method": "GET", - "servers": [ + 'response_type': (IndexMeta,), + 'auth': [ + 'ApiKeyAuth' + ], + 'endpoint_path': '/databases/{indexName}', + 'operation_id': 'describe_index', + 'http_method': 'GET', + 'servers': [ { - "url": "https://controller.{environment}.pinecone.io", - "description": "No description provided", - "variables": { - "environment": { - "description": "No description provided", - "default_value": "unknown", + 'url': "https://controller.{environment}.pinecone.io", + 'description': "No description provided", + 'variables': { + 'environment': { + 'description': "No description provided", + 'default_value': "unknown", + } } - }, }, - ], + ] }, params_map={ - "all": [ - "index_name", + 'all': [ + 'index_name', + ], + 'required': [ + 'index_name', ], - "required": [ - "index_name", + 'nullable': [ ], - "nullable": [], - "enum": [], - "validation": [], + 'enum': [ + ], + 'validation': [ + ] }, root_map={ - "validations": {}, - "allowed_values": {}, - "openapi_types": { - "index_name": (str,), + 'validations': { + }, + 'allowed_values': { }, - "attribute_map": { - "index_name": "indexName", + 'openapi_types': { + 'index_name': + (str,), }, - "location_map": { - "index_name": "path", + 'attribute_map': { + 'index_name': 'indexName', }, - "collection_format_map": {}, + 'location_map': { + 'index_name': 'path', + }, + 'collection_format_map': { + } }, headers_map={ - "accept": ["application/json"], - "content_type": [], + 'accept': [ + 'application/json' + ], + 'content_type': [], }, api_client=api_client, - callable=__describe_index, + callable=__describe_index ) - def __list_collections(self, **kwargs): + def __list_collections( + self, + **kwargs + ): """list_collections # noqa: E501 This operation returns a list of your Pinecone collections. # noqa: E501 @@ -773,56 +988,91 @@ def __list_collections(self, **kwargs): If the method is called asynchronously, returns the request thread. """ - kwargs["async_req"] = kwargs.get("async_req", False) - kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True) - kwargs["_preload_content"] = kwargs.get("_preload_content", True) - kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) - kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) - kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) - kwargs["_host_index"] = kwargs.get("_host_index") + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') return self.call_with_http_info(**kwargs) self.list_collections = _Endpoint( settings={ - "response_type": ([str],), - "auth": ["ApiKeyAuth"], - "endpoint_path": "/collections", - "operation_id": "list_collections", - "http_method": "GET", - "servers": [ + 'response_type': ([str],), + 'auth': [ + 'ApiKeyAuth' + ], + 'endpoint_path': '/collections', + 'operation_id': 'list_collections', + 'http_method': 'GET', + 'servers': [ { - "url": "https://controller.{environment}.pinecone.io", - "description": "No description provided", - "variables": { - "environment": { - "description": "No description provided", - "default_value": "unknown", + 'url': "https://controller.{environment}.pinecone.io", + 'description': "No description provided", + 'variables': { + 'environment': { + 'description': "No description provided", + 'default_value': "unknown", + } } - }, }, + ] + }, + params_map={ + 'all': [ ], + 'required': [], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] }, - params_map={"all": [], "required": [], "nullable": [], "enum": [], "validation": []}, root_map={ - "validations": {}, - "allowed_values": {}, - "openapi_types": {}, - "attribute_map": {}, - "location_map": {}, - "collection_format_map": {}, + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + }, + 'attribute_map': { + }, + 'location_map': { + }, + 'collection_format_map': { + } }, headers_map={ - "accept": ["application/json; charset=utf-8"], - "content_type": [], + 'accept': [ + 'application/json; charset=utf-8' + ], + 'content_type': [], }, api_client=api_client, - callable=__list_collections, + callable=__list_collections ) - def __list_indexes(self, **kwargs): + def __list_indexes( + self, + **kwargs + ): """list_indexes # noqa: E501 - This operation returns a list of the indexes in the current project. # noqa: E501 + This operation returns a list of your Pinecone indexes. # noqa: E501 This method makes a synchronous HTTP request by default. To make an asynchronous HTTP request, please pass async_req=True @@ -856,48 +1106,80 @@ def __list_indexes(self, **kwargs): If the method is called asynchronously, returns the request thread. """ - kwargs["async_req"] = kwargs.get("async_req", False) - kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True) - kwargs["_preload_content"] = kwargs.get("_preload_content", True) - kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) - kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) - kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) - kwargs["_host_index"] = kwargs.get("_host_index") + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') return self.call_with_http_info(**kwargs) self.list_indexes = _Endpoint( settings={ - "response_type": ([str],), - "auth": ["ApiKeyAuth"], - "endpoint_path": "/databases", - "operation_id": "list_indexes", - "http_method": "GET", - "servers": [ + 'response_type': ([str],), + 'auth': [ + 'ApiKeyAuth' + ], + 'endpoint_path': '/databases', + 'operation_id': 'list_indexes', + 'http_method': 'GET', + 'servers': [ { - "url": "https://controller.{environment}.pinecone.io", - "description": "No description provided", - "variables": { - "environment": { - "description": "No description provided", - "default_value": "unknown", + 'url': "https://controller.{environment}.pinecone.io", + 'description': "No description provided", + 'variables': { + 'environment': { + 'description': "No description provided", + 'default_value': "unknown", + } } - }, }, + ] + }, + params_map={ + 'all': [ + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ ], + 'validation': [ + ] }, - params_map={"all": [], "required": [], "nullable": [], "enum": [], "validation": []}, root_map={ - "validations": {}, - "allowed_values": {}, - "openapi_types": {}, - "attribute_map": {}, - "location_map": {}, - "collection_format_map": {}, + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + }, + 'attribute_map': { + }, + 'location_map': { + }, + 'collection_format_map': { + } }, headers_map={ - "accept": ["application/json; charset=utf-8"], - "content_type": [], + 'accept': [ + 'application/json; charset=utf-8' + ], + 'content_type': [], }, api_client=api_client, - callable=__list_indexes, + callable=__list_indexes ) diff --git a/pinecone/core/client/api/vector_operations_api.py b/pinecone/core/client/api/vector_operations_api.py index 1f6d2d259..c5bc02a2a 100644 --- a/pinecone/core/client/api/vector_operations_api.py +++ b/pinecone/core/client/api/vector_operations_api.py @@ -1,5 +1,5 @@ """ - Pinecone vector operations API + Pinecone API No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 @@ -20,7 +20,7 @@ datetime, file_type, none_type, - validate_and_convert_types, + validate_and_convert_types ) from pinecone.core.client.model.delete_request import DeleteRequest from pinecone.core.client.model.describe_index_stats_request import DescribeIndexStatsRequest @@ -46,12 +46,16 @@ def __init__(self, api_client=None): api_client = ApiClient() self.api_client = api_client - def __delete(self, delete_request, **kwargs): + def __delete( + self, + delete_request, + **kwargs + ): """Delete # noqa: E501 - The `Delete` operation deletes records by ID from a single namespace. # noqa: E501 + The `Delete` operation deletes vectors, by id, from a single namespace. You can delete items by their id, from a single namespace. # noqa: E501 This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, pass async_req=True + asynchronous HTTP request, please pass async_req=True >>> thread = api.delete(delete_request, async_req=True) >>> result = thread.get() @@ -60,24 +64,24 @@ def __delete(self, delete_request, **kwargs): delete_request (DeleteRequest): Keyword Args: - _return_http_data_only (bool): Return response data without head status + _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object - is returned without reading or decoding response data. + will be returned without reading/decoding response data. Default is True. - _request_timeout (int/float/tuple): The timeout setting for this request. If - one number is provided, it is the total request timeout. It can also + _request_timeout (int/float/tuple): timeout setting for this request. If + one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. - _check_input_type (bool): Specifies if type checking - should be done on the data sent to the server. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. Default is True. - _check_return_type (bool): Specifies if type checking - should be done on the data received from the server. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. Default is True. - _host_index (int/None): Specifies the index of the server + _host_index (int/None): specifies the index of the server that we want to use. - Default is to read from the configuration. + Default is read from the configuration. async_req (bool): execute request asynchronously Returns: @@ -85,86 +89,119 @@ def __delete(self, delete_request, **kwargs): If the method is called asynchronously, returns the request thread. """ - kwargs["async_req"] = kwargs.get("async_req", False) - kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True) - kwargs["_preload_content"] = kwargs.get("_preload_content", True) - kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) - kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) - kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) - kwargs["_host_index"] = kwargs.get("_host_index") - kwargs["delete_request"] = delete_request + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['delete_request'] = \ + delete_request return self.call_with_http_info(**kwargs) self.delete = _Endpoint( settings={ - "response_type": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), - "auth": ["ApiKeyAuth"], - "endpoint_path": "/vectors/delete", - "operation_id": "delete", - "http_method": "POST", - "servers": None, + 'response_type': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), + 'auth': [ + 'ApiKeyAuth' + ], + 'endpoint_path': '/vectors/delete', + 'operation_id': 'delete', + 'http_method': 'POST', + 'servers': None, }, params_map={ - "all": [ - "delete_request", + 'all': [ + 'delete_request', + ], + 'required': [ + 'delete_request', + ], + 'nullable': [ ], - "required": [ - "delete_request", + 'enum': [ ], - "nullable": [], - "enum": [], - "validation": [], + 'validation': [ + ] }, root_map={ - "validations": {}, - "allowed_values": {}, - "openapi_types": { - "delete_request": (DeleteRequest,), + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'delete_request': + (DeleteRequest,), }, - "attribute_map": {}, - "location_map": { - "delete_request": "body", + 'attribute_map': { }, - "collection_format_map": {}, + 'location_map': { + 'delete_request': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'application/json' + ] }, - headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, api_client=api_client, - callable=__delete, + callable=__delete ) - def __delete1(self, **kwargs): + def __delete1( + self, + **kwargs + ): """Delete # noqa: E501 - The `Delete` operation deletes records by ID from a single namespace. # noqa: E501 + The `Delete` operation deletes vectors, by id, from a single namespace. You can delete items by their id, from a single namespace. # noqa: E501 This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, pass async_req=True + asynchronous HTTP request, please pass async_req=True >>> thread = api.delete1(async_req=True) >>> result = thread.get() Keyword Args: - ids ([str]): Vectors to delete. [optional] - delete_all (bool): This indicates that all records in the index namespace should be deleted. [optional] Default is False. - namespace (str): The namespace to delete records from, if applicable. [optional] - _return_http_data_only (bool): Response data without head status + ids ([str]): Vectors to delete.. [optional] + delete_all (bool): This indicates that all vectors in the index namespace should be deleted.. [optional] if omitted the server will use the default value of False + namespace (str): The namespace to delete vectors from, if applicable.. [optional] + _return_http_data_only (bool): response data without head status code and headers. Default is True. - _preload_content (bool): If False, the urllib3.HTTPResponse object - is returned without reading or decoding response data. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - _request_timeout (int/float/tuple): Timeout setting for this request. If - one number is provided, this number is the total request timeout. This argument can also + _request_timeout (int/float/tuple): timeout setting for this request. If + one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. - _check_input_type (bool): Specifies if type checking - should be done after the data is sent to the server. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. Default is True. - _check_return_type (bool): Specifies if type checking - should be done after the data is received from the server. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. Default is True. - _host_index (int/None): Specifies the index of the server - to use. - Default is to read from the configuration. + _host_index (int/None): specifies the index of the server + that we want to use. + Default is read from the configuration. async_req (bool): execute request asynchronously Returns: @@ -172,71 +209,99 @@ def __delete1(self, **kwargs): If the method is called asynchronously, returns the request thread. """ - kwargs["async_req"] = kwargs.get("async_req", False) - kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True) - kwargs["_preload_content"] = kwargs.get("_preload_content", True) - kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) - kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) - kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) - kwargs["_host_index"] = kwargs.get("_host_index") + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') return self.call_with_http_info(**kwargs) self.delete1 = _Endpoint( settings={ - "response_type": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), - "auth": ["ApiKeyAuth"], - "endpoint_path": "/vectors/delete", - "operation_id": "delete1", - "http_method": "DELETE", - "servers": None, + 'response_type': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), + 'auth': [ + 'ApiKeyAuth' + ], + 'endpoint_path': '/vectors/delete', + 'operation_id': 'delete1', + 'http_method': 'DELETE', + 'servers': None, }, params_map={ - "all": [ - "ids", - "delete_all", - "namespace", + 'all': [ + 'ids', + 'delete_all', + 'namespace', + ], + 'required': [], + 'nullable': [ ], - "required": [], - "nullable": [], - "enum": [], - "validation": [], + 'enum': [ + ], + 'validation': [ + ] }, root_map={ - "validations": {}, - "allowed_values": {}, - "openapi_types": { - "ids": ([str],), - "delete_all": (bool,), - "namespace": (str,), + 'validations': { + }, + 'allowed_values': { }, - "attribute_map": { - "ids": "ids", - "delete_all": "deleteAll", - "namespace": "namespace", + 'openapi_types': { + 'ids': + ([str],), + 'delete_all': + (bool,), + 'namespace': + (str,), }, - "location_map": { - "ids": "query", - "delete_all": "query", - "namespace": "query", + 'attribute_map': { + 'ids': 'ids', + 'delete_all': 'deleteAll', + 'namespace': 'namespace', }, - "collection_format_map": { - "ids": "multi", + 'location_map': { + 'ids': 'query', + 'delete_all': 'query', + 'namespace': 'query', }, + 'collection_format_map': { + 'ids': 'multi', + } }, headers_map={ - "accept": ["application/json"], - "content_type": [], + 'accept': [ + 'application/json' + ], + 'content_type': [], }, api_client=api_client, - callable=__delete1, + callable=__delete1 ) - def __describe_index_stats(self, describe_index_stats_request, **kwargs): + def __describe_index_stats( + self, + describe_index_stats_request, + **kwargs + ): """DescribeIndexStats # noqa: E501 The `DescribeIndexStats` operation returns statistics about the index's contents, including the vector count per namespace, the number of dimensions, and the index fullness. The index fullness result may be inaccurate during pod resizing; to get the status of a pod resizing process, use [`describe_index`](https://www.pinecone.io/docs/api/operation/describe_index/). # noqa: E501 This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, pass async_req=True + asynchronous HTTP request, please pass async_req=True >>> thread = api.describe_index_stats(describe_index_stats_request, async_req=True) >>> result = thread.get() @@ -245,24 +310,24 @@ def __describe_index_stats(self, describe_index_stats_request, **kwargs): describe_index_stats_request (DescribeIndexStatsRequest): Keyword Args: - _return_http_data_only (bool): Return head status - code or headers. Default is True. - _preload_content (bool): If False, the urllib3.HTTPResponse object - is returned without reading or decoding response data. + _return_http_data_only (bool): response data without head status + code and headers. Default is True. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - _request_timeout (int/float/tuple): The timeout setting for this request. If - one number is provided, it is the total request timeout. It can also + _request_timeout (int/float/tuple): timeout setting for this request. If + one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. - _check_input_type (bool): Specifies if type checking - should be done on the data sent to the server. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. Default is True. - _check_return_type (bool): Specifies if type checking - should be done on the data received from the server. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. Default is True. - _host_index (int/None): Specifies the index of the server + _host_index (int/None): specifies the index of the server that we want to use. - Default is to read from the configuration. + Default is read from the configuration. async_req (bool): execute request asynchronously Returns: @@ -270,83 +335,116 @@ def __describe_index_stats(self, describe_index_stats_request, **kwargs): If the method is called asynchronously, returns the request thread. """ - kwargs["async_req"] = kwargs.get("async_req", False) - kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True) - kwargs["_preload_content"] = kwargs.get("_preload_content", True) - kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) - kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) - kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) - kwargs["_host_index"] = kwargs.get("_host_index") - kwargs["describe_index_stats_request"] = describe_index_stats_request + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['describe_index_stats_request'] = \ + describe_index_stats_request return self.call_with_http_info(**kwargs) self.describe_index_stats = _Endpoint( settings={ - "response_type": (DescribeIndexStatsResponse,), - "auth": ["ApiKeyAuth"], - "endpoint_path": "/describe_index_stats", - "operation_id": "describe_index_stats", - "http_method": "POST", - "servers": None, + 'response_type': (DescribeIndexStatsResponse,), + 'auth': [ + 'ApiKeyAuth' + ], + 'endpoint_path': '/describe_index_stats', + 'operation_id': 'describe_index_stats', + 'http_method': 'POST', + 'servers': None, }, params_map={ - "all": [ - "describe_index_stats_request", + 'all': [ + 'describe_index_stats_request', ], - "required": [ - "describe_index_stats_request", + 'required': [ + 'describe_index_stats_request', ], - "nullable": [], - "enum": [], - "validation": [], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] }, root_map={ - "validations": {}, - "allowed_values": {}, - "openapi_types": { - "describe_index_stats_request": (DescribeIndexStatsRequest,), + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'describe_index_stats_request': + (DescribeIndexStatsRequest,), + }, + 'attribute_map': { }, - "attribute_map": {}, - "location_map": { - "describe_index_stats_request": "body", + 'location_map': { + 'describe_index_stats_request': 'body', }, - "collection_format_map": {}, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'application/json' + ] }, - headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, api_client=api_client, - callable=__describe_index_stats, + callable=__describe_index_stats ) - def __describe_index_stats1(self, **kwargs): + def __describe_index_stats1( + self, + **kwargs + ): """DescribeIndexStats # noqa: E501 The `DescribeIndexStats` operation returns statistics about the index's contents, including the vector count per namespace, the number of dimensions, and the index fullness. The index fullness result may be inaccurate during pod resizing; to get the status of a pod resizing process, use [`describe_index`](https://www.pinecone.io/docs/api/operation/describe_index/). # noqa: E501 This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, pass async_req=True + asynchronous HTTP request, please pass async_req=True >>> thread = api.describe_index_stats1(async_req=True) >>> result = thread.get() Keyword Args: - _return_http_data_only (bool): Response data without head status + _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object - is returned without reading or decoding response data. + will be returned without reading/decoding response data. Default is True. - _request_timeout (int/float/tuple): The timeout setting for this request. If - one number is provided, it is the total request timeout. It can also + _request_timeout (int/float/tuple): timeout setting for this request. If + one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. - _check_input_type (bool): Specifies if type checking - should be done on the data sent to the server. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. Default is True. - _check_return_type (bool): Specifies if type checking - should be done on the data received from the server. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. Default is True. - _host_index (int/None): Specifies the index of the server + _host_index (int/None): specifies the index of the server that we want to use. - Default is to read from the configuration. + Default is read from the configuration. async_req (bool): execute request asynchronously Returns: @@ -354,47 +452,83 @@ def __describe_index_stats1(self, **kwargs): If the method is called asynchronously, returns the request thread. """ - kwargs["async_req"] = kwargs.get("async_req", False) - kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True) - kwargs["_preload_content"] = kwargs.get("_preload_content", True) - kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) - kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) - kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) - kwargs["_host_index"] = kwargs.get("_host_index") + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') return self.call_with_http_info(**kwargs) self.describe_index_stats1 = _Endpoint( settings={ - "response_type": (DescribeIndexStatsResponse,), - "auth": ["ApiKeyAuth"], - "endpoint_path": "/describe_index_stats", - "operation_id": "describe_index_stats1", - "http_method": "GET", - "servers": None, - }, - params_map={"all": [], "required": [], "nullable": [], "enum": [], "validation": []}, + 'response_type': (DescribeIndexStatsResponse,), + 'auth': [ + 'ApiKeyAuth' + ], + 'endpoint_path': '/describe_index_stats', + 'operation_id': 'describe_index_stats1', + 'http_method': 'GET', + 'servers': None, + }, + params_map={ + 'all': [ + ], + 'required': [], + 'nullable': [ + ], + 'enum': [ + ], + 'validation': [ + ] + }, root_map={ - "validations": {}, - "allowed_values": {}, - "openapi_types": {}, - "attribute_map": {}, - "location_map": {}, - "collection_format_map": {}, + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + }, + 'attribute_map': { + }, + 'location_map': { + }, + 'collection_format_map': { + } }, headers_map={ - "accept": ["application/json"], - "content_type": [], + 'accept': [ + 'application/json' + ], + 'content_type': [], }, api_client=api_client, - callable=__describe_index_stats1, + callable=__describe_index_stats1 ) - def __fetch(self, ids, **kwargs): + def __fetch( + self, + ids, + **kwargs + ): """Fetch # noqa: E501 - The `Fetch` operation looks up and returns vectors by ID from a single namespace. The returned vectors include the vector data and metadata. # noqa: E501 + The `Fetch` operation looks up and returns vectors, by ID, from a single namespace. The returned vectors include the vector data and/or metadata. # noqa: E501 This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, pass async_req=True + asynchronous HTTP request, please pass async_req=True >>> thread = api.fetch(ids, async_req=True) >>> result = thread.get() @@ -404,24 +538,24 @@ def __fetch(self, ids, **kwargs): Keyword Args: namespace (str): [optional] - _return_http_data_only (bool): Response data without head status + _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object - is returned without reading or decoding response data. + will be returned without reading/decoding response data. Default is True. - _request_timeout (int/float/tuple): The timeout setting for this request. If - one number is provided, it is the total request timeout. It can also + _request_timeout (int/float/tuple): timeout setting for this request. If + one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. - _check_input_type (bool): Specifies if type checking - should be done on the data sent to the server. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. Default is True. - _check_return_type (bool): Specifies if type checking - should be done on the data received from the server. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. Default is True. - _host_index (int/None): Specifies the index of the server + _host_index (int/None): specifies the index of the server that we want to use. - Default is to read from the configuration. + Default is read from the configuration. async_req (bool): execute request asynchronously Returns: @@ -429,70 +563,98 @@ def __fetch(self, ids, **kwargs): If the method is called asynchronously, returns the request thread. """ - kwargs["async_req"] = kwargs.get("async_req", False) - kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True) - kwargs["_preload_content"] = kwargs.get("_preload_content", True) - kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) - kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) - kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) - kwargs["_host_index"] = kwargs.get("_host_index") - kwargs["ids"] = ids + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['ids'] = \ + ids return self.call_with_http_info(**kwargs) self.fetch = _Endpoint( settings={ - "response_type": (FetchResponse,), - "auth": ["ApiKeyAuth"], - "endpoint_path": "/vectors/fetch", - "operation_id": "fetch", - "http_method": "GET", - "servers": None, + 'response_type': (FetchResponse,), + 'auth': [ + 'ApiKeyAuth' + ], + 'endpoint_path': '/vectors/fetch', + 'operation_id': 'fetch', + 'http_method': 'GET', + 'servers': None, }, params_map={ - "all": [ - "ids", - "namespace", + 'all': [ + 'ids', + 'namespace', + ], + 'required': [ + 'ids', ], - "required": [ - "ids", + 'nullable': [ ], - "nullable": [], - "enum": [], - "validation": [], + 'enum': [ + ], + 'validation': [ + ] }, root_map={ - "validations": {}, - "allowed_values": {}, - "openapi_types": { - "ids": ([str],), - "namespace": (str,), + 'validations': { + }, + 'allowed_values': { }, - "attribute_map": { - "ids": "ids", - "namespace": "namespace", + 'openapi_types': { + 'ids': + ([str],), + 'namespace': + (str,), }, - "location_map": { - "ids": "query", - "namespace": "query", + 'attribute_map': { + 'ids': 'ids', + 'namespace': 'namespace', }, - "collection_format_map": { - "ids": "multi", + 'location_map': { + 'ids': 'query', + 'namespace': 'query', }, + 'collection_format_map': { + 'ids': 'multi', + } }, headers_map={ - "accept": ["application/json"], - "content_type": [], + 'accept': [ + 'application/json' + ], + 'content_type': [], }, api_client=api_client, - callable=__fetch, + callable=__fetch ) - def __query(self, query_request, **kwargs): + def __query( + self, + query_request, + **kwargs + ): """Query # noqa: E501 - The `Query` operation searches a namespace using a query vector. It retrieves the IDs of the most similar records in a namespace along with their similarity scores. # noqa: E501 + The `Query` operation searches a namespace, using a query vector. It retrieves the ids of the most similar items in a namespace, along with their similarity scores. # noqa: E501 This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, pass async_req=True + asynchronous HTTP request, please pass async_req=True >>> thread = api.query(query_request, async_req=True) >>> result = thread.get() @@ -501,24 +663,24 @@ def __query(self, query_request, **kwargs): query_request (QueryRequest): Keyword Args: - _return_http_data_only (bool): Return response data without head status + _return_http_data_only (bool): response data without head status code and headers. Default is True. - _preload_content (bool): If False, the urllib3.HTTPResponse object - is returned without reading or decoding response data. + _preload_content (bool): if False, the urllib3.HTTPResponse object + will be returned without reading/decoding response data. Default is True. - _request_timeout (int/float/tuple): The timeout setting for this request. If - one number is provided, it is the total request timeout. It can also + _request_timeout (int/float/tuple): timeout setting for this request. If + one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. - _check_input_type (bool): Specifies if type checking - should be done on the data sent to the server. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. Default is True. - _check_return_type (bool): Specifies if type checking - should be done on the data received from the server. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. Default is True. - _host_index (int/None): Specifies the index of the server + _host_index (int/None): specifies the index of the server that we want to use. - Default is to read from the configuration. + Default is read from the configuration. async_req (bool): execute request asynchronously Returns: @@ -526,59 +688,93 @@ def __query(self, query_request, **kwargs): If the method is called asynchronously, returns the request thread. """ - kwargs["async_req"] = kwargs.get("async_req", False) - kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True) - kwargs["_preload_content"] = kwargs.get("_preload_content", True) - kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) - kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) - kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) - kwargs["_host_index"] = kwargs.get("_host_index") - kwargs["query_request"] = query_request + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['query_request'] = \ + query_request return self.call_with_http_info(**kwargs) self.query = _Endpoint( settings={ - "response_type": (QueryResponse,), - "auth": ["ApiKeyAuth"], - "endpoint_path": "/query", - "operation_id": "query", - "http_method": "POST", - "servers": None, + 'response_type': (QueryResponse,), + 'auth': [ + 'ApiKeyAuth' + ], + 'endpoint_path': '/query', + 'operation_id': 'query', + 'http_method': 'POST', + 'servers': None, }, params_map={ - "all": [ - "query_request", + 'all': [ + 'query_request', + ], + 'required': [ + 'query_request', + ], + 'nullable': [ ], - "required": [ - "query_request", + 'enum': [ ], - "nullable": [], - "enum": [], - "validation": [], + 'validation': [ + ] }, root_map={ - "validations": {}, - "allowed_values": {}, - "openapi_types": { - "query_request": (QueryRequest,), + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'query_request': + (QueryRequest,), }, - "attribute_map": {}, - "location_map": { - "query_request": "body", + 'attribute_map': { }, - "collection_format_map": {}, + 'location_map': { + 'query_request': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'application/json' + ] }, - headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, api_client=api_client, - callable=__query, + callable=__query ) - def __update(self, update_request, **kwargs): + def __update( + self, + update_request, + **kwargs + ): """Update # noqa: E501 - The `Update` operation updates a vector in a namespace. If a value is included, it overwrites the previous value. If set_metadata is included, the values of the fields specified in it are added to or overwrite the previous values. # noqa: E501 + The `Update` operation updates vector in a namespace. If a value is included, it will overwrite the previous value. If a set_metadata is included, the values of the fields specified in it will be added or overwrite the previous value. # noqa: E501 This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, pass async_req=True + asynchronous HTTP request, please pass async_req=True >>> thread = api.update(update_request, async_req=True) >>> result = thread.get() @@ -587,24 +783,24 @@ def __update(self, update_request, **kwargs): update_request (UpdateRequest): Keyword Args: - _return_http_data_only (bool): Response head status + _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object - is returned without reading or decoding response data. + will be returned without reading/decoding response data. Default is True. - _request_timeout (int/float/tuple): The timeout setting for this request. If - one number is provided, it is the total request timeout. It can also + _request_timeout (int/float/tuple): timeout setting for this request. If + one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. - _check_input_type (bool): Specifies if type checking - should be done on the data sent to the server. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. Default is True. - _check_return_type (bool): Specifies if type checking - should be done on the data received from the server. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. Default is True. - _host_index (int/None): Specifies the index of the server + _host_index (int/None): specifies the index of the server that we want to use. - Default is to read from the configuration. + Default is read from the configuration. async_req (bool): execute request asynchronously Returns: @@ -612,59 +808,93 @@ def __update(self, update_request, **kwargs): If the method is called asynchronously, returns the request thread. """ - kwargs["async_req"] = kwargs.get("async_req", False) - kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True) - kwargs["_preload_content"] = kwargs.get("_preload_content", True) - kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) - kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) - kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) - kwargs["_host_index"] = kwargs.get("_host_index") - kwargs["update_request"] = update_request + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['update_request'] = \ + update_request return self.call_with_http_info(**kwargs) self.update = _Endpoint( settings={ - "response_type": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), - "auth": ["ApiKeyAuth"], - "endpoint_path": "/vectors/update", - "operation_id": "update", - "http_method": "POST", - "servers": None, + 'response_type': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), + 'auth': [ + 'ApiKeyAuth' + ], + 'endpoint_path': '/vectors/update', + 'operation_id': 'update', + 'http_method': 'POST', + 'servers': None, }, params_map={ - "all": [ - "update_request", + 'all': [ + 'update_request', + ], + 'required': [ + 'update_request', + ], + 'nullable': [ ], - "required": [ - "update_request", + 'enum': [ ], - "nullable": [], - "enum": [], - "validation": [], + 'validation': [ + ] }, root_map={ - "validations": {}, - "allowed_values": {}, - "openapi_types": { - "update_request": (UpdateRequest,), + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'update_request': + (UpdateRequest,), }, - "attribute_map": {}, - "location_map": { - "update_request": "body", + 'attribute_map': { }, - "collection_format_map": {}, + 'location_map': { + 'update_request': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'application/json' + ] }, - headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, api_client=api_client, - callable=__update, + callable=__update ) - def __upsert(self, upsert_request, **kwargs): + def __upsert( + self, + upsert_request, + **kwargs + ): """Upsert # noqa: E501 - The `Upsert` operation writes vectors into a namespace. If a new value is upserted for an existing vector ID, it overwrites the previous value. # noqa: E501 + The `Upsert` operation writes vectors into a namespace. If a new value is upserted for an existing vector id, it will overwrite the previous value. # noqa: E501 This method makes a synchronous HTTP request by default. To make an - asynchronous HTTP request, pass async_req=True + asynchronous HTTP request, please pass async_req=True >>> thread = api.upsert(upsert_request, async_req=True) >>> result = thread.get() @@ -673,24 +903,24 @@ def __upsert(self, upsert_request, **kwargs): upsert_request (UpsertRequest): Keyword Args: - _return_http_data_only (bool): Return response data without head status + _return_http_data_only (bool): response data without head status code and headers. Default is True. _preload_content (bool): if False, the urllib3.HTTPResponse object - is returned without reading or decoding response data. + will be returned without reading/decoding response data. Default is True. - _request_timeout (int/float/tuple): The timeout setting for this request. If - one number is provided, it is the total request timeout. It can also + _request_timeout (int/float/tuple): timeout setting for this request. If + one number provided, it will be total request timeout. It can also be a pair (tuple) of (connection, read) timeouts. Default is None. - _check_input_type (bool): Specifies if type checking - should be done on the data sent to the server. + _check_input_type (bool): specifies if type checking + should be done one the data sent to the server. Default is True. - _check_return_type (bool): Specifies if type checking - should be done on the data received from the server. + _check_return_type (bool): specifies if type checking + should be done one the data received from the server. Default is True. - _host_index (int/None): Specifies the index of the server + _host_index (int/None): specifies the index of the server that we want to use. - Default is to read from the configuration. + Default is read from the configuration. async_req (bool): execute request asynchronously Returns: @@ -698,49 +928,79 @@ def __upsert(self, upsert_request, **kwargs): If the method is called asynchronously, returns the request thread. """ - kwargs["async_req"] = kwargs.get("async_req", False) - kwargs["_return_http_data_only"] = kwargs.get("_return_http_data_only", True) - kwargs["_preload_content"] = kwargs.get("_preload_content", True) - kwargs["_request_timeout"] = kwargs.get("_request_timeout", None) - kwargs["_check_input_type"] = kwargs.get("_check_input_type", True) - kwargs["_check_return_type"] = kwargs.get("_check_return_type", True) - kwargs["_host_index"] = kwargs.get("_host_index") - kwargs["upsert_request"] = upsert_request + kwargs['async_req'] = kwargs.get( + 'async_req', False + ) + kwargs['_return_http_data_only'] = kwargs.get( + '_return_http_data_only', True + ) + kwargs['_preload_content'] = kwargs.get( + '_preload_content', True + ) + kwargs['_request_timeout'] = kwargs.get( + '_request_timeout', None + ) + kwargs['_check_input_type'] = kwargs.get( + '_check_input_type', True + ) + kwargs['_check_return_type'] = kwargs.get( + '_check_return_type', True + ) + kwargs['_host_index'] = kwargs.get('_host_index') + kwargs['upsert_request'] = \ + upsert_request return self.call_with_http_info(**kwargs) self.upsert = _Endpoint( settings={ - "response_type": (UpsertResponse,), - "auth": ["ApiKeyAuth"], - "endpoint_path": "/vectors/upsert", - "operation_id": "upsert", - "http_method": "POST", - "servers": None, + 'response_type': (UpsertResponse,), + 'auth': [ + 'ApiKeyAuth' + ], + 'endpoint_path': '/vectors/upsert', + 'operation_id': 'upsert', + 'http_method': 'POST', + 'servers': None, }, params_map={ - "all": [ - "upsert_request", + 'all': [ + 'upsert_request', + ], + 'required': [ + 'upsert_request', + ], + 'nullable': [ ], - "required": [ - "upsert_request", + 'enum': [ ], - "nullable": [], - "enum": [], - "validation": [], + 'validation': [ + ] }, root_map={ - "validations": {}, - "allowed_values": {}, - "openapi_types": { - "upsert_request": (UpsertRequest,), + 'validations': { + }, + 'allowed_values': { + }, + 'openapi_types': { + 'upsert_request': + (UpsertRequest,), }, - "attribute_map": {}, - "location_map": { - "upsert_request": "body", + 'attribute_map': { }, - "collection_format_map": {}, + 'location_map': { + 'upsert_request': 'body', + }, + 'collection_format_map': { + } + }, + headers_map={ + 'accept': [ + 'application/json' + ], + 'content_type': [ + 'application/json' + ] }, - headers_map={"accept": ["application/json"], "content_type": ["application/json"]}, api_client=api_client, - callable=__upsert, + callable=__upsert ) diff --git a/pinecone/core/client/api_client.py b/pinecone/core/client/api_client.py index 8084c5321..770fc07cd 100644 --- a/pinecone/core/client/api_client.py +++ b/pinecone/core/client/api_client.py @@ -36,7 +36,7 @@ file_type, model_to_dict, none_type, - validate_and_convert_types, + validate_and_convert_types ) @@ -64,7 +64,8 @@ class ApiClient(object): _pool = None - def __init__(self, configuration=None, header_name=None, header_value=None, cookie=None, pool_threads=1): + def __init__(self, configuration=None, header_name=None, header_value=None, + cookie=None, pool_threads=1): if configuration is None: configuration = Configuration.get_default_copy() self.configuration = configuration @@ -76,7 +77,7 @@ def __init__(self, configuration=None, header_name=None, header_value=None, cook self.default_headers[header_name] = header_value self.cookie = cookie # Set default User-Agent. - self.user_agent = "OpenAPI-Generator/1.0.0/python" + self.user_agent = 'OpenAPI-Generator/1.0.0/python' def __enter__(self): return self @@ -89,13 +90,13 @@ def close(self): self._pool.close() self._pool.join() self._pool = None - if hasattr(atexit, "unregister"): + if hasattr(atexit, 'unregister'): atexit.unregister(self.close) @property def pool(self): """Create thread pool on first request - avoids instantiating unused threadpool for blocking clients. + avoids instantiating unused threadpool for blocking clients. """ if self._pool is None: atexit.register(self.close) @@ -105,11 +106,11 @@ def pool(self): @property def user_agent(self): """User agent for this API client""" - return self.default_headers["User-Agent"] + return self.default_headers['User-Agent'] @user_agent.setter def user_agent(self, value): - self.default_headers["User-Agent"] = value + self.default_headers['User-Agent'] = value def set_default_header(self, header_name, header_value): self.default_headers[header_name] = header_value @@ -131,47 +132,57 @@ def __call_api( _preload_content: bool = True, _request_timeout: typing.Optional[typing.Union[int, float, typing.Tuple]] = None, _host: typing.Optional[str] = None, - _check_type: typing.Optional[bool] = None, + _check_type: typing.Optional[bool] = None ): + config = self.configuration # header parameters header_params = header_params or {} header_params.update(self.default_headers) if self.cookie: - header_params["Cookie"] = self.cookie + header_params['Cookie'] = self.cookie if header_params: header_params = self.sanitize_for_serialization(header_params) - header_params = dict(self.parameters_to_tuples(header_params, collection_formats)) + header_params = dict(self.parameters_to_tuples(header_params, + collection_formats)) # path parameters if path_params: path_params = self.sanitize_for_serialization(path_params) - path_params = self.parameters_to_tuples(path_params, collection_formats) + path_params = self.parameters_to_tuples(path_params, + collection_formats) for k, v in path_params: # specified safe chars, encode everything - resource_path = resource_path.replace("{%s}" % k, quote(str(v), safe=config.safe_chars_for_path_param)) + resource_path = resource_path.replace( + '{%s}' % k, + quote(str(v), safe=config.safe_chars_for_path_param) + ) # query parameters if query_params: query_params = self.sanitize_for_serialization(query_params) - query_params = self.parameters_to_tuples(query_params, collection_formats) + query_params = self.parameters_to_tuples(query_params, + collection_formats) # post parameters if post_params or files: post_params = post_params if post_params else [] post_params = self.sanitize_for_serialization(post_params) - post_params = self.parameters_to_tuples(post_params, collection_formats) + post_params = self.parameters_to_tuples(post_params, + collection_formats) post_params.extend(self.files_parameters(files)) - if header_params["Content-Type"].startswith("multipart"): - post_params = self.parameters_to_multipart(post_params, (dict)) + if header_params['Content-Type'].startswith("multipart"): + post_params = self.parameters_to_multipart(post_params, + (dict) ) # body if body: body = self.sanitize_for_serialization(body) # auth setting - self.update_params_for_auth(header_params, query_params, auth_settings, resource_path, method, body) + self.update_params_for_auth(header_params, query_params, + auth_settings, resource_path, method, body) # request url if _host is None: @@ -183,17 +194,12 @@ def __call_api( try: # perform request and return response response_data = self.request( - method, - url, - query_params=query_params, - headers=header_params, - post_params=post_params, - body=body, + method, url, query_params=query_params, headers=header_params, + post_params=post_params, body=body, _preload_content=_preload_content, - _request_timeout=_request_timeout, - ) + _request_timeout=_request_timeout) except ApiException as e: - e.body = e.body.decode("utf-8") + e.body = e.body.decode('utf-8') raise e self.last_response = response_data @@ -201,28 +207,33 @@ def __call_api( return_data = response_data if not _preload_content: - return return_data + return (return_data) return return_data # deserialize response data if response_type: if response_type != (file_type,): encoding = "utf-8" - content_type = response_data.getheader("content-type") + content_type = response_data.getheader('content-type') if content_type is not None: match = re.search(r"charset=([a-zA-Z\-\d]+)[\s\;]?", content_type) if match: encoding = match.group(1) response_data.data = response_data.data.decode(encoding) - return_data = self.deserialize(response_data, response_type, _check_type) + return_data = self.deserialize( + response_data, + response_type, + _check_type + ) else: return_data = None if _return_http_data_only: - return return_data + return (return_data) else: - return (return_data, response_data.status, response_data.getheaders()) + return (return_data, response_data.status, + response_data.getheaders()) def parameters_to_multipart(self, params, collection_types): """Get parameters as list of tuples, formatting as json if value is collection_types @@ -233,15 +244,15 @@ def parameters_to_multipart(self, params, collection_types): """ new_params = [] if collection_types is None: - collection_types = dict + collection_types = (dict) for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501 - if isinstance(v, collection_types): # v is instance of collection_type, formatting as application/json - v = json.dumps(v, ensure_ascii=False).encode("utf-8") - field = RequestField(k, v) - field.make_multipart(content_type="application/json; charset=utf-8") - new_params.append(field) + if isinstance(v, collection_types): # v is instance of collection_type, formatting as application/json + v = json.dumps(v, ensure_ascii=False).encode("utf-8") + field = RequestField(k, v) + field.make_multipart(content_type="application/json; charset=utf-8") + new_params.append(field) else: - new_params.append((k, v)) + new_params.append((k, v)) return new_params @classmethod @@ -259,7 +270,9 @@ def sanitize_for_serialization(cls, obj): :return: The serialized form of data. """ if isinstance(obj, (ModelNormal, ModelComposed)): - return {key: cls.sanitize_for_serialization(val) for key, val in model_to_dict(obj, serialize=True).items()} + return { + key: cls.sanitize_for_serialization(val) for key, val in model_to_dict(obj, serialize=True).items() + } elif isinstance(obj, io.IOBase): return cls.get_file_data_and_close_file(obj) elif isinstance(obj, (str, int, float, none_type, bool)): @@ -272,7 +285,7 @@ def sanitize_for_serialization(cls, obj): return [cls.sanitize_for_serialization(item) for item in obj] if isinstance(obj, dict): return {key: cls.sanitize_for_serialization(val) for key, val in obj.items()} - raise ApiValueError("Unable to prepare type {} for serialization".format(obj.__class__.__name__)) + raise ApiValueError('Unable to prepare type {} for serialization'.format(obj.__class__.__name__)) def deserialize(self, response, response_type, _check_type): """Deserializes response into an object. @@ -298,7 +311,8 @@ def deserialize(self, response, response_type, _check_type): # save response body into a tmp file and return the instance if response_type == (file_type,): content_disposition = response.getheader("Content-Disposition") - return deserialize_file(response.data, self.configuration, content_disposition=content_disposition) + return deserialize_file(response.data, self.configuration, + content_disposition=content_disposition) # fetch data from response object try: @@ -309,7 +323,12 @@ def deserialize(self, response, response_type, _check_type): # store our data under the key of 'received_data' so users have some # context if they are deserializing a string and the data type is wrong deserialized_data = validate_and_convert_types( - received_data, response_type, ["received_data"], True, _check_type, configuration=self.configuration + received_data, + response_type, + ['received_data'], + True, + _check_type, + configuration=self.configuration ) return deserialized_data @@ -331,7 +350,7 @@ def call_api( _preload_content: bool = True, _request_timeout: typing.Optional[typing.Union[int, float, typing.Tuple]] = None, _host: typing.Optional[str] = None, - _check_type: typing.Optional[bool] = None, + _check_type: typing.Optional[bool] = None ): """Makes the HTTP request (synchronous) and returns deserialized data. @@ -387,126 +406,87 @@ def call_api( then the method will return the response directly. """ if not async_req: - return self.__call_api( - resource_path, - method, - path_params, - query_params, - header_params, - body, - post_params, - files, - response_type, - auth_settings, - _return_http_data_only, - collection_formats, - _preload_content, - _request_timeout, - _host, - _check_type, - ) - - return self.pool.apply_async( - self.__call_api, - ( - resource_path, - method, - path_params, - query_params, - header_params, - body, - post_params, - files, - response_type, - auth_settings, - _return_http_data_only, - collection_formats, - _preload_content, - _request_timeout, - _host, - _check_type, - ), - ) - - def request( - self, - method, - url, - query_params=None, - headers=None, - post_params=None, - body=None, - _preload_content=True, - _request_timeout=None, - ): + return self.__call_api(resource_path, method, + path_params, query_params, header_params, + body, post_params, files, + response_type, auth_settings, + _return_http_data_only, collection_formats, + _preload_content, _request_timeout, _host, + _check_type) + + return self.pool.apply_async(self.__call_api, (resource_path, + method, path_params, + query_params, + header_params, body, + post_params, files, + response_type, + auth_settings, + _return_http_data_only, + collection_formats, + _preload_content, + _request_timeout, + _host, _check_type)) + + def request(self, method, url, query_params=None, headers=None, + post_params=None, body=None, _preload_content=True, + _request_timeout=None): """Makes the HTTP request using RESTClient.""" if method == "GET": - return self.rest_client.GET( - url, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - headers=headers, - ) + return self.rest_client.GET(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) elif method == "HEAD": - return self.rest_client.HEAD( - url, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - headers=headers, - ) + return self.rest_client.HEAD(url, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + headers=headers) elif method == "OPTIONS": - return self.rest_client.OPTIONS( - url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) + return self.rest_client.OPTIONS(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) elif method == "POST": - return self.rest_client.POST( - url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) + return self.rest_client.POST(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) elif method == "PUT": - return self.rest_client.PUT( - url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) + return self.rest_client.PUT(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) elif method == "PATCH": - return self.rest_client.PATCH( - url, - query_params=query_params, - headers=headers, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) + return self.rest_client.PATCH(url, + query_params=query_params, + headers=headers, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) elif method == "DELETE": - return self.rest_client.DELETE( - url, - query_params=query_params, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) + return self.rest_client.DELETE(url, + query_params=query_params, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) else: - raise ApiValueError("http method must be `GET`, `HEAD`, `OPTIONS`," " `POST`, `PATCH`, `PUT` or `DELETE`.") + raise ApiValueError( + "http method must be `GET`, `HEAD`, `OPTIONS`," + " `POST`, `PATCH`, `PUT` or `DELETE`." + ) def parameters_to_tuples(self, params, collection_formats): """Get parameters as list of tuples, formatting collections. @@ -521,18 +501,19 @@ def parameters_to_tuples(self, params, collection_formats): for k, v in params.items() if isinstance(params, dict) else params: # noqa: E501 if k in collection_formats: collection_format = collection_formats[k] - if collection_format == "multi": + if collection_format == 'multi': new_params.extend((k, value) for value in v) else: - if collection_format == "ssv": - delimiter = " " - elif collection_format == "tsv": - delimiter = "\t" - elif collection_format == "pipes": - delimiter = "|" + if collection_format == 'ssv': + delimiter = ' ' + elif collection_format == 'tsv': + delimiter = '\t' + elif collection_format == 'pipes': + delimiter = '|' else: # csv is the default - delimiter = "," - new_params.append((k, delimiter.join(str(value) for value in v))) + delimiter = ',' + new_params.append( + (k, delimiter.join(str(value) for value in v))) else: new_params.append((k, v)) return new_params @@ -564,12 +545,15 @@ def files_parameters(self, files: typing.Optional[typing.Dict[str, typing.List[i continue if file_instance.closed is True: raise ApiValueError( - "Cannot read a closed file. The passed in file_type " "for %s must be open." % param_name + "Cannot read a closed file. The passed in file_type " + "for %s must be open." % param_name ) filename = os.path.basename(file_instance.name) filedata = self.get_file_data_and_close_file(file_instance) - mimetype = mimetypes.guess_type(filename)[0] or "application/octet-stream" - params.append(tuple([param_name, tuple([filename, filedata, mimetype])])) + mimetype = (mimetypes.guess_type(filename)[0] or + 'application/octet-stream') + params.append( + tuple([param_name, tuple([filename, filedata, mimetype])])) return params @@ -584,10 +568,10 @@ def select_header_accept(self, accepts): accepts = [x.lower() for x in accepts] - if "application/json" in accepts: - return "application/json" + if 'application/json' in accepts: + return 'application/json' else: - return ", ".join(accepts) + return ', '.join(accepts) def select_header_content_type(self, content_types): """Returns `Content-Type` based on an array of content_types provided. @@ -596,16 +580,17 @@ def select_header_content_type(self, content_types): :return: Content-Type (e.g. application/json). """ if not content_types: - return "application/json" + return 'application/json' content_types = [x.lower() for x in content_types] - if "application/json" in content_types or "*/*" in content_types: - return "application/json" + if 'application/json' in content_types or '*/*' in content_types: + return 'application/json' else: return content_types[0] - def update_params_for_auth(self, headers, querys, auth_settings, resource_path, method, body): + def update_params_for_auth(self, headers, querys, auth_settings, + resource_path, method, body): """Updates header and query params based on authentication setting. :param headers: Header parameters dict to be updated. @@ -622,19 +607,22 @@ def update_params_for_auth(self, headers, querys, auth_settings, resource_path, for auth in auth_settings: auth_setting = self.configuration.auth_settings().get(auth) if auth_setting: - if auth_setting["in"] == "cookie": - headers["Cookie"] = auth_setting["value"] - elif auth_setting["in"] == "header": - if auth_setting["type"] != "http-signature": - headers[auth_setting["key"]] = auth_setting["value"] - elif auth_setting["in"] == "query": - querys.append((auth_setting["key"], auth_setting["value"])) + if auth_setting['in'] == 'cookie': + headers['Cookie'] = auth_setting['value'] + elif auth_setting['in'] == 'header': + if auth_setting['type'] != 'http-signature': + headers[auth_setting['key']] = auth_setting['value'] + elif auth_setting['in'] == 'query': + querys.append((auth_setting['key'], auth_setting['value'])) else: - raise ApiValueError("Authentication token must be in `query` or `header`") + raise ApiValueError( + 'Authentication token must be in `query` or `header`' + ) class Endpoint(object): - def __init__(self, settings=None, params_map=None, root_map=None, headers_map=None, api_client=None, callable=None): + def __init__(self, settings=None, params_map=None, root_map=None, + headers_map=None, api_client=None, callable=None): """Creates an endpoint Args: @@ -670,50 +658,55 @@ def __init__(self, settings=None, params_map=None, root_map=None, headers_map=No """ self.settings = settings self.params_map = params_map - self.params_map["all"].extend( - [ - "async_req", - "_host_index", - "_preload_content", - "_request_timeout", - "_return_http_data_only", - "_check_input_type", - "_check_return_type", - ] - ) - self.params_map["nullable"].extend(["_request_timeout"]) - self.validations = root_map["validations"] - self.allowed_values = root_map["allowed_values"] - self.openapi_types = root_map["openapi_types"] + self.params_map['all'].extend([ + 'async_req', + '_host_index', + '_preload_content', + '_request_timeout', + '_return_http_data_only', + '_check_input_type', + '_check_return_type' + ]) + self.params_map['nullable'].extend(['_request_timeout']) + self.validations = root_map['validations'] + self.allowed_values = root_map['allowed_values'] + self.openapi_types = root_map['openapi_types'] extra_types = { - "async_req": (bool,), - "_host_index": (none_type, int), - "_preload_content": (bool,), - "_request_timeout": (none_type, float, (float,), [float], int, (int,), [int]), - "_return_http_data_only": (bool,), - "_check_input_type": (bool,), - "_check_return_type": (bool,), + 'async_req': (bool,), + '_host_index': (none_type, int), + '_preload_content': (bool,), + '_request_timeout': (none_type, float, (float,), [float], int, (int,), [int]), + '_return_http_data_only': (bool,), + '_check_input_type': (bool,), + '_check_return_type': (bool,) } self.openapi_types.update(extra_types) - self.attribute_map = root_map["attribute_map"] - self.location_map = root_map["location_map"] - self.collection_format_map = root_map["collection_format_map"] + self.attribute_map = root_map['attribute_map'] + self.location_map = root_map['location_map'] + self.collection_format_map = root_map['collection_format_map'] self.headers_map = headers_map self.api_client = api_client self.callable = callable def __validate_inputs(self, kwargs): - for param in self.params_map["enum"]: + for param in self.params_map['enum']: if param in kwargs: - check_allowed_values(self.allowed_values, (param,), kwargs[param]) + check_allowed_values( + self.allowed_values, + (param,), + kwargs[param] + ) - for param in self.params_map["validation"]: + for param in self.params_map['validation']: if param in kwargs: check_validations( - self.validations, (param,), kwargs[param], configuration=self.api_client.configuration + self.validations, + (param,), + kwargs[param], + configuration=self.api_client.configuration ) - if kwargs["_check_input_type"] is False: + if kwargs['_check_input_type'] is False: return for key, value in kwargs.items(): @@ -722,41 +715,51 @@ def __validate_inputs(self, kwargs): self.openapi_types[key], [key], False, - kwargs["_check_input_type"], - configuration=self.api_client.configuration, + kwargs['_check_input_type'], + configuration=self.api_client.configuration ) kwargs[key] = fixed_val def __gather_params(self, kwargs): - params = {"body": None, "collection_format": {}, "file": {}, "form": [], "header": {}, "path": {}, "query": []} + params = { + 'body': None, + 'collection_format': {}, + 'file': {}, + 'form': [], + 'header': {}, + 'path': {}, + 'query': [] + } for param_name, param_value in kwargs.items(): param_location = self.location_map.get(param_name) if param_location is None: continue if param_location: - if param_location == "body": - params["body"] = param_value + if param_location == 'body': + params['body'] = param_value continue base_name = self.attribute_map[param_name] - if param_location == "form" and self.openapi_types[param_name] == (file_type,): - params["file"][param_name] = [param_value] - elif param_location == "form" and self.openapi_types[param_name] == ([file_type],): + if (param_location == 'form' and + self.openapi_types[param_name] == (file_type,)): + params['file'][param_name] = [param_value] + elif (param_location == 'form' and + self.openapi_types[param_name] == ([file_type],)): # param_value is already a list - params["file"][param_name] = param_value - elif param_location in {"form", "query"}: + params['file'][param_name] = param_value + elif param_location in {'form', 'query'}: param_value_full = (base_name, param_value) params[param_location].append(param_value_full) - if param_location not in {"form", "query"}: + if param_location not in {'form', 'query'}: params[param_location][base_name] = param_value collection_format = self.collection_format_map.get(param_name) if collection_format: - params["collection_format"][base_name] = collection_format + params['collection_format'][base_name] = collection_format return params def __call__(self, *args, **kwargs): - """This method is invoked when endpoints are called + """ This method is invoked when endpoints are called Example: api_instance = IndexOperationsApi() @@ -769,74 +772,79 @@ def __call__(self, *args, **kwargs): return self.callable(self, *args, **kwargs) def call_with_http_info(self, **kwargs): + try: - index = ( - self.api_client.configuration.server_operation_index.get( - self.settings["operation_id"], self.api_client.configuration.server_index - ) - if kwargs["_host_index"] is None - else kwargs["_host_index"] - ) + index = self.api_client.configuration.server_operation_index.get( + self.settings['operation_id'], self.api_client.configuration.server_index + ) if kwargs['_host_index'] is None else kwargs['_host_index'] server_variables = self.api_client.configuration.server_operation_variables.get( - self.settings["operation_id"], self.api_client.configuration.server_variables + self.settings['operation_id'], self.api_client.configuration.server_variables ) _host = self.api_client.configuration.get_host_from_settings( - index, variables=server_variables, servers=self.settings["servers"] + index, variables=server_variables, servers=self.settings['servers'] ) except IndexError: - if self.settings["servers"]: - raise ApiValueError("Invalid host index. Must be 0 <= index < %s" % len(self.settings["servers"])) + if self.settings['servers']: + raise ApiValueError( + "Invalid host index. Must be 0 <= index < %s" % + len(self.settings['servers']) + ) _host = None for key, value in kwargs.items(): - if key not in self.params_map["all"]: + if key not in self.params_map['all']: raise ApiTypeError( - "Got an unexpected parameter '%s'" " to method `%s`" % (key, self.settings["operation_id"]) + "Got an unexpected parameter '%s'" + " to method `%s`" % + (key, self.settings['operation_id']) ) # only throw this nullable ApiValueError if _check_input_type # is False, if _check_input_type==True we catch this case # in self.__validate_inputs - if key not in self.params_map["nullable"] and value is None and kwargs["_check_input_type"] is False: + if (key not in self.params_map['nullable'] and value is None + and kwargs['_check_input_type'] is False): raise ApiValueError( "Value may not be None for non-nullable parameter `%s`" - " when calling `%s`" % (key, self.settings["operation_id"]) + " when calling `%s`" % + (key, self.settings['operation_id']) ) - for key in self.params_map["required"]: + for key in self.params_map['required']: if key not in kwargs.keys(): raise ApiValueError( - "Missing the required parameter `%s` when calling " "`%s`" % (key, self.settings["operation_id"]) + "Missing the required parameter `%s` when calling " + "`%s`" % (key, self.settings['operation_id']) ) self.__validate_inputs(kwargs) params = self.__gather_params(kwargs) - accept_headers_list = self.headers_map["accept"] + accept_headers_list = self.headers_map['accept'] if accept_headers_list: - params["header"]["Accept"] = self.api_client.select_header_accept(accept_headers_list) + params['header']['Accept'] = self.api_client.select_header_accept( + accept_headers_list) - content_type_headers_list = self.headers_map["content_type"] + content_type_headers_list = self.headers_map['content_type'] if content_type_headers_list: - header_list = self.api_client.select_header_content_type(content_type_headers_list) - params["header"]["Content-Type"] = header_list + header_list = self.api_client.select_header_content_type( + content_type_headers_list) + params['header']['Content-Type'] = header_list return self.api_client.call_api( - self.settings["endpoint_path"], - self.settings["http_method"], - params["path"], - params["query"], - params["header"], - body=params["body"], - post_params=params["form"], - files=params["file"], - response_type=self.settings["response_type"], - auth_settings=self.settings["auth"], - async_req=kwargs["async_req"], - _check_type=kwargs["_check_return_type"], - _return_http_data_only=kwargs["_return_http_data_only"], - _preload_content=kwargs["_preload_content"], - _request_timeout=kwargs["_request_timeout"], + self.settings['endpoint_path'], self.settings['http_method'], + params['path'], + params['query'], + params['header'], + body=params['body'], + post_params=params['form'], + files=params['file'], + response_type=self.settings['response_type'], + auth_settings=self.settings['auth'], + async_req=kwargs['async_req'], + _check_type=kwargs['_check_return_type'], + _return_http_data_only=kwargs['_return_http_data_only'], + _preload_content=kwargs['_preload_content'], + _request_timeout=kwargs['_request_timeout'], _host=_host, - collection_formats=params["collection_format"], - ) + collection_formats=params['collection_format']) diff --git a/pinecone/core/client/apis/__init__.py b/pinecone/core/client/apis/__init__.py index 88516b08b..ec42b1a85 100644 --- a/pinecone/core/client/apis/__init__.py +++ b/pinecone/core/client/apis/__init__.py @@ -1,3 +1,4 @@ + # flake8: noqa # Import all APIs into this package. diff --git a/pinecone/core/client/configuration.py b/pinecone/core/client/configuration.py index 2c6baf433..6e2d4949b 100644 --- a/pinecone/core/client/configuration.py +++ b/pinecone/core/client/configuration.py @@ -20,112 +20,99 @@ JSON_SCHEMA_VALIDATION_KEYWORDS = { - "multipleOf", - "maximum", - "exclusiveMaximum", - "minimum", - "exclusiveMinimum", - "maxLength", - "minLength", - "pattern", - "maxItems", - "minItems", + 'multipleOf', 'maximum', 'exclusiveMaximum', + 'minimum', 'exclusiveMinimum', 'maxLength', + 'minLength', 'pattern', 'maxItems', 'minItems' } - class Configuration(object): """NOTE: This class is auto generated by OpenAPI Generator - Ref: https://openapi-generator.tech - Do not edit the class manually. - - :param host: Base url - :param api_key: Dict to store API key(s). - Each entry in the dict specifies an API key. - The dict key is the name of the security scheme in the OAS specification. - The dict value is the API key secret. - :param api_key_prefix: Dict to store API prefix (e.g. Bearer) - The dict key is the name of the security scheme in the OAS specification. - The dict value is an API key prefix when generating the auth data. - :param username: Username for HTTP basic authentication - :param password: Password for HTTP basic authentication - :param discard_unknown_keys: Boolean value indicating whether to discard - unknown properties. A server may send a response that includes additional - properties that are not known by the client in the following scenarios: - 1. The OpenAPI document is incomplete, i.e. it does not match the server - implementation. - 2. The client was generated using an older version of the OpenAPI document - and the server has been upgraded since then. - If a schema in the OpenAPI document defines the additionalProperties attribute, - then all undeclared properties received by the server are injected into the - additional properties map. In that case, there are undeclared properties, and - nothing to discard. - :param disabled_client_side_validations (string): Comma-separated list of - JSON schema validation keywords to disable JSON schema structural validation - rules. The following keywords may be specified: multipleOf, maximum, - exclusiveMaximum, minimum, exclusiveMinimum, maxLength, minLength, pattern, - maxItems, minItems. - By default, the validation is performed for data generated locally by the client - and data received from the server, independent of any validation performed by - the server side. If the input data does not satisfy the JSON schema validation - rules specified in the OpenAPI document, an exception is raised. - If disabled_client_side_validations is set, structural validation is - disabled. This can be useful to troubleshoot data validation problem, such as - when the OpenAPI document validation rules do not match the actual API data - received by the server. - :param server_index: Index to servers configuration. - :param server_variables: Mapping with string values to replace variables in - templated server configuration. The validation of enums is performed for - variables with defined enum values before. - :param server_operation_index: Mapping from operation ID to an index to server - configuration. - :param server_operation_variables: Mapping from operation ID to a mapping with - string values to replace variables in templated server configuration. - The validation of enums is performed for variables with defined enum values before. - :param ssl_ca_cert: str - the path to a file of concatenated CA certificates - in PEM format - - :Example: - - API Key Authentication Example. - Given the following security scheme in the OpenAPI specification: - components: - securitySchemes: - cookieAuth: # name for the security scheme - type: apiKey - in: cookie - name: JSESSIONID # cookie name - - You can programmatically set the cookie: - - conf = pinecone.core.client.Configuration( - api_key={'cookieAuth': 'abc123'} - api_key_prefix={'cookieAuth': 'JSESSIONID'} - ) - - The following cookie will be added to the HTTP request: - Cookie: JSESSIONID abc123 + Ref: https://openapi-generator.tech + Do not edit the class manually. + + :param host: Base url + :param api_key: Dict to store API key(s). + Each entry in the dict specifies an API key. + The dict key is the name of the security scheme in the OAS specification. + The dict value is the API key secret. + :param api_key_prefix: Dict to store API prefix (e.g. Bearer) + The dict key is the name of the security scheme in the OAS specification. + The dict value is an API key prefix when generating the auth data. + :param username: Username for HTTP basic authentication + :param password: Password for HTTP basic authentication + :param discard_unknown_keys: Boolean value indicating whether to discard + unknown properties. A server may send a response that includes additional + properties that are not known by the client in the following scenarios: + 1. The OpenAPI document is incomplete, i.e. it does not match the server + implementation. + 2. The client was generated using an older version of the OpenAPI document + and the server has been upgraded since then. + If a schema in the OpenAPI document defines the additionalProperties attribute, + then all undeclared properties received by the server are injected into the + additional properties map. In that case, there are undeclared properties, and + nothing to discard. + :param disabled_client_side_validations (string): Comma-separated list of + JSON schema validation keywords to disable JSON schema structural validation + rules. The following keywords may be specified: multipleOf, maximum, + exclusiveMaximum, minimum, exclusiveMinimum, maxLength, minLength, pattern, + maxItems, minItems. + By default, the validation is performed for data generated locally by the client + and data received from the server, independent of any validation performed by + the server side. If the input data does not satisfy the JSON schema validation + rules specified in the OpenAPI document, an exception is raised. + If disabled_client_side_validations is set, structural validation is + disabled. This can be useful to troubleshoot data validation problem, such as + when the OpenAPI document validation rules do not match the actual API data + received by the server. + :param server_index: Index to servers configuration. + :param server_variables: Mapping with string values to replace variables in + templated server configuration. The validation of enums is performed for + variables with defined enum values before. + :param server_operation_index: Mapping from operation ID to an index to server + configuration. + :param server_operation_variables: Mapping from operation ID to a mapping with + string values to replace variables in templated server configuration. + The validation of enums is performed for variables with defined enum values before. + :param ssl_ca_cert: str - the path to a file of concatenated CA certificates + in PEM format + + :Example: + + API Key Authentication Example. + Given the following security scheme in the OpenAPI specification: + components: + securitySchemes: + cookieAuth: # name for the security scheme + type: apiKey + in: cookie + name: JSESSIONID # cookie name + + You can programmatically set the cookie: + +conf = pinecone.core.client.Configuration( + api_key={'cookieAuth': 'abc123'} + api_key_prefix={'cookieAuth': 'JSESSIONID'} +) + + The following cookie will be added to the HTTP request: + Cookie: JSESSIONID abc123 """ _default = None - def __init__( - self, - host=None, - api_key=None, - api_key_prefix=None, - access_token=None, - username=None, - password=None, - discard_unknown_keys=False, - disabled_client_side_validations="", - server_index=None, - server_variables=None, - server_operation_index=None, - server_operation_variables=None, - ssl_ca_cert=None, - ): - """Constructor""" + def __init__(self, host=None, + api_key=None, api_key_prefix=None, + access_token=None, + username=None, password=None, + discard_unknown_keys=False, + disabled_client_side_validations="", + server_index=None, server_variables=None, + server_operation_index=None, server_operation_variables=None, + ssl_ca_cert=None, + ): + """Constructor + """ self._base_path = "https://unknown-unknown.svc.unknown.pinecone.io" if host is None else host """Default Base url """ @@ -168,7 +155,7 @@ def __init__( """ self.logger["package_logger"] = logging.getLogger("pinecone.core.client") self.logger["urllib3_logger"] = logging.getLogger("urllib3") - self.logger_format = "%(asctime)s %(levelname)s %(message)s" + self.logger_format = '%(asctime)s %(levelname)s %(message)s' """Log format """ self.logger_stream_handler = None @@ -216,7 +203,7 @@ def __init__( self.proxy_headers = None """Proxy headers """ - self.safe_chars_for_path_param = "" + self.safe_chars_for_path_param = '' """Safe chars for path_param """ self.retries = None @@ -233,7 +220,7 @@ def __deepcopy__(self, memo): result = cls.__new__(cls) memo[id(self)] = result for k, v in self.__dict__.items(): - if k not in ("logger", "logger_file_handler"): + if k not in ('logger', 'logger_file_handler'): setattr(result, k, copy.deepcopy(v, memo)) # shallow copy of loggers result.logger = copy.copy(self.logger) @@ -244,11 +231,12 @@ def __deepcopy__(self, memo): def __setattr__(self, name, value): object.__setattr__(self, name, value) - if name == "disabled_client_side_validations": - s = set(filter(None, value.split(","))) + if name == 'disabled_client_side_validations': + s = set(filter(None, value.split(','))) for v in s: if v not in JSON_SCHEMA_VALIDATION_KEYWORDS: - raise ApiValueError("Invalid keyword: '{0}''".format(v)) + raise ApiValueError( + "Invalid keyword: '{0}''".format(v)) self._disabled_client_side_validations = s @classmethod @@ -389,7 +377,9 @@ def get_basic_auth_token(self): password = "" if self.password is not None: password = self.password - return urllib3.util.make_headers(basic_auth=username + ":" + password).get("authorization") + return urllib3.util.make_headers( + basic_auth=username + ':' + password + ).get('authorization') def auth_settings(self): """Gets Auth Settings dict for api client. @@ -397,13 +387,13 @@ def auth_settings(self): :return: The Auth Settings information dict. """ auth = {} - if "ApiKeyAuth" in self.api_key: - auth["ApiKeyAuth"] = { - "type": "api_key", - "in": "header", - "key": "Api-Key", - "value": self.get_api_key_with_prefix( - "ApiKeyAuth", + if 'ApiKeyAuth' in self.api_key: + auth['ApiKeyAuth'] = { + 'type': 'api_key', + 'in': 'header', + 'key': 'Api-Key', + 'value': self.get_api_key_with_prefix( + 'ApiKeyAuth', ), } return auth @@ -413,13 +403,12 @@ def to_debug_report(self): :return: The report for debugging. """ - return ( - "Python SDK Debug Report:\n" - "OS: {env}\n" - "Python Version: {pyversion}\n" - "Version of the API: version not set\n" - "SDK Package Version: 1.0.0".format(env=sys.platform, pyversion=sys.version) - ) + return "Python SDK Debug Report:\n"\ + "OS: {env}\n"\ + "Python Version: {pyversion}\n"\ + "Version of the API: version not set\n"\ + "SDK Package Version: 1.0.0".\ + format(env=sys.platform, pyversion=sys.version) def get_host_settings(self): """Gets an array of host settings @@ -428,22 +417,22 @@ def get_host_settings(self): """ return [ { - "url": "https://{index_name}-{project_name}.svc.{environment}.pinecone.io", - "description": "No description provided", - "variables": { - "index_name": { - "description": "No description provided", - "default_value": "unknown", - }, - "project_name": { - "description": "No description provided", - "default_value": "unknown", - }, - "environment": { - "description": "No description provided", - "default_value": "unknown", - }, - }, + 'url': "https://{index_name}-{project_name}.svc.{environment}.pinecone.io", + 'description': "No description provided", + 'variables': { + 'index_name': { + 'description': "No description provided", + 'default_value': "unknown", + }, + 'project_name': { + 'description': "No description provided", + 'default_value': "unknown", + }, + 'environment': { + 'description': "No description provided", + 'default_value': "unknown", + } + } } ] @@ -465,20 +454,22 @@ def get_host_from_settings(self, index, variables=None, servers=None): except IndexError: raise ValueError( "Invalid index {0} when selecting the host settings. " - "Must be less than {1}".format(index, len(servers)) - ) + "Must be less than {1}".format(index, len(servers))) - url = server["url"] + url = server['url'] # go through variables and replace placeholders - for variable_name, variable in server.get("variables", {}).items(): - used_value = variables.get(variable_name, variable["default_value"]) + for variable_name, variable in server.get('variables', {}).items(): + used_value = variables.get( + variable_name, variable['default_value']) - if "enum_values" in variable and used_value not in variable["enum_values"]: + if 'enum_values' in variable \ + and used_value not in variable['enum_values']: raise ValueError( "The variable `{0}` in the host URL has invalid value " - "{1}. Must be {2}.".format(variable_name, variables[variable_name], variable["enum_values"]) - ) + "{1}. Must be {2}.".format( + variable_name, variables[variable_name], + variable['enum_values'])) url = url.replace("{" + variable_name + "}", used_value) diff --git a/pinecone/core/client/exceptions.py b/pinecone/core/client/exceptions.py index 5cb822bc4..dd777d024 100644 --- a/pinecone/core/client/exceptions.py +++ b/pinecone/core/client/exceptions.py @@ -9,16 +9,15 @@ """ -from pinecone.core.exceptions import PineconeException - -class OpenApiException(PineconeException): +class OpenApiException(Exception): """The base exception class for all OpenAPIExceptions""" class ApiTypeError(OpenApiException, TypeError): - def __init__(self, msg, path_to_item=None, valid_classes=None, key_type=None): - """Raises an exception for TypeErrors + def __init__(self, msg, path_to_item=None, valid_classes=None, + key_type=None): + """ Raises an exception for TypeErrors Args: msg (str): the exception message @@ -99,6 +98,7 @@ def __init__(self, msg, path_to_item=None): class ApiException(OpenApiException): + def __init__(self, status=None, reason=None, http_resp=None): if http_resp: self.status = http_resp.status @@ -113,9 +113,11 @@ def __init__(self, status=None, reason=None, http_resp=None): def __str__(self): """Custom error messages for exception""" - error_message = "({0})\n" "Reason: {1}\n".format(self.status, self.reason) + error_message = "({0})\n"\ + "Reason: {1}\n".format(self.status, self.reason) if self.headers: - error_message += "HTTP response headers: {0}\n".format(self.headers) + error_message += "HTTP response headers: {0}\n".format( + self.headers) if self.body: error_message += "HTTP response body: {0}\n".format(self.body) @@ -124,21 +126,25 @@ def __str__(self): class NotFoundException(ApiException): + def __init__(self, status=None, reason=None, http_resp=None): super(NotFoundException, self).__init__(status, reason, http_resp) class UnauthorizedException(ApiException): + def __init__(self, status=None, reason=None, http_resp=None): super(UnauthorizedException, self).__init__(status, reason, http_resp) class ForbiddenException(ApiException): + def __init__(self, status=None, reason=None, http_resp=None): super(ForbiddenException, self).__init__(status, reason, http_resp) class ServiceException(ApiException): + def __init__(self, status=None, reason=None, http_resp=None): super(ServiceException, self).__init__(status, reason, http_resp) diff --git a/pinecone/core/client/model/approximated_config.py b/pinecone/core/client/model/approximated_config.py index 4c237d89e..9e881a945 100644 --- a/pinecone/core/client/model/approximated_config.py +++ b/pinecone/core/client/model/approximated_config.py @@ -30,6 +30,7 @@ from pinecone.core.client.exceptions import ApiAttributeError + class ApproximatedConfig(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -54,9 +55,11 @@ class ApproximatedConfig(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + } - validations = {} + validations = { + } @cached_property def additional_properties_type(): @@ -64,17 +67,7 @@ def additional_properties_type(): This must be a method because a model may have properties that are of type self, this must run after the class is loaded """ - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -89,20 +82,22 @@ def openapi_types(): and the value is attribute type. """ return { - "k_bits": (int,), # noqa: E501 - "hybrid": (bool,), # noqa: E501 + 'k_bits': (int,), # noqa: E501 + 'hybrid': (bool,), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "k_bits": "k_bits", # noqa: E501 - "hybrid": "hybrid", # noqa: E501 + 'k_bits': 'k_bits', # noqa: E501 + 'hybrid': 'hybrid', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -146,18 +141,17 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 hybrid (bool): [optional] if omitted the server will use the default value of False # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -173,27 +167,23 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, *args, **kwargs): # noqa: E501 @@ -234,16 +224,15 @@ def __init__(self, *args, **kwargs): # noqa: E501 hybrid (bool): [optional] if omitted the server will use the default value of False # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -259,17 +248,13 @@ def __init__(self, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/collection_meta.py b/pinecone/core/client/model/collection_meta.py index de2f5b6b8..cc3bfa5f1 100644 --- a/pinecone/core/client/model/collection_meta.py +++ b/pinecone/core/client/model/collection_meta.py @@ -30,6 +30,7 @@ from pinecone.core.client.exceptions import ApiAttributeError + class CollectionMeta(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -54,9 +55,11 @@ class CollectionMeta(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + } - validations = {} + validations = { + } @cached_property def additional_properties_type(): @@ -64,17 +67,7 @@ def additional_properties_type(): This must be a method because a model may have properties that are of type self, this must run after the class is loaded """ - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -89,22 +82,28 @@ def openapi_types(): and the value is attribute type. """ return { - "name": (str,), # noqa: E501 - "size": (int,), # noqa: E501 - "status": (str,), # noqa: E501 + 'name': (str,), # noqa: E501 + 'size': (int,), # noqa: E501 + 'status': (str,), # noqa: E501 + 'dimension': (int,), # noqa: E501 + 'vector_count': (int,), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "name": "name", # noqa: E501 - "size": "size", # noqa: E501 - "status": "status", # noqa: E501 + 'name': 'name', # noqa: E501 + 'size': 'size', # noqa: E501 + 'status': 'status', # noqa: E501 + 'dimension': 'dimension', # noqa: E501 + 'vector_count': 'vector_count', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -147,20 +146,21 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 name (str): [optional] # noqa: E501 size (int): The size of the collection in bytes.. [optional] # noqa: E501 status (str): The status of the collection.. [optional] # noqa: E501 + dimension (int): [optional] # noqa: E501 + vector_count (int): [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -176,27 +176,23 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, *args, **kwargs): # noqa: E501 @@ -236,18 +232,19 @@ def __init__(self, *args, **kwargs): # noqa: E501 name (str): [optional] # noqa: E501 size (int): The size of the collection in bytes.. [optional] # noqa: E501 status (str): The status of the collection.. [optional] # noqa: E501 + dimension (int): [optional] # noqa: E501 + vector_count (int): [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -263,17 +260,13 @@ def __init__(self, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/create_collection_request.py b/pinecone/core/client/model/create_collection_request.py index 47379c0ea..ac5474413 100644 --- a/pinecone/core/client/model/create_collection_request.py +++ b/pinecone/core/client/model/create_collection_request.py @@ -30,6 +30,7 @@ from pinecone.core.client.exceptions import ApiAttributeError + class CreateCollectionRequest(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -54,9 +55,11 @@ class CreateCollectionRequest(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + } - validations = {} + validations = { + } @cached_property def additional_properties_type(): @@ -64,17 +67,7 @@ def additional_properties_type(): This must be a method because a model may have properties that are of type self, this must run after the class is loaded """ - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -89,20 +82,22 @@ def openapi_types(): and the value is attribute type. """ return { - "name": (str,), # noqa: E501 - "source": (str,), # noqa: E501 + 'name': (str,), # noqa: E501 + 'source': (str,), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "name": "name", # noqa: E501 - "source": "source", # noqa: E501 + 'name': 'name', # noqa: E501 + 'source': 'source', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -148,18 +143,17 @@ def _from_openapi_data(cls, name, source, *args, **kwargs): # noqa: E501 _visited_composed_classes = (Animal,) """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -177,27 +171,23 @@ def _from_openapi_data(cls, name, source, *args, **kwargs): # noqa: E501 self.name = name self.source = source for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, name, source, *args, **kwargs): # noqa: E501 @@ -240,16 +230,15 @@ def __init__(self, name, source, *args, **kwargs): # noqa: E501 _visited_composed_classes = (Animal,) """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -267,17 +256,13 @@ def __init__(self, name, source, *args, **kwargs): # noqa: E501 self.name = name self.source = source for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/create_request.py b/pinecone/core/client/model/create_request.py index 1aa615c0e..0dbb9f900 100644 --- a/pinecone/core/client/model/create_request.py +++ b/pinecone/core/client/model/create_request.py @@ -30,6 +30,7 @@ from pinecone.core.client.exceptions import ApiAttributeError + class CreateRequest(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -54,9 +55,11 @@ class CreateRequest(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + } - validations = {} + validations = { + } @cached_property def additional_properties_type(): @@ -64,17 +67,7 @@ def additional_properties_type(): This must be a method because a model may have properties that are of type self, this must run after the class is loaded """ - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -89,41 +82,40 @@ def openapi_types(): and the value is attribute type. """ return { - "name": (str,), # noqa: E501 - "dimension": (int,), # noqa: E501 - "index_type": (str,), # noqa: E501 - "metric": (str,), # noqa: E501 - "pods": (int,), # noqa: E501 - "replicas": (int,), # noqa: E501 - "shards": (int,), # noqa: E501 - "pod_type": (str,), # noqa: E501 - "index_config": (dict,), # noqa: E501 - "metadata_config": ( - {str: (bool, date, datetime, dict, float, int, list, str, none_type)}, - none_type, - ), # noqa: E501 - "source_collection": (str,), # noqa: E501 + 'name': (str,), # noqa: E501 + 'dimension': (int,), # noqa: E501 + 'index_type': (str,), # noqa: E501 + 'metric': (str,), # noqa: E501 + 'pods': (int,), # noqa: E501 + 'replicas': (int,), # noqa: E501 + 'shards': (int,), # noqa: E501 + 'pod_type': (str,), # noqa: E501 + 'index_config': (dict,), # noqa: E501 + 'metadata_config': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}, none_type,), # noqa: E501 + 'source_collection': (str,), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "name": "name", # noqa: E501 - "dimension": "dimension", # noqa: E501 - "index_type": "index_type", # noqa: E501 - "metric": "metric", # noqa: E501 - "pods": "pods", # noqa: E501 - "replicas": "replicas", # noqa: E501 - "shards": "shards", # noqa: E501 - "pod_type": "pod_type", # noqa: E501 - "index_config": "index_config", # noqa: E501 - "metadata_config": "metadata_config", # noqa: E501 - "source_collection": "source_collection", # noqa: E501 + 'name': 'name', # noqa: E501 + 'dimension': 'dimension', # noqa: E501 + 'index_type': 'index_type', # noqa: E501 + 'metric': 'metric', # noqa: E501 + 'pods': 'pods', # noqa: E501 + 'replicas': 'replicas', # noqa: E501 + 'shards': 'shards', # noqa: E501 + 'pod_type': 'pod_type', # noqa: E501 + 'index_config': 'index_config', # noqa: E501 + 'metadata_config': 'metadata_config', # noqa: E501 + 'source_collection': 'source_collection', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -178,18 +170,17 @@ def _from_openapi_data(cls, name, dimension, *args, **kwargs): # noqa: E501 source_collection (str): The name of the collection to create an index from. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -207,27 +198,23 @@ def _from_openapi_data(cls, name, dimension, *args, **kwargs): # noqa: E501 self.name = name self.dimension = dimension for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, name, dimension, *args, **kwargs): # noqa: E501 @@ -279,16 +266,15 @@ def __init__(self, name, dimension, *args, **kwargs): # noqa: E501 source_collection (str): The name of the collection to create an index from. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -306,17 +292,13 @@ def __init__(self, name, dimension, *args, **kwargs): # noqa: E501 self.name = name self.dimension = dimension for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/delete_request.py b/pinecone/core/client/model/delete_request.py index d60289048..446466d57 100644 --- a/pinecone/core/client/model/delete_request.py +++ b/pinecone/core/client/model/delete_request.py @@ -30,6 +30,7 @@ from pinecone.core.client.exceptions import ApiAttributeError + class DeleteRequest(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -54,10 +55,12 @@ class DeleteRequest(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + } validations = { - ("ids",): {}, + ('ids',): { + }, } @cached_property @@ -66,17 +69,7 @@ def additional_properties_type(): This must be a method because a model may have properties that are of type self, this must run after the class is loaded """ - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -91,24 +84,26 @@ def openapi_types(): and the value is attribute type. """ return { - "ids": ([str],), # noqa: E501 - "delete_all": (bool,), # noqa: E501 - "namespace": (str,), # noqa: E501 - "filter": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 + 'ids': ([str],), # noqa: E501 + 'delete_all': (bool,), # noqa: E501 + 'namespace': (str,), # noqa: E501 + 'filter': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "ids": "ids", # noqa: E501 - "delete_all": "deleteAll", # noqa: E501 - "namespace": "namespace", # noqa: E501 - "filter": "filter", # noqa: E501 + 'ids': 'ids', # noqa: E501 + 'delete_all': 'deleteAll', # noqa: E501 + 'namespace': 'namespace', # noqa: E501 + 'filter': 'filter', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -154,18 +149,17 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 filter ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): If specified, the metadata filter here will be used to select the vectors to delete. This is mutually exclusive with specifying ids to delete in the ids param or using delete_all=True. See https://www.pinecone.io/docs/metadata-filtering/.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -181,27 +175,23 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, *args, **kwargs): # noqa: E501 @@ -244,16 +234,15 @@ def __init__(self, *args, **kwargs): # noqa: E501 filter ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): If specified, the metadata filter here will be used to select the vectors to delete. This is mutually exclusive with specifying ids to delete in the ids param or using delete_all=True. See https://www.pinecone.io/docs/metadata-filtering/.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -269,17 +258,13 @@ def __init__(self, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/describe_index_stats_request.py b/pinecone/core/client/model/describe_index_stats_request.py index 05c73506a..da0eb0b24 100644 --- a/pinecone/core/client/model/describe_index_stats_request.py +++ b/pinecone/core/client/model/describe_index_stats_request.py @@ -30,6 +30,7 @@ from pinecone.core.client.exceptions import ApiAttributeError + class DescribeIndexStatsRequest(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -54,9 +55,11 @@ class DescribeIndexStatsRequest(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + } - validations = {} + validations = { + } @cached_property def additional_properties_type(): @@ -64,17 +67,7 @@ def additional_properties_type(): This must be a method because a model may have properties that are of type self, this must run after the class is loaded """ - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -89,18 +82,20 @@ def openapi_types(): and the value is attribute type. """ return { - "filter": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 + 'filter': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "filter": "filter", # noqa: E501 + 'filter': 'filter', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -143,18 +138,17 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 filter ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): If this parameter is present, the operation only returns statistics for vectors that satisfy the filter. See https://www.pinecone.io/docs/metadata-filtering/.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -170,27 +164,23 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, *args, **kwargs): # noqa: E501 @@ -230,16 +220,15 @@ def __init__(self, *args, **kwargs): # noqa: E501 filter ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): If this parameter is present, the operation only returns statistics for vectors that satisfy the filter. See https://www.pinecone.io/docs/metadata-filtering/.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -255,17 +244,13 @@ def __init__(self, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/describe_index_stats_response.py b/pinecone/core/client/model/describe_index_stats_response.py index 6e965ed90..9dc9c4056 100644 --- a/pinecone/core/client/model/describe_index_stats_response.py +++ b/pinecone/core/client/model/describe_index_stats_response.py @@ -32,8 +32,7 @@ def lazy_import(): from pinecone.core.client.model.namespace_summary import NamespaceSummary - - globals()["NamespaceSummary"] = NamespaceSummary + globals()['NamespaceSummary'] = NamespaceSummary class DescribeIndexStatsResponse(ModelNormal): @@ -60,9 +59,11 @@ class DescribeIndexStatsResponse(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + } - validations = {} + validations = { + } @cached_property def additional_properties_type(): @@ -71,17 +72,7 @@ def additional_properties_type(): of type self, this must run after the class is loaded """ lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -97,24 +88,26 @@ def openapi_types(): """ lazy_import() return { - "namespaces": ({str: (NamespaceSummary,)},), # noqa: E501 - "dimension": (int,), # noqa: E501 - "index_fullness": (float,), # noqa: E501 - "total_vector_count": (int,), # noqa: E501 + 'namespaces': ({str: (NamespaceSummary,)},), # noqa: E501 + 'dimension': (int,), # noqa: E501 + 'index_fullness': (float,), # noqa: E501 + 'total_vector_count': (int,), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "namespaces": "namespaces", # noqa: E501 - "dimension": "dimension", # noqa: E501 - "index_fullness": "indexFullness", # noqa: E501 - "total_vector_count": "totalVectorCount", # noqa: E501 + 'namespaces': 'namespaces', # noqa: E501 + 'dimension': 'dimension', # noqa: E501 + 'index_fullness': 'indexFullness', # noqa: E501 + 'total_vector_count': 'totalVectorCount', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -160,18 +153,17 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 total_vector_count (int): [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -187,27 +179,23 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, *args, **kwargs): # noqa: E501 @@ -250,16 +238,15 @@ def __init__(self, *args, **kwargs): # noqa: E501 total_vector_count (int): [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -275,17 +262,13 @@ def __init__(self, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/fetch_response.py b/pinecone/core/client/model/fetch_response.py index 37ed4b17a..d355980fc 100644 --- a/pinecone/core/client/model/fetch_response.py +++ b/pinecone/core/client/model/fetch_response.py @@ -32,8 +32,7 @@ def lazy_import(): from pinecone.core.client.model.vector import Vector - - globals()["Vector"] = Vector + globals()['Vector'] = Vector class FetchResponse(ModelNormal): @@ -60,9 +59,11 @@ class FetchResponse(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + } - validations = {} + validations = { + } @cached_property def additional_properties_type(): @@ -71,17 +72,7 @@ def additional_properties_type(): of type self, this must run after the class is loaded """ lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -97,20 +88,22 @@ def openapi_types(): """ lazy_import() return { - "vectors": ({str: (Vector,)},), # noqa: E501 - "namespace": (str,), # noqa: E501 + 'vectors': ({str: (Vector,)},), # noqa: E501 + 'namespace': (str,), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "vectors": "vectors", # noqa: E501 - "namespace": "namespace", # noqa: E501 + 'vectors': 'vectors', # noqa: E501 + 'namespace': 'namespace', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -154,18 +147,17 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 namespace (str): The namespace of the vectors.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -181,27 +173,23 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, *args, **kwargs): # noqa: E501 @@ -242,16 +230,15 @@ def __init__(self, *args, **kwargs): # noqa: E501 namespace (str): The namespace of the vectors.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -267,17 +254,13 @@ def __init__(self, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/hnsw_config.py b/pinecone/core/client/model/hnsw_config.py index ecf41422d..d6a99a345 100644 --- a/pinecone/core/client/model/hnsw_config.py +++ b/pinecone/core/client/model/hnsw_config.py @@ -30,6 +30,7 @@ from pinecone.core.client.exceptions import ApiAttributeError + class HnswConfig(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -54,9 +55,11 @@ class HnswConfig(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + } - validations = {} + validations = { + } @cached_property def additional_properties_type(): @@ -64,17 +67,7 @@ def additional_properties_type(): This must be a method because a model may have properties that are of type self, this must run after the class is loaded """ - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -89,24 +82,26 @@ def openapi_types(): and the value is attribute type. """ return { - "ef_construction": (int,), # noqa: E501 - "ef": (int,), # noqa: E501 - "m": (int,), # noqa: E501 - "max_elements": (int,), # noqa: E501 + 'ef_construction': (int,), # noqa: E501 + 'ef': (int,), # noqa: E501 + 'm': (int,), # noqa: E501 + 'max_elements': (int,), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "ef_construction": "ef_construction", # noqa: E501 - "ef": "ef", # noqa: E501 - "m": "M", # noqa: E501 - "max_elements": "max_elements", # noqa: E501 + 'ef_construction': 'ef_construction', # noqa: E501 + 'ef': 'ef', # noqa: E501 + 'm': 'M', # noqa: E501 + 'max_elements': 'max_elements', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -152,18 +147,17 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 max_elements (int): [optional] if omitted the server will use the default value of 50000000 # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -179,27 +173,23 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, *args, **kwargs): # noqa: E501 @@ -242,16 +232,15 @@ def __init__(self, *args, **kwargs): # noqa: E501 max_elements (int): [optional] if omitted the server will use the default value of 50000000 # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -267,17 +256,13 @@ def __init__(self, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/index_meta.py b/pinecone/core/client/model/index_meta.py index e2e9bd948..5f17947dd 100644 --- a/pinecone/core/client/model/index_meta.py +++ b/pinecone/core/client/model/index_meta.py @@ -32,8 +32,9 @@ def lazy_import(): from pinecone.core.client.model.index_meta_database import IndexMetaDatabase - - globals()["IndexMetaDatabase"] = IndexMetaDatabase + from pinecone.core.client.model.index_meta_status import IndexMetaStatus + globals()['IndexMetaDatabase'] = IndexMetaDatabase + globals()['IndexMetaStatus'] = IndexMetaStatus class IndexMeta(ModelNormal): @@ -60,9 +61,11 @@ class IndexMeta(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + } - validations = {} + validations = { + } @cached_property def additional_properties_type(): @@ -71,17 +74,7 @@ def additional_properties_type(): of type self, this must run after the class is loaded """ lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -97,18 +90,22 @@ def openapi_types(): """ lazy_import() return { - "database": (IndexMetaDatabase,), # noqa: E501 + 'database': (IndexMetaDatabase,), # noqa: E501 + 'status': (IndexMetaStatus,), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "database": "database", # noqa: E501 + 'database': 'database', # noqa: E501 + 'status': 'status', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -149,20 +146,20 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 through its discriminator because we passed in _visited_composed_classes = (Animal,) database (IndexMetaDatabase): [optional] # noqa: E501 + status (IndexMetaStatus): [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -178,27 +175,23 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, *args, **kwargs): # noqa: E501 @@ -236,18 +229,18 @@ def __init__(self, *args, **kwargs): # noqa: E501 through its discriminator because we passed in _visited_composed_classes = (Animal,) database (IndexMetaDatabase): [optional] # noqa: E501 + status (IndexMetaStatus): [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -263,17 +256,13 @@ def __init__(self, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/index_meta_database.py b/pinecone/core/client/model/index_meta_database.py index a969abd82..d93ddf057 100644 --- a/pinecone/core/client/model/index_meta_database.py +++ b/pinecone/core/client/model/index_meta_database.py @@ -30,11 +30,6 @@ from pinecone.core.client.exceptions import ApiAttributeError -def lazy_import(): - from pinecone.core.client.model.index_meta_database_status import IndexMetaDatabaseStatus - - globals()["IndexMetaDatabaseStatus"] = IndexMetaDatabaseStatus - class IndexMetaDatabase(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. @@ -60,9 +55,11 @@ class IndexMetaDatabase(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + } - validations = {} + validations = { + } @cached_property def additional_properties_type(): @@ -70,18 +67,7 @@ def additional_properties_type(): This must be a method because a model may have properties that are of type self, this must run after the class is loaded """ - lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -95,40 +81,39 @@ def openapi_types(): openapi_types (dict): The key is attribute name and the value is attribute type. """ - lazy_import() return { - "name": (str,), # noqa: E501 - "dimensions": (str,), # noqa: E501 - "index_type": (str,), # noqa: E501 - "metric": (str,), # noqa: E501 - "pods": (int,), # noqa: E501 - "replicas": (int,), # noqa: E501 - "shards": (int,), # noqa: E501 - "pod_type": (str,), # noqa: E501 - "index_config": (dict,), # noqa: E501 - "metadata_config": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 - "status": (IndexMetaDatabaseStatus,), # noqa: E501 + 'name': (str,), # noqa: E501 + 'dimension': (str,), # noqa: E501 + 'index_type': (str,), # noqa: E501 + 'metric': (str,), # noqa: E501 + 'pods': (int,), # noqa: E501 + 'replicas': (int,), # noqa: E501 + 'shards': (int,), # noqa: E501 + 'pod_type': (str,), # noqa: E501 + 'index_config': (dict,), # noqa: E501 + 'metadata_config': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "name": "name", # noqa: E501 - "dimensions": "dimensions", # noqa: E501 - "index_type": "index_type", # noqa: E501 - "metric": "metric", # noqa: E501 - "pods": "pods", # noqa: E501 - "replicas": "replicas", # noqa: E501 - "shards": "shards", # noqa: E501 - "pod_type": "pod_type", # noqa: E501 - "index_config": "index_config", # noqa: E501 - "metadata_config": "metadata_config", # noqa: E501 - "status": "status", # noqa: E501 + 'name': 'name', # noqa: E501 + 'dimension': 'dimension', # noqa: E501 + 'index_type': 'index_type', # noqa: E501 + 'metric': 'metric', # noqa: E501 + 'pods': 'pods', # noqa: E501 + 'replicas': 'replicas', # noqa: E501 + 'shards': 'shards', # noqa: E501 + 'pod_type': 'pod_type', # noqa: E501 + 'index_config': 'index_config', # noqa: E501 + 'metadata_config': 'metadata_config', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -169,7 +154,7 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 through its discriminator because we passed in _visited_composed_classes = (Animal,) name (str): [optional] # noqa: E501 - dimensions (str): [optional] # noqa: E501 + dimension (str): [optional] # noqa: E501 index_type (str): [optional] # noqa: E501 metric (str): [optional] # noqa: E501 pods (int): [optional] # noqa: E501 @@ -178,21 +163,19 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 pod_type (str): [optional] # noqa: E501 index_config (dict): [optional] # noqa: E501 metadata_config ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): [optional] # noqa: E501 - status (IndexMetaDatabaseStatus): [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -208,27 +191,23 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, *args, **kwargs): # noqa: E501 @@ -266,7 +245,7 @@ def __init__(self, *args, **kwargs): # noqa: E501 through its discriminator because we passed in _visited_composed_classes = (Animal,) name (str): [optional] # noqa: E501 - dimensions (str): [optional] # noqa: E501 + dimension (str): [optional] # noqa: E501 index_type (str): [optional] # noqa: E501 metric (str): [optional] # noqa: E501 pods (int): [optional] # noqa: E501 @@ -275,19 +254,17 @@ def __init__(self, *args, **kwargs): # noqa: E501 pod_type (str): [optional] # noqa: E501 index_config (dict): [optional] # noqa: E501 metadata_config ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): [optional] # noqa: E501 - status (IndexMetaDatabaseStatus): [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -303,17 +280,13 @@ def __init__(self, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/index_meta_database_status.py b/pinecone/core/client/model/index_meta_database_status.py deleted file mode 100644 index 8430174fe..000000000 --- a/pinecone/core/client/model/index_meta_database_status.py +++ /dev/null @@ -1,283 +0,0 @@ -""" - Pinecone API - - 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: support@pinecone.io - Generated by: https://openapi-generator.tech -""" - - -import re # noqa: F401 -import sys # noqa: F401 - -from pinecone.core.client.model_utils import ( # noqa: F401 - ApiTypeError, - ModelComposed, - ModelNormal, - ModelSimple, - cached_property, - change_keys_js_to_python, - convert_js_args_to_python_args, - date, - datetime, - file_type, - none_type, - validate_get_composed_info, -) -from ..model_utils import OpenApiModel -from pinecone.core.client.exceptions import ApiAttributeError - - -class IndexMetaDatabaseStatus(ModelNormal): - """NOTE: This class is auto generated by OpenAPI Generator. - Ref: https://openapi-generator.tech - - Do not edit the class manually. - - Attributes: - allowed_values (dict): The key is the tuple path to the attribute - and the for var_name this is (var_name,). The value is a dict - with a capitalized key describing the allowed value and an allowed - value. These dicts store the allowed enum values. - attribute_map (dict): The key is attribute name - and the value is json key in definition. - discriminator_value_class_map (dict): A dict to go from the discriminator - variable value to the discriminator class name. - validations (dict): The key is the tuple path to the attribute - and the for var_name this is (var_name,). The value is a dict - that stores validations for max_length, min_length, max_items, - min_items, exclusive_maximum, inclusive_maximum, exclusive_minimum, - inclusive_minimum, and regex. - additional_properties_type (tuple): A tuple of classes accepted - as additional properties values. - """ - - allowed_values = { - ("state",): { - "INITIALIZING": "Initializing", - "SCALINGUP": "ScalingUp", - "SCALINGDOWN": "ScalingDown", - "TERMINATING": "Terminating", - "READY": "Ready", - }, - } - - validations = {} - - @cached_property - def additional_properties_type(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - """ - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 - - _nullable = False - - @cached_property - def openapi_types(): - """ - This must be a method because a model may have properties that are - of type self, this must run after the class is loaded - - Returns - openapi_types (dict): The key is attribute name - and the value is attribute type. - """ - return { - "ready": (bool,), # noqa: E501 - "state": (str,), # noqa: E501 - } - - @cached_property - def discriminator(): - return None - - attribute_map = { - "ready": "ready", # noqa: E501 - "state": "state", # noqa: E501 - } - - read_only_vars = {} - - _composed_schemas = {} - - @classmethod - @convert_js_args_to_python_args - def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 - """IndexMetaDatabaseStatus - a model defined in OpenAPI - - Keyword Args: - _check_type (bool): if True, values for parameters in openapi_types - will be type checked and a TypeError will be - raised if the wrong type is input. - Defaults to True - _path_to_item (tuple/list): This is a list of keys or values to - drill down to the model in received_data - when deserializing a response - _spec_property_naming (bool): True if the variable names in the input data - are serialized names, as specified in the OpenAPI document. - False if the variable names in the input data - are pythonic names, e.g. snake case (default) - _configuration (Configuration): the instance to use when - deserializing a file_type parameter. - If passed, type conversion is attempted - If omitted no type conversion is done. - _visited_composed_classes (tuple): This stores a tuple of - classes that we have traveled through so that - if we see that class again we will not use its - discriminator again. - When traveling through a discriminator, the - composed schema that is - is traveled through is added to this set. - For example if Animal has a discriminator - petType and we pass in "Dog", and the class Dog - allOf includes Animal, we move through Animal - once using the discriminator, and pick Dog. - Then in Dog, we will make an instance of the - Animal class but this time we won't travel - through its discriminator because we passed in - _visited_composed_classes = (Animal,) - ready (bool): [optional] # noqa: E501 - state (str): [optional] # noqa: E501 - """ - - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) - - self = super(OpenApiModel, cls).__new__(cls) - - if args: - raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( - args, - self.__class__.__name__, - ), - path_to_item=_path_to_item, - valid_classes=(self.__class__,), - ) - - self._data_store = {} - self._check_type = _check_type - self._spec_property_naming = _spec_property_naming - self._path_to_item = _path_to_item - self._configuration = _configuration - self._visited_composed_classes = _visited_composed_classes + (self.__class__,) - - for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): - # discard variable. - continue - setattr(self, var_name, var_value) - return self - - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) - - @convert_js_args_to_python_args - def __init__(self, *args, **kwargs): # noqa: E501 - """IndexMetaDatabaseStatus - a model defined in OpenAPI - - Keyword Args: - _check_type (bool): if True, values for parameters in openapi_types - will be type checked and a TypeError will be - raised if the wrong type is input. - Defaults to True - _path_to_item (tuple/list): This is a list of keys or values to - drill down to the model in received_data - when deserializing a response - _spec_property_naming (bool): True if the variable names in the input data - are serialized names, as specified in the OpenAPI document. - False if the variable names in the input data - are pythonic names, e.g. snake case (default) - _configuration (Configuration): the instance to use when - deserializing a file_type parameter. - If passed, type conversion is attempted - If omitted no type conversion is done. - _visited_composed_classes (tuple): This stores a tuple of - classes that we have traveled through so that - if we see that class again we will not use its - discriminator again. - When traveling through a discriminator, the - composed schema that is - is traveled through is added to this set. - For example if Animal has a discriminator - petType and we pass in "Dog", and the class Dog - allOf includes Animal, we move through Animal - once using the discriminator, and pick Dog. - Then in Dog, we will make an instance of the - Animal class but this time we won't travel - through its discriminator because we passed in - _visited_composed_classes = (Animal,) - ready (bool): [optional] # noqa: E501 - state (str): [optional] # noqa: E501 - """ - - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) - - if args: - raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( - args, - self.__class__.__name__, - ), - path_to_item=_path_to_item, - valid_classes=(self.__class__,), - ) - - self._data_store = {} - self._check_type = _check_type - self._spec_property_naming = _spec_property_naming - self._path_to_item = _path_to_item - self._configuration = _configuration - self._visited_composed_classes = _visited_composed_classes + (self.__class__,) - - for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): - # discard variable. - continue - setattr(self, var_name, var_value) - if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) diff --git a/pinecone/core/client/model/index_meta_status.py b/pinecone/core/client/model/index_meta_status.py index c9da0214a..62abdbd66 100644 --- a/pinecone/core/client/model/index_meta_status.py +++ b/pinecone/core/client/model/index_meta_status.py @@ -1,5 +1,5 @@ """ - Pinecone JSON API + Pinecone API No description provided (generated by Openapi Generator https://github.com/openapitools/openapi-generator) # noqa: E501 @@ -30,6 +30,7 @@ from pinecone.core.client.exceptions import ApiAttributeError + class IndexMetaStatus(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -54,9 +55,21 @@ class IndexMetaStatus(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + ('state',): { + 'INITIALIZING': "Initializing", + 'INITIALIZATIONFAILED': "InitializationFailed", + 'SCALINGUP': "ScalingUp", + 'SCALINGDOWN': "ScalingDown", + 'SCALINGUPPODSIZE': "ScalingUpPodSize", + 'SCALINGDOWNPODSIZE': "ScalingDownPodSize", + 'TERMINATING': "Terminating", + 'READY': "Ready", + }, + } - validations = {} + validations = { + } @cached_property def additional_properties_type(): @@ -64,17 +77,7 @@ def additional_properties_type(): This must be a method because a model may have properties that are of type self, this must run after the class is loaded """ - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -89,24 +92,26 @@ def openapi_types(): and the value is attribute type. """ return { - "crashed": ([str],), # noqa: E501 - "ready": (bool,), # noqa: E501 - "port": (int,), # noqa: E501 - "waiting": ([str],), # noqa: E501 + 'ready': (bool,), # noqa: E501 + 'state': (str,), # noqa: E501 + 'host': (str,), # noqa: E501 + 'port': (int,), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "crashed": "crashed", # noqa: E501 - "ready": "ready", # noqa: E501 - "port": "port", # noqa: E501 - "waiting": "waiting", # noqa: E501 + 'ready': 'ready', # noqa: E501 + 'state': 'state', # noqa: E501 + 'host': 'host', # noqa: E501 + 'port': 'port', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -146,24 +151,23 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - crashed ([str]): [optional] # noqa: E501 ready (bool): [optional] # noqa: E501 + state (str): [optional] # noqa: E501 + host (str): [optional] # noqa: E501 port (int): [optional] # noqa: E501 - waiting ([str]): [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -179,27 +183,23 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, *args, **kwargs): # noqa: E501 @@ -236,22 +236,21 @@ def __init__(self, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - crashed ([str]): [optional] # noqa: E501 ready (bool): [optional] # noqa: E501 + state (str): [optional] # noqa: E501 + host (str): [optional] # noqa: E501 port (int): [optional] # noqa: E501 - waiting ([str]): [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -267,17 +266,13 @@ def __init__(self, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/namespace_summary.py b/pinecone/core/client/model/namespace_summary.py index 869672d0a..33633f796 100644 --- a/pinecone/core/client/model/namespace_summary.py +++ b/pinecone/core/client/model/namespace_summary.py @@ -30,6 +30,7 @@ from pinecone.core.client.exceptions import ApiAttributeError + class NamespaceSummary(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -54,9 +55,11 @@ class NamespaceSummary(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + } - validations = {} + validations = { + } @cached_property def additional_properties_type(): @@ -64,17 +67,7 @@ def additional_properties_type(): This must be a method because a model may have properties that are of type self, this must run after the class is loaded """ - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -89,18 +82,20 @@ def openapi_types(): and the value is attribute type. """ return { - "vector_count": (int,), # noqa: E501 + 'vector_count': (int,), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "vector_count": "vectorCount", # noqa: E501 + 'vector_count': 'vectorCount', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -143,18 +138,17 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 vector_count (int): The number of vectors stored in this namespace. Note that updates to this field may lag behind updates to the underlying index and corresponding query results, etc.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -170,27 +164,23 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, *args, **kwargs): # noqa: E501 @@ -230,16 +220,15 @@ def __init__(self, *args, **kwargs): # noqa: E501 vector_count (int): The number of vectors stored in this namespace. Note that updates to this field may lag behind updates to the underlying index and corresponding query results, etc.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -255,17 +244,13 @@ def __init__(self, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/patch_request.py b/pinecone/core/client/model/patch_request.py index ac67785d5..53425c222 100644 --- a/pinecone/core/client/model/patch_request.py +++ b/pinecone/core/client/model/patch_request.py @@ -30,6 +30,7 @@ from pinecone.core.client.exceptions import ApiAttributeError + class PatchRequest(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -54,9 +55,11 @@ class PatchRequest(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + } - validations = {} + validations = { + } @cached_property def additional_properties_type(): @@ -64,17 +67,7 @@ def additional_properties_type(): This must be a method because a model may have properties that are of type self, this must run after the class is loaded """ - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -89,20 +82,22 @@ def openapi_types(): and the value is attribute type. """ return { - "replicas": (int,), # noqa: E501 - "pod_type": (str,), # noqa: E501 + 'replicas': (int,), # noqa: E501 + 'pod_type': (str,), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "replicas": "replicas", # noqa: E501 - "pod_type": "pod_type", # noqa: E501 + 'replicas': 'replicas', # noqa: E501 + 'pod_type': 'pod_type', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -146,18 +141,17 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 pod_type (str): The new pod type for the index. One of `s1`, `p1`, or `p2` appended with `.` and one of `x1`, `x2`, `x4`, or `x8`.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -173,27 +167,23 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, *args, **kwargs): # noqa: E501 @@ -234,16 +224,15 @@ def __init__(self, *args, **kwargs): # noqa: E501 pod_type (str): The new pod type for the index. One of `s1`, `p1`, or `p2` appended with `.` and one of `x1`, `x2`, `x4`, or `x8`.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -259,17 +248,13 @@ def __init__(self, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/protobuf_any.py b/pinecone/core/client/model/protobuf_any.py index 220d4fc11..365f5064c 100644 --- a/pinecone/core/client/model/protobuf_any.py +++ b/pinecone/core/client/model/protobuf_any.py @@ -30,6 +30,7 @@ from pinecone.core.client.exceptions import ApiAttributeError + class ProtobufAny(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -54,9 +55,11 @@ class ProtobufAny(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + } - validations = {} + validations = { + } @cached_property def additional_properties_type(): @@ -64,17 +67,7 @@ def additional_properties_type(): This must be a method because a model may have properties that are of type self, this must run after the class is loaded """ - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -89,20 +82,22 @@ def openapi_types(): and the value is attribute type. """ return { - "type_url": (str,), # noqa: E501 - "value": (str,), # noqa: E501 + 'type_url': (str,), # noqa: E501 + 'value': (str,), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "type_url": "typeUrl", # noqa: E501 - "value": "value", # noqa: E501 + 'type_url': 'typeUrl', # noqa: E501 + 'value': 'value', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -146,18 +141,17 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 value (str): [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -173,27 +167,23 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, *args, **kwargs): # noqa: E501 @@ -234,16 +224,15 @@ def __init__(self, *args, **kwargs): # noqa: E501 value (str): [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -259,17 +248,13 @@ def __init__(self, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/protobuf_null_value.py b/pinecone/core/client/model/protobuf_null_value.py index 9cc94e881..63129117d 100644 --- a/pinecone/core/client/model/protobuf_null_value.py +++ b/pinecone/core/client/model/protobuf_null_value.py @@ -30,6 +30,7 @@ from pinecone.core.client.exceptions import ApiAttributeError + class ProtobufNullValue(ModelSimple): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -51,12 +52,13 @@ class ProtobufNullValue(ModelSimple): """ allowed_values = { - ("value",): { - "NULL_VALUE": "NULL_VALUE", + ('value',): { + 'NULL_VALUE': "NULL_VALUE", }, } - validations = {} + validations = { + } @cached_property def additional_properties_type(): @@ -64,17 +66,7 @@ def additional_properties_type(): This must be a method because a model may have properties that are of type self, this must run after the class is loaded """ - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -89,29 +81,28 @@ def openapi_types(): and the value is attribute type. """ return { - "value": (str,), + 'value': (str,), } @cached_property def discriminator(): return None + attribute_map = {} read_only_vars = set() _composed_schemas = None - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, *args, **kwargs): @@ -156,25 +147,24 @@ def __init__(self, *args, **kwargs): _visited_composed_classes = (Animal,) """ # required up here when default value is not given - _path_to_item = kwargs.pop("_path_to_item", ()) + _path_to_item = kwargs.pop('_path_to_item', ()) - if "value" in kwargs: - value = kwargs.pop("value") + if 'value' in kwargs: + value = kwargs.pop('value') elif args: args = list(args) value = args.pop(0) else: value = "NULL_VALUE" - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -191,8 +181,7 @@ def __init__(self, *args, **kwargs): self.value = value if kwargs: raise ApiTypeError( - "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." - % ( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." % ( kwargs, self.__class__.__name__, ), @@ -244,27 +233,26 @@ def _from_openapi_data(cls, *args, **kwargs): _visited_composed_classes = (Animal,) """ # required up here when default value is not given - _path_to_item = kwargs.pop("_path_to_item", ()) + _path_to_item = kwargs.pop('_path_to_item', ()) self = super(OpenApiModel, cls).__new__(cls) - if "value" in kwargs: - value = kwargs.pop("value") + if 'value' in kwargs: + value = kwargs.pop('value') elif args: args = list(args) value = args.pop(0) else: value = "NULL_VALUE" - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -281,8 +269,7 @@ def _from_openapi_data(cls, *args, **kwargs): self.value = value if kwargs: raise ApiTypeError( - "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." - % ( + "Invalid named arguments=%s passed to %s. Remove those invalid named arguments." % ( kwargs, self.__class__.__name__, ), diff --git a/pinecone/core/client/model/query_request.py b/pinecone/core/client/model/query_request.py index ec88c383c..774d06f73 100644 --- a/pinecone/core/client/model/query_request.py +++ b/pinecone/core/client/model/query_request.py @@ -33,9 +33,8 @@ def lazy_import(): from pinecone.core.client.model.query_vector import QueryVector from pinecone.core.client.model.sparse_values import SparseValues - - globals()["QueryVector"] = QueryVector - globals()["SparseValues"] = SparseValues + globals()['QueryVector'] = QueryVector + globals()['SparseValues'] = SparseValues class QueryRequest(ModelNormal): @@ -62,17 +61,20 @@ class QueryRequest(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + } validations = { - ("top_k",): { - "inclusive_maximum": 10000, - "inclusive_minimum": 1, + ('top_k',): { + 'inclusive_maximum': 10000, + 'inclusive_minimum': 1, + }, + ('queries',): { + }, + ('vector',): { }, - ("queries",): {}, - ("vector",): {}, - ("id",): { - "max_length": 512, + ('id',): { + 'max_length': 512, }, } @@ -83,17 +85,7 @@ def additional_properties_type(): of type self, this must run after the class is loaded """ lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -109,34 +101,36 @@ def openapi_types(): """ lazy_import() return { - "top_k": (int,), # noqa: E501 - "namespace": (str,), # noqa: E501 - "filter": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 - "include_values": (bool,), # noqa: E501 - "include_metadata": (bool,), # noqa: E501 - "queries": ([QueryVector],), # noqa: E501 - "vector": ([float],), # noqa: E501 - "sparse_vector": (SparseValues,), # noqa: E501 - "id": (str,), # noqa: E501 + 'top_k': (int,), # noqa: E501 + 'namespace': (str,), # noqa: E501 + 'filter': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 + 'include_values': (bool,), # noqa: E501 + 'include_metadata': (bool,), # noqa: E501 + 'queries': ([QueryVector],), # noqa: E501 + 'vector': ([float],), # noqa: E501 + 'sparse_vector': (SparseValues,), # noqa: E501 + 'id': (str,), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "top_k": "topK", # noqa: E501 - "namespace": "namespace", # noqa: E501 - "filter": "filter", # noqa: E501 - "include_values": "includeValues", # noqa: E501 - "include_metadata": "includeMetadata", # noqa: E501 - "queries": "queries", # noqa: E501 - "vector": "vector", # noqa: E501 - "sparse_vector": "sparseVector", # noqa: E501 - "id": "id", # noqa: E501 + 'top_k': 'topK', # noqa: E501 + 'namespace': 'namespace', # noqa: E501 + 'filter': 'filter', # noqa: E501 + 'include_values': 'includeValues', # noqa: E501 + 'include_metadata': 'includeMetadata', # noqa: E501 + 'queries': 'queries', # noqa: E501 + 'vector': 'vector', # noqa: E501 + 'sparse_vector': 'sparseVector', # noqa: E501 + 'id': 'id', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -189,18 +183,17 @@ def _from_openapi_data(cls, top_k, *args, **kwargs): # noqa: E501 id (str): The unique ID of the vector to be used as a query vector. Each `query()` request can contain only one of the parameters `queries`, `vector`, or `id`.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -217,27 +210,23 @@ def _from_openapi_data(cls, top_k, *args, **kwargs): # noqa: E501 self.top_k = top_k for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, top_k, *args, **kwargs): # noqa: E501 @@ -283,20 +272,19 @@ def __init__(self, top_k, *args, **kwargs): # noqa: E501 include_metadata (bool): Indicates whether metadata is included in the response as well as the ids.. [optional] if omitted the server will use the default value of False # noqa: E501 queries ([QueryVector]): DEPRECATED. The query vectors. Each `query()` request can contain only one of the parameters `queries`, `vector`, or `id`.. [optional] # noqa: E501 vector ([float]): The query vector. This should be the same length as the dimension of the index being queried. Each `query()` request can contain only one of the parameters `id` or `vector`.. [optional] # noqa: E501 - sparse_vector (SparseValues): The sparse values of the query vector [optional] # noqa: E501 + sparse_vector (SparseValues): [optional] # noqa: E501 id (str): The unique ID of the vector to be used as a query vector. Each `query()` request can contain only one of the parameters `queries`, `vector`, or `id`.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -313,17 +301,13 @@ def __init__(self, top_k, *args, **kwargs): # noqa: E501 self.top_k = top_k for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/query_response.py b/pinecone/core/client/model/query_response.py index 855337627..886c93000 100644 --- a/pinecone/core/client/model/query_response.py +++ b/pinecone/core/client/model/query_response.py @@ -33,9 +33,8 @@ def lazy_import(): from pinecone.core.client.model.scored_vector import ScoredVector from pinecone.core.client.model.single_query_results import SingleQueryResults - - globals()["ScoredVector"] = ScoredVector - globals()["SingleQueryResults"] = SingleQueryResults + globals()['ScoredVector'] = ScoredVector + globals()['SingleQueryResults'] = SingleQueryResults class QueryResponse(ModelNormal): @@ -62,9 +61,11 @@ class QueryResponse(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + } - validations = {} + validations = { + } @cached_property def additional_properties_type(): @@ -73,17 +74,7 @@ def additional_properties_type(): of type self, this must run after the class is loaded """ lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -99,22 +90,24 @@ def openapi_types(): """ lazy_import() return { - "results": ([SingleQueryResults],), # noqa: E501 - "matches": ([ScoredVector],), # noqa: E501 - "namespace": (str,), # noqa: E501 + 'results': ([SingleQueryResults],), # noqa: E501 + 'matches': ([ScoredVector],), # noqa: E501 + 'namespace': (str,), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "results": "results", # noqa: E501 - "matches": "matches", # noqa: E501 - "namespace": "namespace", # noqa: E501 + 'results': 'results', # noqa: E501 + 'matches': 'matches', # noqa: E501 + 'namespace': 'namespace', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -159,18 +152,17 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 namespace (str): The namespace for the vectors.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -186,27 +178,23 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, *args, **kwargs): # noqa: E501 @@ -248,16 +236,15 @@ def __init__(self, *args, **kwargs): # noqa: E501 namespace (str): The namespace for the vectors.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -273,17 +260,13 @@ def __init__(self, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/query_vector.py b/pinecone/core/client/model/query_vector.py index 5d52522ec..b7220d5d9 100644 --- a/pinecone/core/client/model/query_vector.py +++ b/pinecone/core/client/model/query_vector.py @@ -32,8 +32,7 @@ def lazy_import(): from pinecone.core.client.model.sparse_values import SparseValues - - globals()["SparseValues"] = SparseValues + globals()['SparseValues'] = SparseValues class QueryVector(ModelNormal): @@ -60,13 +59,15 @@ class QueryVector(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + } validations = { - ("values",): {}, - ("top_k",): { - "inclusive_maximum": 10000, - "inclusive_minimum": 1, + ('values',): { + }, + ('top_k',): { + 'inclusive_maximum': 10000, + 'inclusive_minimum': 1, }, } @@ -77,17 +78,7 @@ def additional_properties_type(): of type self, this must run after the class is loaded """ lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -103,26 +94,28 @@ def openapi_types(): """ lazy_import() return { - "values": ([float],), # noqa: E501 - "sparse_values": (SparseValues,), # noqa: E501 - "top_k": (int,), # noqa: E501 - "namespace": (str,), # noqa: E501 - "filter": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 + 'values': ([float],), # noqa: E501 + 'sparse_values': (SparseValues,), # noqa: E501 + 'top_k': (int,), # noqa: E501 + 'namespace': (str,), # noqa: E501 + 'filter': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "values": "values", # noqa: E501 - "sparse_values": "sparseValues", # noqa: E501 - "top_k": "topK", # noqa: E501 - "namespace": "namespace", # noqa: E501 - "filter": "filter", # noqa: E501 + 'values': 'values', # noqa: E501 + 'sparse_values': 'sparseValues', # noqa: E501 + 'top_k': 'topK', # noqa: E501 + 'namespace': 'namespace', # noqa: E501 + 'filter': 'filter', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -165,24 +158,23 @@ def _from_openapi_data(cls, values, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - sparse_values (SparseValues): The sparse data of the query vector [optional] # noqa: E501 + sparse_values (SparseValues): [optional] # noqa: E501 top_k (int): An override for the number of results to return for this query vector.. [optional] # noqa: E501 namespace (str): An override the namespace to search.. [optional] # noqa: E501 filter ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): An override for the metadata filter to apply. This replaces the request-level filter.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -199,27 +191,23 @@ def _from_openapi_data(cls, values, *args, **kwargs): # noqa: E501 self.values = values for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, values, *args, **kwargs): # noqa: E501 @@ -259,22 +247,21 @@ def __init__(self, values, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - sparse_values (SparseValues): This is the sparse data of the vector [optional] # noqa: E501 + sparse_values (SparseValues): [optional] # noqa: E501 top_k (int): An override for the number of results to return for this query vector.. [optional] # noqa: E501 namespace (str): An override the namespace to search.. [optional] # noqa: E501 filter ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): An override for the metadata filter to apply. This replaces the request-level filter.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -291,17 +278,13 @@ def __init__(self, values, *args, **kwargs): # noqa: E501 self.values = values for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/rpc_status.py b/pinecone/core/client/model/rpc_status.py index 6d0c7605a..30ff15f95 100644 --- a/pinecone/core/client/model/rpc_status.py +++ b/pinecone/core/client/model/rpc_status.py @@ -32,8 +32,7 @@ def lazy_import(): from pinecone.core.client.model.protobuf_any import ProtobufAny - - globals()["ProtobufAny"] = ProtobufAny + globals()['ProtobufAny'] = ProtobufAny class RpcStatus(ModelNormal): @@ -60,9 +59,11 @@ class RpcStatus(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + } - validations = {} + validations = { + } @cached_property def additional_properties_type(): @@ -71,17 +72,7 @@ def additional_properties_type(): of type self, this must run after the class is loaded """ lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -97,22 +88,24 @@ def openapi_types(): """ lazy_import() return { - "code": (int,), # noqa: E501 - "message": (str,), # noqa: E501 - "details": ([ProtobufAny],), # noqa: E501 + 'code': (int,), # noqa: E501 + 'message': (str,), # noqa: E501 + 'details': ([ProtobufAny],), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "code": "code", # noqa: E501 - "message": "message", # noqa: E501 - "details": "details", # noqa: E501 + 'code': 'code', # noqa: E501 + 'message': 'message', # noqa: E501 + 'details': 'details', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -157,18 +150,17 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 details ([ProtobufAny]): [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -184,27 +176,23 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, *args, **kwargs): # noqa: E501 @@ -246,16 +234,15 @@ def __init__(self, *args, **kwargs): # noqa: E501 details ([ProtobufAny]): [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -271,17 +258,13 @@ def __init__(self, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/scored_vector.py b/pinecone/core/client/model/scored_vector.py index 98e7f9589..88cd807db 100644 --- a/pinecone/core/client/model/scored_vector.py +++ b/pinecone/core/client/model/scored_vector.py @@ -32,8 +32,7 @@ def lazy_import(): from pinecone.core.client.model.sparse_values import SparseValues - - globals()["SparseValues"] = SparseValues + globals()['SparseValues'] = SparseValues class ScoredVector(ModelNormal): @@ -60,12 +59,13 @@ class ScoredVector(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + } validations = { - ("id",): { - "max_length": 512, - "min_length": 1, + ('id',): { + 'max_length': 512, + 'min_length': 1, }, } @@ -76,17 +76,7 @@ def additional_properties_type(): of type self, this must run after the class is loaded """ lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -102,26 +92,28 @@ def openapi_types(): """ lazy_import() return { - "id": (str,), # noqa: E501 - "score": (float,), # noqa: E501 - "values": ([float],), # noqa: E501 - "sparse_values": (SparseValues,), # noqa: E501 - "metadata": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 + 'id': (str,), # noqa: E501 + 'score': (float,), # noqa: E501 + 'values': ([float],), # noqa: E501 + 'sparse_values': (SparseValues,), # noqa: E501 + 'metadata': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "id": "id", # noqa: E501 - "score": "score", # noqa: E501 - "values": "values", # noqa: E501 - "sparse_values": "sparseValues", # noqa: E501 - "metadata": "metadata", # noqa: E501 + 'id': 'id', # noqa: E501 + 'score': 'score', # noqa: E501 + 'values': 'values', # noqa: E501 + 'sparse_values': 'sparseValues', # noqa: E501 + 'metadata': 'metadata', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -166,22 +158,21 @@ def _from_openapi_data(cls, id, *args, **kwargs): # noqa: E501 _visited_composed_classes = (Animal,) score (float): This is a measure of similarity between this vector and the query vector. The higher the score, the more they are similar.. [optional] # noqa: E501 values ([float]): This is the vector data, if it is requested.. [optional] # noqa: E501 - sparse_values (SparseValues): the sparse data of the vector [optional] # noqa: E501 + sparse_values (SparseValues): [optional] # noqa: E501 metadata ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): This is the metadata, if it is requested.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -198,27 +189,23 @@ def _from_openapi_data(cls, id, *args, **kwargs): # noqa: E501 self.id = id for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, id, *args, **kwargs): # noqa: E501 @@ -260,20 +247,19 @@ def __init__(self, id, *args, **kwargs): # noqa: E501 _visited_composed_classes = (Animal,) score (float): This is a measure of similarity between this vector and the query vector. The higher the score, the more they are similar.. [optional] # noqa: E501 values ([float]): This is the vector data, if it is requested.. [optional] # noqa: E501 - sparse_values (SparseValues): This is the sparse data of the vector [optional] # noqa: E501 + sparse_values (SparseValues): [optional] # noqa: E501 metadata ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): This is the metadata, if it is requested.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -290,17 +276,13 @@ def __init__(self, id, *args, **kwargs): # noqa: E501 self.id = id for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/single_query_results.py b/pinecone/core/client/model/single_query_results.py index 9ff572893..0c7415621 100644 --- a/pinecone/core/client/model/single_query_results.py +++ b/pinecone/core/client/model/single_query_results.py @@ -32,8 +32,7 @@ def lazy_import(): from pinecone.core.client.model.scored_vector import ScoredVector - - globals()["ScoredVector"] = ScoredVector + globals()['ScoredVector'] = ScoredVector class SingleQueryResults(ModelNormal): @@ -60,9 +59,11 @@ class SingleQueryResults(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + } - validations = {} + validations = { + } @cached_property def additional_properties_type(): @@ -71,17 +72,7 @@ def additional_properties_type(): of type self, this must run after the class is loaded """ lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -97,20 +88,22 @@ def openapi_types(): """ lazy_import() return { - "matches": ([ScoredVector],), # noqa: E501 - "namespace": (str,), # noqa: E501 + 'matches': ([ScoredVector],), # noqa: E501 + 'namespace': (str,), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "matches": "matches", # noqa: E501 - "namespace": "namespace", # noqa: E501 + 'matches': 'matches', # noqa: E501 + 'namespace': 'namespace', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -154,18 +147,17 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 namespace (str): The namespace for the vectors.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -181,27 +173,23 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, *args, **kwargs): # noqa: E501 @@ -242,16 +230,15 @@ def __init__(self, *args, **kwargs): # noqa: E501 namespace (str): The namespace for the vectors.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -267,17 +254,13 @@ def __init__(self, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/sparse_values.py b/pinecone/core/client/model/sparse_values.py index 08bc71338..4d619531a 100644 --- a/pinecone/core/client/model/sparse_values.py +++ b/pinecone/core/client/model/sparse_values.py @@ -30,6 +30,7 @@ from pinecone.core.client.exceptions import ApiAttributeError + class SparseValues(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -54,11 +55,14 @@ class SparseValues(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + } validations = { - ("indices",): {}, - ("values",): {}, + ('indices',): { + }, + ('values',): { + }, } @cached_property @@ -67,17 +71,7 @@ def additional_properties_type(): This must be a method because a model may have properties that are of type self, this must run after the class is loaded """ - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -92,20 +86,22 @@ def openapi_types(): and the value is attribute type. """ return { - "indices": ([int],), # noqa: E501 - "values": ([float],), # noqa: E501 + 'indices': ([int],), # noqa: E501 + 'values': ([float],), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "indices": "indices", # noqa: E501 - "values": "values", # noqa: E501 + 'indices': 'indices', # noqa: E501 + 'values': 'values', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -115,8 +111,8 @@ def _from_openapi_data(cls, indices, values, *args, **kwargs): # noqa: E501 """SparseValues - a model defined in OpenAPI Args: - indices ([int]): - values ([float]): + indices ([int]): The indices of the sparse data. + values ([float]): The corresponding values of the sparse data, which must be with the same length as the indices. Keyword Args: _check_type (bool): if True, values for parameters in openapi_types @@ -151,18 +147,17 @@ def _from_openapi_data(cls, indices, values, *args, **kwargs): # noqa: E501 _visited_composed_classes = (Animal,) """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -180,35 +175,31 @@ def _from_openapi_data(cls, indices, values, *args, **kwargs): # noqa: E501 self.indices = indices self.values = values for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, indices, values, *args, **kwargs): # noqa: E501 """SparseValues - a model defined in OpenAPI Args: - indices ([int]): - values ([float]): + indices ([int]): The indices of the sparse data. + values ([float]): The corresponding values of the sparse data, which must be with the same length as the indices. Keyword Args: _check_type (bool): if True, values for parameters in openapi_types @@ -243,16 +234,15 @@ def __init__(self, indices, values, *args, **kwargs): # noqa: E501 _visited_composed_classes = (Animal,) """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -270,17 +260,13 @@ def __init__(self, indices, values, *args, **kwargs): # noqa: E501 self.indices = indices self.values = values for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/update_request.py b/pinecone/core/client/model/update_request.py index 404ec38d4..1aec2bd88 100644 --- a/pinecone/core/client/model/update_request.py +++ b/pinecone/core/client/model/update_request.py @@ -32,8 +32,7 @@ def lazy_import(): from pinecone.core.client.model.sparse_values import SparseValues - - globals()["SparseValues"] = SparseValues + globals()['SparseValues'] = SparseValues class UpdateRequest(ModelNormal): @@ -60,14 +59,16 @@ class UpdateRequest(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + } validations = { - ("id",): { - "max_length": 512, - "min_length": 1, + ('id',): { + 'max_length': 512, + 'min_length': 1, + }, + ('values',): { }, - ("values",): {}, } @cached_property @@ -77,17 +78,7 @@ def additional_properties_type(): of type self, this must run after the class is loaded """ lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -103,26 +94,28 @@ def openapi_types(): """ lazy_import() return { - "id": (str,), # noqa: E501 - "values": ([float],), # noqa: E501 - "sparse_values": (SparseValues,), # noqa: E501 - "set_metadata": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 - "namespace": (str,), # noqa: E501 + 'id': (str,), # noqa: E501 + 'values': ([float],), # noqa: E501 + 'sparse_values': (SparseValues,), # noqa: E501 + 'set_metadata': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 + 'namespace': (str,), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "id": "id", # noqa: E501 - "values": "values", # noqa: E501 - "sparse_values": "sparseValues", # noqa: E501 - "set_metadata": "setMetadata", # noqa: E501 - "namespace": "namespace", # noqa: E501 + 'id': 'id', # noqa: E501 + 'values': 'values', # noqa: E501 + 'sparse_values': 'sparseValues', # noqa: E501 + 'set_metadata': 'setMetadata', # noqa: E501 + 'namespace': 'namespace', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -166,23 +159,22 @@ def _from_openapi_data(cls, id, *args, **kwargs): # noqa: E501 through its discriminator because we passed in _visited_composed_classes = (Animal,) values ([float]): Vector data.. [optional] # noqa: E501 - sparse_values (SparseValues): This is the sparse data of the vector to update [optional] # noqa: E501 + sparse_values (SparseValues): [optional] # noqa: E501 set_metadata ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): Metadata to *set* for the vector.. [optional] # noqa: E501 namespace (str): Namespace name where to update the vector.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -199,27 +191,23 @@ def _from_openapi_data(cls, id, *args, **kwargs): # noqa: E501 self.id = id for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, id, *args, **kwargs): # noqa: E501 @@ -260,21 +248,20 @@ def __init__(self, id, *args, **kwargs): # noqa: E501 through its discriminator because we passed in _visited_composed_classes = (Animal,) values ([float]): Vector data.. [optional] # noqa: E501 - sparse_values (SparseValues): This is the sparse data of the vector to update [optional] # noqa: E501 + sparse_values (SparseValues): [optional] # noqa: E501 set_metadata ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): Metadata to *set* for the vector.. [optional] # noqa: E501 namespace (str): Namespace name where to update the vector.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -291,17 +278,13 @@ def __init__(self, id, *args, **kwargs): # noqa: E501 self.id = id for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/upsert_request.py b/pinecone/core/client/model/upsert_request.py index 319900217..0ebf0aaed 100644 --- a/pinecone/core/client/model/upsert_request.py +++ b/pinecone/core/client/model/upsert_request.py @@ -32,8 +32,7 @@ def lazy_import(): from pinecone.core.client.model.vector import Vector - - globals()["Vector"] = Vector + globals()['Vector'] = Vector class UpsertRequest(ModelNormal): @@ -60,10 +59,12 @@ class UpsertRequest(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + } validations = { - ("vectors",): {}, + ('vectors',): { + }, } @cached_property @@ -73,17 +74,7 @@ def additional_properties_type(): of type self, this must run after the class is loaded """ lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -99,20 +90,22 @@ def openapi_types(): """ lazy_import() return { - "vectors": ([Vector],), # noqa: E501 - "namespace": (str,), # noqa: E501 + 'vectors': ([Vector],), # noqa: E501 + 'namespace': (str,), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "vectors": "vectors", # noqa: E501 - "namespace": "namespace", # noqa: E501 + 'vectors': 'vectors', # noqa: E501 + 'namespace': 'namespace', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -158,18 +151,17 @@ def _from_openapi_data(cls, vectors, *args, **kwargs): # noqa: E501 namespace (str): This is the namespace name where you upsert vectors.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -186,27 +178,23 @@ def _from_openapi_data(cls, vectors, *args, **kwargs): # noqa: E501 self.vectors = vectors for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, vectors, *args, **kwargs): # noqa: E501 @@ -249,16 +237,15 @@ def __init__(self, vectors, *args, **kwargs): # noqa: E501 namespace (str): This is the namespace name where you upsert vectors.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -275,17 +262,13 @@ def __init__(self, vectors, *args, **kwargs): # noqa: E501 self.vectors = vectors for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/upsert_response.py b/pinecone/core/client/model/upsert_response.py index b766ec431..831fb39bb 100644 --- a/pinecone/core/client/model/upsert_response.py +++ b/pinecone/core/client/model/upsert_response.py @@ -30,6 +30,7 @@ from pinecone.core.client.exceptions import ApiAttributeError + class UpsertResponse(ModelNormal): """NOTE: This class is auto generated by OpenAPI Generator. Ref: https://openapi-generator.tech @@ -54,9 +55,11 @@ class UpsertResponse(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + } - validations = {} + validations = { + } @cached_property def additional_properties_type(): @@ -64,17 +67,7 @@ def additional_properties_type(): This must be a method because a model may have properties that are of type self, this must run after the class is loaded """ - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -89,18 +82,20 @@ def openapi_types(): and the value is attribute type. """ return { - "upserted_count": (int,), # noqa: E501 + 'upserted_count': (int,), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "upserted_count": "upsertedCount", # noqa: E501 + 'upserted_count': 'upsertedCount', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -143,18 +138,17 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 upserted_count (int): The number of vectors upserted.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -170,27 +164,23 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, *args, **kwargs): # noqa: E501 @@ -230,16 +220,15 @@ def __init__(self, *args, **kwargs): # noqa: E501 upserted_count (int): The number of vectors upserted.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -255,17 +244,13 @@ def __init__(self, *args, **kwargs): # noqa: E501 self._visited_composed_classes = _visited_composed_classes + (self.__class__,) for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model/vector.py b/pinecone/core/client/model/vector.py index 58a4dbea7..e3aef790a 100644 --- a/pinecone/core/client/model/vector.py +++ b/pinecone/core/client/model/vector.py @@ -32,8 +32,7 @@ def lazy_import(): from pinecone.core.client.model.sparse_values import SparseValues - - globals()["SparseValues"] = SparseValues + globals()['SparseValues'] = SparseValues class Vector(ModelNormal): @@ -60,14 +59,16 @@ class Vector(ModelNormal): as additional properties values. """ - allowed_values = {} + allowed_values = { + } validations = { - ("id",): { - "max_length": 512, - "min_length": 1, + ('id',): { + 'max_length': 512, + 'min_length': 1, + }, + ('values',): { }, - ("values",): {}, } @cached_property @@ -77,17 +78,7 @@ def additional_properties_type(): of type self, this must run after the class is loaded """ lazy_import() - return ( - bool, - date, - datetime, - dict, - float, - int, - list, - str, - none_type, - ) # noqa: E501 + return (bool, date, datetime, dict, float, int, list, str, none_type,) # noqa: E501 _nullable = False @@ -103,24 +94,26 @@ def openapi_types(): """ lazy_import() return { - "id": (str,), # noqa: E501 - "values": ([float],), # noqa: E501 - "sparse_values": (SparseValues,), # noqa: E501 - "metadata": ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 + 'id': (str,), # noqa: E501 + 'values': ([float],), # noqa: E501 + 'sparse_values': (SparseValues,), # noqa: E501 + 'metadata': ({str: (bool, date, datetime, dict, float, int, list, str, none_type)},), # noqa: E501 } @cached_property def discriminator(): return None + attribute_map = { - "id": "id", # noqa: E501 - "values": "values", # noqa: E501 - "sparse_values": "sparseValues", # noqa: E501 - "metadata": "metadata", # noqa: E501 + 'id': 'id', # noqa: E501 + 'values': 'values', # noqa: E501 + 'sparse_values': 'sparseValues', # noqa: E501 + 'metadata': 'metadata', # noqa: E501 } - read_only_vars = {} + read_only_vars = { + } _composed_schemas = {} @@ -164,22 +157,21 @@ def _from_openapi_data(cls, id, values, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - sparse_values (SparseValues): the sparse data of the returned vector [optional] # noqa: E501 + sparse_values (SparseValues): [optional] # noqa: E501 metadata ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): This is the metadata included in the request.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) self = super(OpenApiModel, cls).__new__(cls) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -197,27 +189,23 @@ def _from_openapi_data(cls, id, values, *args, **kwargs): # noqa: E501 self.id = id self.values = values for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) return self - required_properties = set( - [ - "_data_store", - "_check_type", - "_spec_property_naming", - "_path_to_item", - "_configuration", - "_visited_composed_classes", - ] - ) + required_properties = set([ + '_data_store', + '_check_type', + '_spec_property_naming', + '_path_to_item', + '_configuration', + '_visited_composed_classes', + ]) @convert_js_args_to_python_args def __init__(self, id, values, *args, **kwargs): # noqa: E501 @@ -258,20 +246,19 @@ def __init__(self, id, values, *args, **kwargs): # noqa: E501 Animal class but this time we won't travel through its discriminator because we passed in _visited_composed_classes = (Animal,) - sparse_values (SparseValues): This is the sparse data of the vector to update [optional] # noqa: E501 + sparse_values (SparseValues): [optional] # noqa: E501 metadata ({str: (bool, date, datetime, dict, float, int, list, str, none_type)}): This is the metadata included in the request.. [optional] # noqa: E501 """ - _check_type = kwargs.pop("_check_type", True) - _spec_property_naming = kwargs.pop("_spec_property_naming", False) - _path_to_item = kwargs.pop("_path_to_item", ()) - _configuration = kwargs.pop("_configuration", None) - _visited_composed_classes = kwargs.pop("_visited_composed_classes", ()) + _check_type = kwargs.pop('_check_type', True) + _spec_property_naming = kwargs.pop('_spec_property_naming', False) + _path_to_item = kwargs.pop('_path_to_item', ()) + _configuration = kwargs.pop('_configuration', None) + _visited_composed_classes = kwargs.pop('_visited_composed_classes', ()) if args: raise ApiTypeError( - "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." - % ( + "Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % ( args, self.__class__.__name__, ), @@ -289,17 +276,13 @@ def __init__(self, id, values, *args, **kwargs): # noqa: E501 self.id = id self.values = values for var_name, var_value in kwargs.items(): - if ( - var_name not in self.attribute_map - and self._configuration is not None - and self._configuration.discard_unknown_keys - and self.additional_properties_type is None - ): + if var_name not in self.attribute_map and \ + self._configuration is not None and \ + self._configuration.discard_unknown_keys and \ + self.additional_properties_type is None: # discard variable. continue setattr(self, var_name, var_value) if var_name in self.read_only_vars: - raise ApiAttributeError( - f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " - f"class with read only attributes." - ) + raise ApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate " + f"class with read only attributes.") diff --git a/pinecone/core/client/model_utils.py b/pinecone/core/client/model_utils.py index 73dc385d5..940cc93a1 100644 --- a/pinecone/core/client/model_utils.py +++ b/pinecone/core/client/model_utils.py @@ -32,7 +32,6 @@ def convert_js_args_to_python_args(fn): from functools import wraps - @wraps(fn) def wrapped_init(_self, *args, **kwargs): """ @@ -40,11 +39,10 @@ def wrapped_init(_self, *args, **kwargs): parameter of a class method. During generation, `self` attributes are mapped to `_self` in models. Here, we name `_self` instead of `self` to avoid conflicts. """ - spec_property_naming = kwargs.get("_spec_property_naming", False) + spec_property_naming = kwargs.get('_spec_property_naming', False) if spec_property_naming: kwargs = change_keys_js_to_python(kwargs, _self if isinstance(_self, type) else _self.__class__) return fn(_self, *args, **kwargs) - return wrapped_init @@ -52,7 +50,7 @@ class cached_property(object): # this caches the result of the function call for fn with no inputs # use this as a decorator on function methods that you want converted # into cached properties - result_key = "_results" + result_key = '_results' def __init__(self, fn): self._fn = fn @@ -68,7 +66,6 @@ def __get__(self, instance, cls=None): PRIMITIVE_TYPES = (list, float, int, bool, datetime, date, str, file_type) - def allows_single_value_input(cls): """ This function returns True if the input composed schema model or any @@ -82,15 +79,17 @@ def allows_single_value_input(cls): - null TODO: lru_cache this """ - if issubclass(cls, ModelSimple) or cls in PRIMITIVE_TYPES: + if ( + issubclass(cls, ModelSimple) or + cls in PRIMITIVE_TYPES + ): return True elif issubclass(cls, ModelComposed): - if not cls._composed_schemas["oneOf"]: + if not cls._composed_schemas['oneOf']: return False - return any(allows_single_value_input(c) for c in cls._composed_schemas["oneOf"]) + return any(allows_single_value_input(c) for c in cls._composed_schemas['oneOf']) return False - def composed_model_input_classes(cls): """ This function returns a list of the possible models that can be accepted as @@ -105,11 +104,11 @@ def composed_model_input_classes(cls): else: return get_discriminated_classes(cls) elif issubclass(cls, ModelComposed): - if not cls._composed_schemas["oneOf"]: + if not cls._composed_schemas['oneOf']: return [] if cls.discriminator is None: input_classes = [] - for c in cls._composed_schemas["oneOf"]: + for c in cls._composed_schemas['oneOf']: input_classes.extend(composed_model_input_classes(c)) return input_classes else: @@ -131,28 +130,46 @@ def set_attribute(self, name, value): if name in self.openapi_types: required_types_mixed = self.openapi_types[name] elif self.additional_properties_type is None: - raise ApiAttributeError("{0} has no attribute '{1}'".format(type(self).__name__, name), path_to_item) + raise ApiAttributeError( + "{0} has no attribute '{1}'".format( + type(self).__name__, name), + path_to_item + ) elif self.additional_properties_type is not None: required_types_mixed = self.additional_properties_type if get_simple_class(name) != str: - error_msg = type_error_message(var_name=name, var_value=name, valid_classes=(str,), key_type=True) - raise ApiTypeError(error_msg, path_to_item=path_to_item, valid_classes=(str,), key_type=True) + error_msg = type_error_message( + var_name=name, + var_value=name, + valid_classes=(str,), + key_type=True + ) + raise ApiTypeError( + error_msg, + path_to_item=path_to_item, + valid_classes=(str,), + key_type=True + ) if self._check_type: value = validate_and_convert_types( - value, - required_types_mixed, - path_to_item, - self._spec_property_naming, - self._check_type, - configuration=self._configuration, - ) + value, required_types_mixed, path_to_item, self._spec_property_naming, + self._check_type, configuration=self._configuration) if (name,) in self.allowed_values: - check_allowed_values(self.allowed_values, (name,), value) + check_allowed_values( + self.allowed_values, + (name,), + value + ) if (name,) in self.validations: - check_validations(self.validations, (name,), value, self._configuration) - self.__dict__["_data_store"][name] = value + check_validations( + self.validations, + (name,), + value, + self._configuration + ) + self.__dict__['_data_store'][name] = value def __repr__(self): """For `print` and `pprint`""" @@ -186,8 +203,12 @@ def __new__(cls, *args, **kwargs): oneof_instance = get_oneof_instance(cls, model_kwargs, kwargs, model_arg=arg) return oneof_instance - visited_composed_classes = kwargs.get("_visited_composed_classes", ()) - if cls.discriminator is None or cls in visited_composed_classes: + + visited_composed_classes = kwargs.get('_visited_composed_classes', ()) + if ( + cls.discriminator is None or + cls in visited_composed_classes + ): # Use case 1: this openapi schema (cls) does not have a discriminator # Use case 2: we have already visited this class before and are sure that we # want to instantiate it this time. We have visited this class deserializing @@ -217,24 +238,28 @@ def __new__(cls, *args, **kwargs): discr_value = kwargs[discr_propertyname_py] else: # The input data does not contain the discriminator property. - path_to_item = kwargs.get("_path_to_item", ()) + path_to_item = kwargs.get('_path_to_item', ()) raise ApiValueError( "Cannot deserialize input data due to missing discriminator. " - "The discriminator property '%s' is missing at path: %s" % (discr_propertyname_js, path_to_item) + "The discriminator property '%s' is missing at path: %s" % + (discr_propertyname_js, path_to_item) ) # Implementation note: the last argument to get_discriminator_class # is a list of visited classes. get_discriminator_class may recursively # call itself and update the list of visited classes, and the initial # value must be an empty list. Hence not using 'visited_composed_classes' - new_cls = get_discriminator_class(cls, discr_propertyname_py, discr_value, []) + new_cls = get_discriminator_class( + cls, discr_propertyname_py, discr_value, []) if new_cls is None: - path_to_item = kwargs.get("_path_to_item", ()) - disc_prop_value = kwargs.get(discr_propertyname_js, kwargs.get(discr_propertyname_py)) + path_to_item = kwargs.get('_path_to_item', ()) + disc_prop_value = kwargs.get( + discr_propertyname_js, kwargs.get(discr_propertyname_py)) raise ApiValueError( "Cannot deserialize input data due to invalid discriminator " "value. The OpenAPI document has no mapping for discriminator " - "property '%s'='%s' at path: %s" % (discr_propertyname_js, disc_prop_value, path_to_item) + "property '%s'='%s' at path: %s" % + (discr_propertyname_js, disc_prop_value, path_to_item) ) if new_cls in visited_composed_classes: @@ -259,11 +284,13 @@ def __new__(cls, *args, **kwargs): # Build a list containing all oneOf and anyOf descendants. oneof_anyof_classes = None if cls._composed_schemas is not None: - oneof_anyof_classes = cls._composed_schemas.get("oneOf", ()) + cls._composed_schemas.get("anyOf", ()) + oneof_anyof_classes = ( + cls._composed_schemas.get('oneOf', ()) + + cls._composed_schemas.get('anyOf', ())) oneof_anyof_child = new_cls in oneof_anyof_classes - kwargs["_visited_composed_classes"] = visited_composed_classes + (cls,) + kwargs['_visited_composed_classes'] = visited_composed_classes + (cls,) - if cls._composed_schemas.get("allOf") and oneof_anyof_child: + if cls._composed_schemas.get('allOf') and oneof_anyof_child: # Validate that we can make self because when we make the # new_cls it will not include the allOf validations in self self_inst = super(OpenApiModel, cls).__new__(cls) @@ -273,6 +300,7 @@ def __new__(cls, *args, **kwargs): new_inst.__init__(*args, **kwargs) return new_inst + @classmethod @convert_js_args_to_python_args def _new_from_openapi_data(cls, *args, **kwargs): @@ -291,8 +319,12 @@ def _new_from_openapi_data(cls, *args, **kwargs): oneof_instance = get_oneof_instance(cls, model_kwargs, kwargs, model_arg=arg) return oneof_instance - visited_composed_classes = kwargs.get("_visited_composed_classes", ()) - if cls.discriminator is None or cls in visited_composed_classes: + + visited_composed_classes = kwargs.get('_visited_composed_classes', ()) + if ( + cls.discriminator is None or + cls in visited_composed_classes + ): # Use case 1: this openapi schema (cls) does not have a discriminator # Use case 2: we have already visited this class before and are sure that we # want to instantiate it this time. We have visited this class deserializing @@ -322,24 +354,28 @@ def _new_from_openapi_data(cls, *args, **kwargs): discr_value = kwargs[discr_propertyname_py] else: # The input data does not contain the discriminator property. - path_to_item = kwargs.get("_path_to_item", ()) + path_to_item = kwargs.get('_path_to_item', ()) raise ApiValueError( "Cannot deserialize input data due to missing discriminator. " - "The discriminator property '%s' is missing at path: %s" % (discr_propertyname_js, path_to_item) + "The discriminator property '%s' is missing at path: %s" % + (discr_propertyname_js, path_to_item) ) # Implementation note: the last argument to get_discriminator_class # is a list of visited classes. get_discriminator_class may recursively # call itself and update the list of visited classes, and the initial # value must be an empty list. Hence not using 'visited_composed_classes' - new_cls = get_discriminator_class(cls, discr_propertyname_py, discr_value, []) + new_cls = get_discriminator_class( + cls, discr_propertyname_py, discr_value, []) if new_cls is None: - path_to_item = kwargs.get("_path_to_item", ()) - disc_prop_value = kwargs.get(discr_propertyname_js, kwargs.get(discr_propertyname_py)) + path_to_item = kwargs.get('_path_to_item', ()) + disc_prop_value = kwargs.get( + discr_propertyname_js, kwargs.get(discr_propertyname_py)) raise ApiValueError( "Cannot deserialize input data due to invalid discriminator " "value. The OpenAPI document has no mapping for discriminator " - "property '%s'='%s' at path: %s" % (discr_propertyname_js, disc_prop_value, path_to_item) + "property '%s'='%s' at path: %s" % + (discr_propertyname_js, disc_prop_value, path_to_item) ) if new_cls in visited_composed_classes: @@ -364,15 +400,18 @@ def _new_from_openapi_data(cls, *args, **kwargs): # Build a list containing all oneOf and anyOf descendants. oneof_anyof_classes = None if cls._composed_schemas is not None: - oneof_anyof_classes = cls._composed_schemas.get("oneOf", ()) + cls._composed_schemas.get("anyOf", ()) + oneof_anyof_classes = ( + cls._composed_schemas.get('oneOf', ()) + + cls._composed_schemas.get('anyOf', ())) oneof_anyof_child = new_cls in oneof_anyof_classes - kwargs["_visited_composed_classes"] = visited_composed_classes + (cls,) + kwargs['_visited_composed_classes'] = visited_composed_classes + (cls,) - if cls._composed_schemas.get("allOf") and oneof_anyof_child: + if cls._composed_schemas.get('allOf') and oneof_anyof_child: # Validate that we can make self because when we make the # new_cls it will not include the allOf validations in self self_inst = cls._from_openapi_data(*args, **kwargs) + new_inst = new_cls._new_from_openapi_data(*args, **kwargs) return new_inst @@ -394,7 +433,7 @@ def get(self, name, default=None): if name in self.required_properties: return self.__dict__[name] - return self.__dict__["_data_store"].get(name, default) + return self.__dict__['_data_store'].get(name, default) def __getitem__(self, name): """get the value of an attribute using square-bracket notation: `instance[attr]`""" @@ -402,7 +441,9 @@ def __getitem__(self, name): return self.get(name) raise ApiAttributeError( - "{0} has no attribute '{1}'".format(type(self).__name__, name), [e for e in [self._path_to_item, name] if e] + "{0} has no attribute '{1}'".format( + type(self).__name__, name), + [e for e in [self._path_to_item, name] if e] ) def __contains__(self, name): @@ -410,7 +451,7 @@ def __contains__(self, name): if name in self.required_properties: return name in self.__dict__ - return name in self.__dict__["_data_store"] + return name in self.__dict__['_data_store'] def to_str(self): """Returns the string representation of the model""" @@ -421,8 +462,8 @@ def __eq__(self, other): if not isinstance(other, self.__class__): return False - this_val = self._data_store["value"] - that_val = other._data_store["value"] + this_val = self._data_store['value'] + that_val = other._data_store['value'] types = set() types.add(this_val.__class__) types.add(that_val.__class__) @@ -447,7 +488,7 @@ def get(self, name, default=None): if name in self.required_properties: return self.__dict__[name] - return self.__dict__["_data_store"].get(name, default) + return self.__dict__['_data_store'].get(name, default) def __getitem__(self, name): """get the value of an attribute using square-bracket notation: `instance[attr]`""" @@ -455,7 +496,9 @@ def __getitem__(self, name): return self.get(name) raise ApiAttributeError( - "{0} has no attribute '{1}'".format(type(self).__name__, name), [e for e in [self._path_to_item, name] if e] + "{0} has no attribute '{1}'".format( + type(self).__name__, name), + [e for e in [self._path_to_item, name] if e] ) def __contains__(self, name): @@ -463,7 +506,7 @@ def __contains__(self, name): if name in self.required_properties: return name in self.__dict__ - return name in self.__dict__["_data_store"] + return name in self.__dict__['_data_store'] def to_dict(self): """Returns the model properties as a dict""" @@ -548,8 +591,9 @@ def __setitem__(self, name, value): """ if name not in self.openapi_types: raise ApiAttributeError( - "{0} has no attribute '{1}'".format(type(self).__name__, name), - [e for e in [self._path_to_item, name] if e], + "{0} has no attribute '{1}'".format( + type(self).__name__, name), + [e for e in [self._path_to_item, name] if e] ) # attribute must be set on self and composed instances self.set_attribute(name, value) @@ -557,7 +601,7 @@ def __setitem__(self, name, value): setattr(model_instance, name, value) if name not in self._var_name_to_model_instances: # we assigned an additional property - self.__dict__["_var_name_to_model_instances"][name] = self._composed_instances + [self] + self.__dict__['_var_name_to_model_instances'][name] = self._composed_instances + [self] return None __unset_attribute_value__ = object() @@ -590,7 +634,7 @@ def get(self, name, default=None): "Values stored for property {0} in {1} differ when looking " "at self and self's composed instances. All values must be " "the same".format(name, type(self).__name__), - [e for e in [self._path_to_item, name] if e], + [e for e in [self._path_to_item, name] if e] ) def __getitem__(self, name): @@ -598,8 +642,9 @@ def __getitem__(self, name): value = self.get(name, self.__unset_attribute_value__) if value is self.__unset_attribute_value__: raise ApiAttributeError( - "{0} has no attribute '{1}'".format(type(self).__name__, name), - [e for e in [self._path_to_item, name] if e], + "{0} has no attribute '{1}'".format( + type(self).__name__, name), + [e for e in [self._path_to_item, name] if e] ) return value @@ -609,7 +654,8 @@ def __contains__(self, name): if name in self.required_properties: return name in self.__dict__ - model_instances = self._var_name_to_model_instances.get(name, self._additional_properties_model_instances) + model_instances = self._var_name_to_model_instances.get( + name, self._additional_properties_model_instances) if model_instances: for model_instance in model_instances: @@ -648,7 +694,7 @@ def __eq__(self, other): ModelComposed: 0, ModelNormal: 1, ModelSimple: 2, - none_type: 3, # The type of 'None'. + none_type: 3, # The type of 'None'. list: 4, dict: 5, float: 6, @@ -657,7 +703,7 @@ def __eq__(self, other): datetime: 9, date: 10, str: 11, - file_type: 12, # 'file_type' is an alias for the built-in 'file' or 'io.IOBase' type. + file_type: 12, # 'file_type' is an alias for the built-in 'file' or 'io.IOBase' type. } # these are used to limit what type conversions we try to do @@ -666,7 +712,7 @@ def __eq__(self, other): UPCONVERSION_TYPE_PAIRS = ( (str, datetime), (str, date), - (int, float), # A float may be serialized as an integer, e.g. '3' is a valid serialized float. + (int, float), # A float may be serialized as an integer, e.g. '3' is a valid serialized float. (list, ModelComposed), (dict, ModelComposed), (str, ModelComposed), @@ -713,7 +759,7 @@ def __eq__(self, other): (str, date), # (int, str), # (float, str), - (str, file_type), + (str, file_type) ), } @@ -770,22 +816,41 @@ def check_allowed_values(allowed_values, input_variable_path, input_values): are checking to see if they are in allowed_values """ these_allowed_values = list(allowed_values[input_variable_path].values()) - if isinstance(input_values, list) and not set(input_values).issubset(set(these_allowed_values)): - invalid_values = (", ".join(map(str, set(input_values) - set(these_allowed_values))),) + if (isinstance(input_values, list) + and not set(input_values).issubset( + set(these_allowed_values))): + invalid_values = ", ".join( + map(str, set(input_values) - set(these_allowed_values))), raise ApiValueError( - "Invalid values for `%s` [%s], must be a subset of [%s]" - % (input_variable_path[0], invalid_values, ", ".join(map(str, these_allowed_values))) + "Invalid values for `%s` [%s], must be a subset of [%s]" % + ( + input_variable_path[0], + invalid_values, + ", ".join(map(str, these_allowed_values)) + ) ) - elif isinstance(input_values, dict) and not set(input_values.keys()).issubset(set(these_allowed_values)): - invalid_values = ", ".join(map(str, set(input_values.keys()) - set(these_allowed_values))) + elif (isinstance(input_values, dict) + and not set( + input_values.keys()).issubset(set(these_allowed_values))): + invalid_values = ", ".join( + map(str, set(input_values.keys()) - set(these_allowed_values))) raise ApiValueError( - "Invalid keys in `%s` [%s], must be a subset of [%s]" - % (input_variable_path[0], invalid_values, ", ".join(map(str, these_allowed_values))) + "Invalid keys in `%s` [%s], must be a subset of [%s]" % + ( + input_variable_path[0], + invalid_values, + ", ".join(map(str, these_allowed_values)) + ) ) - elif not isinstance(input_values, (list, dict)) and input_values not in these_allowed_values: + elif (not isinstance(input_values, (list, dict)) + and input_values not in these_allowed_values): raise ApiValueError( - "Invalid value for `%s` (%s), must be one of %s" - % (input_variable_path[0], input_values, these_allowed_values) + "Invalid value for `%s` (%s), must be one of %s" % + ( + input_variable_path[0], + input_values, + these_allowed_values + ) ) @@ -799,14 +864,14 @@ def is_json_validation_enabled(schema_keyword, configuration=None): configuration (Configuration): the configuration class. """ - return ( - configuration is None - or not hasattr(configuration, "_disabled_client_side_validations") - or schema_keyword not in configuration._disabled_client_side_validations - ) + return (configuration is None or + not hasattr(configuration, '_disabled_client_side_validations') or + schema_keyword not in configuration._disabled_client_side_validations) -def check_validations(validations, input_variable_path, input_values, configuration=None): +def check_validations( + validations, input_variable_path, input_values, + configuration=None): """Raises an exception if the input_values are invalid Args: @@ -821,60 +886,66 @@ def check_validations(validations, input_variable_path, input_values, configurat return current_validations = validations[input_variable_path] - if ( - is_json_validation_enabled("multipleOf", configuration) - and "multiple_of" in current_validations - and isinstance(input_values, (int, float)) - and not (float(input_values) / current_validations["multiple_of"]).is_integer() - ): + if (is_json_validation_enabled('multipleOf', configuration) and + 'multiple_of' in current_validations and + isinstance(input_values, (int, float)) and + not (float(input_values) / current_validations['multiple_of']).is_integer()): # Note 'multipleOf' will be as good as the floating point arithmetic. raise ApiValueError( "Invalid value for `%s`, value must be a multiple of " - "`%s`" % (input_variable_path[0], current_validations["multiple_of"]) + "`%s`" % ( + input_variable_path[0], + current_validations['multiple_of'] + ) ) - if ( - is_json_validation_enabled("maxLength", configuration) - and "max_length" in current_validations - and len(input_values) > current_validations["max_length"] - ): + if (is_json_validation_enabled('maxLength', configuration) and + 'max_length' in current_validations and + len(input_values) > current_validations['max_length']): raise ApiValueError( "Invalid value for `%s`, length must be less than or equal to " - "`%s`" % (input_variable_path[0], current_validations["max_length"]) + "`%s`" % ( + input_variable_path[0], + current_validations['max_length'] + ) ) - if ( - is_json_validation_enabled("minLength", configuration) - and "min_length" in current_validations - and len(input_values) < current_validations["min_length"] - ): + if (is_json_validation_enabled('minLength', configuration) and + 'min_length' in current_validations and + len(input_values) < current_validations['min_length']): raise ApiValueError( "Invalid value for `%s`, length must be greater than or equal to " - "`%s`" % (input_variable_path[0], current_validations["min_length"]) + "`%s`" % ( + input_variable_path[0], + current_validations['min_length'] + ) ) - if ( - is_json_validation_enabled("maxItems", configuration) - and "max_items" in current_validations - and len(input_values) > current_validations["max_items"] - ): + if (is_json_validation_enabled('maxItems', configuration) and + 'max_items' in current_validations and + len(input_values) > current_validations['max_items']): raise ApiValueError( "Invalid value for `%s`, number of items must be less than or " - "equal to `%s`" % (input_variable_path[0], current_validations["max_items"]) + "equal to `%s`" % ( + input_variable_path[0], + current_validations['max_items'] + ) ) - if ( - is_json_validation_enabled("minItems", configuration) - and "min_items" in current_validations - and len(input_values) < current_validations["min_items"] - ): + if (is_json_validation_enabled('minItems', configuration) and + 'min_items' in current_validations and + len(input_values) < current_validations['min_items']): raise ValueError( "Invalid value for `%s`, number of items must be greater than or " - "equal to `%s`" % (input_variable_path[0], current_validations["min_items"]) + "equal to `%s`" % ( + input_variable_path[0], + current_validations['min_items'] + ) ) - items = ("exclusive_maximum", "inclusive_maximum", "exclusive_minimum", "inclusive_minimum") - if any(item in current_validations for item in items): + items = ('exclusive_maximum', 'inclusive_maximum', 'exclusive_minimum', + 'inclusive_minimum') + if (any(item in current_validations for item in items)): if isinstance(input_values, list): max_val = max(input_values) min_val = min(input_values) @@ -885,55 +956,57 @@ def check_validations(validations, input_variable_path, input_values, configurat max_val = input_values min_val = input_values - if ( - is_json_validation_enabled("exclusiveMaximum", configuration) - and "exclusive_maximum" in current_validations - and max_val >= current_validations["exclusive_maximum"] - ): + if (is_json_validation_enabled('exclusiveMaximum', configuration) and + 'exclusive_maximum' in current_validations and + max_val >= current_validations['exclusive_maximum']): raise ApiValueError( - "Invalid value for `%s`, must be a value less than `%s`" - % (input_variable_path[0], current_validations["exclusive_maximum"]) + "Invalid value for `%s`, must be a value less than `%s`" % ( + input_variable_path[0], + current_validations['exclusive_maximum'] + ) ) - if ( - is_json_validation_enabled("maximum", configuration) - and "inclusive_maximum" in current_validations - and max_val > current_validations["inclusive_maximum"] - ): + if (is_json_validation_enabled('maximum', configuration) and + 'inclusive_maximum' in current_validations and + max_val > current_validations['inclusive_maximum']): raise ApiValueError( "Invalid value for `%s`, must be a value less than or equal to " - "`%s`" % (input_variable_path[0], current_validations["inclusive_maximum"]) + "`%s`" % ( + input_variable_path[0], + current_validations['inclusive_maximum'] + ) ) - if ( - is_json_validation_enabled("exclusiveMinimum", configuration) - and "exclusive_minimum" in current_validations - and min_val <= current_validations["exclusive_minimum"] - ): + if (is_json_validation_enabled('exclusiveMinimum', configuration) and + 'exclusive_minimum' in current_validations and + min_val <= current_validations['exclusive_minimum']): raise ApiValueError( - "Invalid value for `%s`, must be a value greater than `%s`" - % (input_variable_path[0], current_validations["exclusive_maximum"]) + "Invalid value for `%s`, must be a value greater than `%s`" % + ( + input_variable_path[0], + current_validations['exclusive_maximum'] + ) ) - if ( - is_json_validation_enabled("minimum", configuration) - and "inclusive_minimum" in current_validations - and min_val < current_validations["inclusive_minimum"] - ): + if (is_json_validation_enabled('minimum', configuration) and + 'inclusive_minimum' in current_validations and + min_val < current_validations['inclusive_minimum']): raise ApiValueError( "Invalid value for `%s`, must be a value greater than or equal " - "to `%s`" % (input_variable_path[0], current_validations["inclusive_minimum"]) + "to `%s`" % ( + input_variable_path[0], + current_validations['inclusive_minimum'] + ) ) - flags = current_validations.get("regex", {}).get("flags", 0) - if ( - is_json_validation_enabled("pattern", configuration) - and "regex" in current_validations - and not re.search(current_validations["regex"]["pattern"], input_values, flags=flags) - ): + flags = current_validations.get('regex', {}).get('flags', 0) + if (is_json_validation_enabled('pattern', configuration) and + 'regex' in current_validations and + not re.search(current_validations['regex']['pattern'], + input_values, flags=flags)): err_msg = r"Invalid value for `%s`, must match regular expression `%s`" % ( - input_variable_path[0], - current_validations["regex"]["pattern"], - ) + input_variable_path[0], + current_validations['regex']['pattern'] + ) if flags != 0: # Don't print the regex flags if the flags are not # specified in the OAS document. @@ -958,21 +1031,28 @@ def index_getter(class_or_instance): return COERCION_INDEX_BY_TYPE[list] elif isinstance(class_or_instance, dict): return COERCION_INDEX_BY_TYPE[dict] - elif inspect.isclass(class_or_instance) and issubclass(class_or_instance, ModelComposed): + elif (inspect.isclass(class_or_instance) + and issubclass(class_or_instance, ModelComposed)): return COERCION_INDEX_BY_TYPE[ModelComposed] - elif inspect.isclass(class_or_instance) and issubclass(class_or_instance, ModelNormal): + elif (inspect.isclass(class_or_instance) + and issubclass(class_or_instance, ModelNormal)): return COERCION_INDEX_BY_TYPE[ModelNormal] - elif inspect.isclass(class_or_instance) and issubclass(class_or_instance, ModelSimple): + elif (inspect.isclass(class_or_instance) + and issubclass(class_or_instance, ModelSimple)): return COERCION_INDEX_BY_TYPE[ModelSimple] elif class_or_instance in COERCION_INDEX_BY_TYPE: return COERCION_INDEX_BY_TYPE[class_or_instance] raise ApiValueError("Unsupported type: %s" % class_or_instance) - sorted_types = sorted(required_types, key=lambda class_or_instance: index_getter(class_or_instance)) + sorted_types = sorted( + required_types, + key=lambda class_or_instance: index_getter(class_or_instance) + ) return sorted_types -def remove_uncoercible(required_types_classes, current_item, spec_property_naming, must_convert=True): +def remove_uncoercible(required_types_classes, current_item, spec_property_naming, + must_convert=True): """Only keeps the type conversions that are possible Args: @@ -1017,7 +1097,6 @@ def remove_uncoercible(required_types_classes, current_item, spec_property_namin results_classes.append(required_type_class) return results_classes - def get_discriminated_classes(cls): """ Returns all the classes that a discriminator converts to @@ -1028,7 +1107,7 @@ def get_discriminated_classes(cls): if is_type_nullable(cls): possible_classes.append(cls) for discr_cls in cls.discriminator[key].values(): - if hasattr(discr_cls, "discriminator") and discr_cls.discriminator is not None: + if hasattr(discr_cls, 'discriminator') and discr_cls.discriminator is not None: possible_classes.extend(get_discriminated_classes(discr_cls)) else: possible_classes.append(discr_cls) @@ -1040,7 +1119,7 @@ def get_possible_classes(cls, from_server_context): possible_classes = [cls] if from_server_context: return possible_classes - if hasattr(cls, "discriminator") and cls.discriminator is not None: + if hasattr(cls, 'discriminator') and cls.discriminator is not None: possible_classes = [] possible_classes.extend(get_discriminated_classes(cls)) elif issubclass(cls, ModelComposed): @@ -1096,10 +1175,11 @@ def change_keys_js_to_python(input_dict, model_class): document). """ - if getattr(model_class, "attribute_map", None) is None: + if getattr(model_class, 'attribute_map', None) is None: return input_dict output_dict = {} - reversed_attr_map = {value: key for key, value in model_class.attribute_map.items()} + reversed_attr_map = {value: key for key, value in + model_class.attribute_map.items()} for javascript_key, value in input_dict.items(): python_key = reversed_attr_map.get(javascript_key) if python_key is None: @@ -1112,9 +1192,17 @@ def change_keys_js_to_python(input_dict, model_class): def get_type_error(var_value, path_to_item, valid_classes, key_type=False): error_msg = type_error_message( - var_name=path_to_item[-1], var_value=var_value, valid_classes=valid_classes, key_type=key_type + var_name=path_to_item[-1], + var_value=var_value, + valid_classes=valid_classes, + key_type=key_type + ) + return ApiTypeError( + error_msg, + path_to_item=path_to_item, + valid_classes=valid_classes, + key_type=key_type ) - return ApiTypeError(error_msg, path_to_item=path_to_item, valid_classes=valid_classes, key_type=key_type) def deserialize_primitive(data, klass, path_to_item): @@ -1139,11 +1227,11 @@ def deserialize_primitive(data, klass, path_to_item): # The string should be in iso8601 datetime format. parsed_datetime = parse(data) date_only = ( - parsed_datetime.hour == 0 - and parsed_datetime.minute == 0 - and parsed_datetime.second == 0 - and parsed_datetime.tzinfo is None - and 8 <= len(data) <= 10 + parsed_datetime.hour == 0 and + parsed_datetime.minute == 0 and + parsed_datetime.second == 0 and + parsed_datetime.tzinfo is None and + 8 <= len(data) <= 10 ) if date_only: raise ValueError("This is a date, not a datetime") @@ -1157,17 +1245,21 @@ def deserialize_primitive(data, klass, path_to_item): if isinstance(data, str) and klass == float: if str(converted_value) != data: # '7' -> 7.0 -> '7.0' != '7' - raise ValueError("This is not a float") + raise ValueError('This is not a float') return converted_value except (OverflowError, ValueError) as ex: # parse can raise OverflowError raise ApiValueError( - "{0}Failed to parse {1} as {2}".format(additional_message, repr(data), klass.__name__), - path_to_item=path_to_item, + "{0}Failed to parse {1} as {2}".format( + additional_message, repr(data), klass.__name__ + ), + path_to_item=path_to_item ) from ex -def get_discriminator_class(model_class, discr_name, discr_value, cls_visited): +def get_discriminator_class(model_class, + discr_name, + discr_value, cls_visited): """Returns the child class specified by the discriminator. Args: @@ -1203,21 +1295,22 @@ def get_discriminator_class(model_class, discr_name, discr_value, cls_visited): # Descendant example: mammal -> whale/zebra/Pig -> BasquePig/DanishPig # if we try to make BasquePig from mammal, we need to travel through # the oneOf descendant discriminators to find BasquePig - descendant_classes = model_class._composed_schemas.get("oneOf", ()) + model_class._composed_schemas.get( - "anyOf", () - ) - ancestor_classes = model_class._composed_schemas.get("allOf", ()) + descendant_classes = model_class._composed_schemas.get('oneOf', ()) + \ + model_class._composed_schemas.get('anyOf', ()) + ancestor_classes = model_class._composed_schemas.get('allOf', ()) possible_classes = descendant_classes + ancestor_classes for cls in possible_classes: # Check if the schema has inherited discriminators. - if hasattr(cls, "discriminator") and cls.discriminator is not None: - used_model_class = get_discriminator_class(cls, discr_name, discr_value, cls_visited) + if hasattr(cls, 'discriminator') and cls.discriminator is not None: + used_model_class = get_discriminator_class( + cls, discr_name, discr_value, cls_visited) if used_model_class is not None: return used_model_class return used_model_class -def deserialize_model(model_data, model_class, path_to_item, check_type, configuration, spec_property_naming): +def deserialize_model(model_data, model_class, path_to_item, check_type, + configuration, spec_property_naming): """Deserializes model_data to model instance. Args: @@ -1241,12 +1334,10 @@ def deserialize_model(model_data, model_class, path_to_item, check_type, configu ApiKeyError """ - kw_args = dict( - _check_type=check_type, - _path_to_item=path_to_item, - _configuration=configuration, - _spec_property_naming=spec_property_naming, - ) + kw_args = dict(_check_type=check_type, + _path_to_item=path_to_item, + _configuration=configuration, + _spec_property_naming=spec_property_naming) if issubclass(model_class, ModelSimple): return model_class._new_from_openapi_data(model_data, **kw_args) @@ -1282,29 +1373,23 @@ def deserialize_file(response_data, configuration, content_disposition=None): os.remove(path) if content_disposition: - filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', content_disposition).group(1) + filename = re.search(r'filename=[\'"]?([^\'"\s]+)[\'"]?', + content_disposition).group(1) path = os.path.join(os.path.dirname(path), filename) with open(path, "wb") as f: if isinstance(response_data, str): # change str to bytes so we can write it - response_data = response_data.encode("utf-8") + response_data = response_data.encode('utf-8') f.write(response_data) f = open(path, "rb") return f -def attempt_convert_item( - input_value, - valid_classes, - path_to_item, - configuration, - spec_property_naming, - key_type=False, - must_convert=False, - check_type=True, -): +def attempt_convert_item(input_value, valid_classes, path_to_item, + configuration, spec_property_naming, key_type=False, + must_convert=False, check_type=True): """ Args: input_value (any): the data to convert @@ -1329,21 +1414,24 @@ def attempt_convert_item( ApiKeyError """ valid_classes_ordered = order_response_types(valid_classes) - valid_classes_coercible = remove_uncoercible(valid_classes_ordered, input_value, spec_property_naming) + valid_classes_coercible = remove_uncoercible( + valid_classes_ordered, input_value, spec_property_naming) if not valid_classes_coercible or key_type: # we do not handle keytype errors, json will take care # of this for us if configuration is None or not configuration.discard_unknown_keys: - raise get_type_error(input_value, path_to_item, valid_classes, key_type=key_type) + raise get_type_error(input_value, path_to_item, valid_classes, + key_type=key_type) for valid_class in valid_classes_coercible: try: if issubclass(valid_class, OpenApiModel): - return deserialize_model( - input_value, valid_class, path_to_item, check_type, configuration, spec_property_naming - ) + return deserialize_model(input_value, valid_class, + path_to_item, check_type, + configuration, spec_property_naming) elif valid_class == file_type: return deserialize_file(input_value, configuration) - return deserialize_primitive(input_value, valid_class, path_to_item) + return deserialize_primitive(input_value, valid_class, + path_to_item) except (ApiTypeError, ApiValueError, ApiKeyError) as conversion_exc: if must_convert: raise conversion_exc @@ -1375,12 +1463,10 @@ def is_type_nullable(input_type): return True if issubclass(input_type, ModelComposed): # If oneOf/anyOf, check if the 'null' type is one of the allowed types. - for t in input_type._composed_schemas.get("oneOf", ()): - if is_type_nullable(t): - return True - for t in input_type._composed_schemas.get("anyOf", ()): - if is_type_nullable(t): - return True + for t in input_type._composed_schemas.get('oneOf', ()): + if is_type_nullable(t): return True + for t in input_type._composed_schemas.get('anyOf', ()): + if is_type_nullable(t): return True return False @@ -1395,7 +1481,9 @@ def is_valid_type(input_class_simple, valid_classes): bool """ valid_type = input_class_simple in valid_classes - if not valid_type and (issubclass(input_class_simple, OpenApiModel) or input_class_simple is none_type): + if not valid_type and ( + issubclass(input_class_simple, OpenApiModel) or + input_class_simple is none_type): for valid_class in valid_classes: if input_class_simple is none_type and is_type_nullable(valid_class): # Schema is oneOf/anyOf and the 'null' type is one of the allowed types. @@ -1403,16 +1491,17 @@ def is_valid_type(input_class_simple, valid_classes): if not (issubclass(valid_class, OpenApiModel) and valid_class.discriminator): continue discr_propertyname_py = list(valid_class.discriminator.keys())[0] - discriminator_classes = valid_class.discriminator[discr_propertyname_py].values() + discriminator_classes = ( + valid_class.discriminator[discr_propertyname_py].values() + ) valid_type = is_valid_type(input_class_simple, discriminator_classes) if valid_type: return True return valid_type -def validate_and_convert_types( - input_value, required_types_mixed, path_to_item, spec_property_naming, _check_type, configuration=None -): +def validate_and_convert_types(input_value, required_types_mixed, path_to_item, + spec_property_naming, _check_type, configuration=None): """Raises a TypeError is there is a problem, otherwise returns value Args: @@ -1457,18 +1546,18 @@ def validate_and_convert_types( spec_property_naming, key_type=False, must_convert=True, - check_type=_check_type, + check_type=_check_type ) return converted_instance else: - raise get_type_error(input_value, path_to_item, valid_classes, key_type=False) + raise get_type_error(input_value, path_to_item, valid_classes, + key_type=False) # input_value's type is in valid_classes if len(valid_classes) > 1 and configuration: # there are valid classes which are not the current class valid_classes_coercible = remove_uncoercible( - valid_classes, input_value, spec_property_naming, must_convert=False - ) + valid_classes, input_value, spec_property_naming, must_convert=False) if valid_classes_coercible: converted_instance = attempt_convert_item( input_value, @@ -1478,7 +1567,7 @@ def validate_and_convert_types( spec_property_naming, key_type=False, must_convert=False, - check_type=_check_type, + check_type=_check_type ) return converted_instance @@ -1486,7 +1575,9 @@ def validate_and_convert_types( # all types are of the required types and there are no more inner # variables left to look at return input_value - inner_required_types = child_req_types_by_current_type.get(type(input_value)) + inner_required_types = child_req_types_by_current_type.get( + type(input_value) + ) if inner_required_types is None: # for this type, there are not more inner variables left to look at return input_value @@ -1503,7 +1594,7 @@ def validate_and_convert_types( inner_path, spec_property_naming, _check_type, - configuration=configuration, + configuration=configuration ) elif isinstance(input_value, dict): if input_value == {}: @@ -1513,14 +1604,15 @@ def validate_and_convert_types( inner_path = list(path_to_item) inner_path.append(inner_key) if get_simple_class(inner_key) != str: - raise get_type_error(inner_key, inner_path, valid_classes, key_type=True) + raise get_type_error(inner_key, inner_path, valid_classes, + key_type=True) input_value[inner_key] = validate_and_convert_types( inner_val, inner_required_types, inner_path, spec_property_naming, _check_type, - configuration=configuration, + configuration=configuration ) return input_value @@ -1556,31 +1648,29 @@ def model_to_dict(model_instance, serialize=True): except KeyError: used_fallback_python_attribute_names.add(attr) if isinstance(value, list): - if not value: - # empty list or None - result[attr] = value - else: - res = [] - for v in value: - if isinstance(v, PRIMITIVE_TYPES) or v is None: - res.append(v) - elif isinstance(v, ModelSimple): - res.append(v.value) - else: - res.append(model_to_dict(v, serialize=serialize)) - result[attr] = res + if not value: + # empty list or None + result[attr] = value + else: + res = [] + for v in value: + if isinstance(v, PRIMITIVE_TYPES) or v is None: + res.append(v) + elif isinstance(v, ModelSimple): + res.append(v.value) + else: + res.append(model_to_dict(v, serialize=serialize)) + result[attr] = res elif isinstance(value, dict): - result[attr] = dict( - map( - lambda item: (item[0], model_to_dict(item[1], serialize=serialize)) - if hasattr(item[1], "_data_store") - else item, - value.items(), - ) - ) + result[attr] = dict(map( + lambda item: (item[0], + model_to_dict(item[1], serialize=serialize)) + if hasattr(item[1], '_data_store') else item, + value.items() + )) elif isinstance(value, ModelSimple): result[attr] = value.value - elif hasattr(value, "_data_store"): + elif hasattr(value, '_data_store'): result[attr] = model_to_dict(value, serialize=serialize) else: result[attr] = value @@ -1598,7 +1688,8 @@ def model_to_dict(model_instance, serialize=True): return result -def type_error_message(var_value=None, var_name=None, valid_classes=None, key_type=None): +def type_error_message(var_value=None, var_name=None, valid_classes=None, + key_type=None): """ Keyword Args: var_value (any): the variable which has the type_error @@ -1609,26 +1700,30 @@ def type_error_message(var_value=None, var_name=None, valid_classes=None, key_ty True if it is a key in a dict False if our item is an item in a list """ - key_or_value = "value" + key_or_value = 'value' if key_type: - key_or_value = "key" + key_or_value = 'key' valid_classes_phrase = get_valid_classes_phrase(valid_classes) - msg = "Invalid type for variable '{0}'. Required {1} type {2} and " "passed type was {3}".format( - var_name, - key_or_value, - valid_classes_phrase, - type(var_value).__name__, + msg = ( + "Invalid type for variable '{0}'. Required {1} type {2} and " + "passed type was {3}".format( + var_name, + key_or_value, + valid_classes_phrase, + type(var_value).__name__, + ) ) return msg def get_valid_classes_phrase(input_classes): - """Returns a string phrase describing what types are allowed""" + """Returns a string phrase describing what types are allowed + """ all_classes = list(input_classes) all_classes = sorted(all_classes, key=lambda cls: cls.__name__) all_class_names = [cls.__name__ for cls in all_classes] if len(all_class_names) == 1: - return "is {0}".format(all_class_names[0]) + return 'is {0}'.format(all_class_names[0]) return "is one of [{0}]".format(", ".join(all_class_names)) @@ -1650,7 +1745,8 @@ def get_allof_instances(self, model_args, constant_args): composed_instances (list) """ composed_instances = [] - for allof_class in self._composed_schemas["allOf"]: + for allof_class in self._composed_schemas['allOf']: + try: allof_instance = allof_class(**model_args, **constant_args) composed_instances.append(allof_instance) @@ -1658,7 +1754,12 @@ def get_allof_instances(self, model_args, constant_args): raise ApiValueError( "Invalid inputs given to generate an instance of '%s'. The " "input data was invalid for the allOf schema '%s' in the composed " - "schema '%s'. Error=%s" % (allof_class.__name__, allof_class.__name__, self.__class__.__name__, str(ex)) + "schema '%s'. Error=%s" % ( + allof_class.__name__, + allof_class.__name__, + self.__class__.__name__, + str(ex) + ) ) from ex return composed_instances @@ -1691,13 +1792,13 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None): Returns oneof_instance (instance) """ - if len(cls._composed_schemas["oneOf"]) == 0: + if len(cls._composed_schemas['oneOf']) == 0: return None oneof_instances = [] # Iterate over each oneOf schema and determine if the input data # matches the oneOf schemas. - for oneof_class in cls._composed_schemas["oneOf"]: + for oneof_class in cls._composed_schemas['oneOf']: # The composed oneOf schema allows the 'null' type and the input data # is the null value. This is a OAS >= 3.1 feature. if oneof_class is none_type: @@ -1717,10 +1818,10 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None): oneof_instance = validate_and_convert_types( model_arg, (oneof_class,), - constant_kwargs["_path_to_item"], - constant_kwargs["_spec_property_naming"], - constant_kwargs["_check_type"], - configuration=constant_kwargs["_configuration"], + constant_kwargs['_path_to_item'], + constant_kwargs['_spec_property_naming'], + constant_kwargs['_check_type'], + configuration=constant_kwargs['_configuration'] ) oneof_instances.append(oneof_instance) except Exception: @@ -1728,12 +1829,14 @@ def get_oneof_instance(cls, model_kwargs, constant_kwargs, model_arg=None): if len(oneof_instances) == 0: raise ApiValueError( "Invalid inputs given to generate an instance of %s. None " - "of the oneOf schemas matched the input data." % cls.__name__ + "of the oneOf schemas matched the input data." % + cls.__name__ ) elif len(oneof_instances) > 1: raise ApiValueError( "Invalid inputs given to generate an instance of %s. Multiple " - "oneOf schemas matched the inputs, but a max of one is allowed." % cls.__name__ + "oneOf schemas matched the inputs, but a max of one is allowed." % + cls.__name__ ) return oneof_instances[0] @@ -1753,10 +1856,10 @@ def get_anyof_instances(self, model_args, constant_args): anyof_instances (list) """ anyof_instances = [] - if len(self._composed_schemas["anyOf"]) == 0: + if len(self._composed_schemas['anyOf']) == 0: return anyof_instances - for anyof_class in self._composed_schemas["anyOf"]: + for anyof_class in self._composed_schemas['anyOf']: # The composed oneOf schema allows the 'null' type and the input data # is the null value. This is a OAS >= 3.1 feature. if anyof_class is none_type: @@ -1772,7 +1875,8 @@ def get_anyof_instances(self, model_args, constant_args): if len(anyof_instances) == 0: raise ApiValueError( "Invalid inputs given to generate an instance of %s. None of the " - "anyOf schemas matched the inputs." % self.__class__.__name__ + "anyOf schemas matched the inputs." % + self.__class__.__name__ ) return anyof_instances @@ -1786,7 +1890,7 @@ def get_discarded_args(self, composed_instances, model_args): # arguments passed to self were already converted to python names # before __init__ was called for instance in composed_instances: - if instance.__class__ in self._composed_schemas["allOf"]: + if instance.__class__ in self._composed_schemas['allOf']: try: keys = instance.to_dict().keys() discarded_keys = model_args - keys @@ -1881,4 +1985,9 @@ def validate_get_composed_info(constant_args, model_args, self): if prop_name not in discarded_args: var_name_to_model_instances[prop_name] = [self] + composed_instances - return [composed_instances, var_name_to_model_instances, additional_properties_model_instances, discarded_args] + return [ + composed_instances, + var_name_to_model_instances, + additional_properties_model_instances, + discarded_args + ] diff --git a/pinecone/core/client/models/__init__.py b/pinecone/core/client/models/__init__.py index 23c7ef034..5c2079103 100644 --- a/pinecone/core/client/models/__init__.py +++ b/pinecone/core/client/models/__init__.py @@ -20,7 +20,7 @@ from pinecone.core.client.model.hnsw_config import HnswConfig from pinecone.core.client.model.index_meta import IndexMeta from pinecone.core.client.model.index_meta_database import IndexMetaDatabase -from pinecone.core.client.model.index_meta_database_status import IndexMetaDatabaseStatus +from pinecone.core.client.model.index_meta_status import IndexMetaStatus from pinecone.core.client.model.namespace_summary import NamespaceSummary from pinecone.core.client.model.patch_request import PatchRequest from pinecone.core.client.model.protobuf_any import ProtobufAny diff --git a/pinecone/core/client/rest.py b/pinecone/core/client/rest.py index b986712be..8a9aafcb6 100644 --- a/pinecone/core/client/rest.py +++ b/pinecone/core/client/rest.py @@ -18,20 +18,14 @@ import urllib3 -from pinecone.core.client.exceptions import ( - ApiException, - UnauthorizedException, - ForbiddenException, - NotFoundException, - ServiceException, - ApiValueError, -) +from pinecone.core.client.exceptions import ApiException, UnauthorizedException, ForbiddenException, NotFoundException, ServiceException, ApiValueError logger = logging.getLogger(__name__) class RESTResponse(io.IOBase): + def __init__(self, resp): self.urllib3_response = resp self.status = resp.status @@ -40,7 +34,7 @@ def __init__(self, resp): def getheaders(self): """Returns a dictionary of the response headers.""" - return self.urllib3_response.headers + return self.urllib3_response.getheaders() def getheader(self, name, default=None): """Returns a given response header.""" @@ -48,6 +42,7 @@ def getheader(self, name, default=None): class RESTClientObject(object): + def __init__(self, configuration, pools_size=4, maxsize=None): # urllib3.PoolManager will pass all kw parameters to connectionpool # https://github.com/shazow/urllib3/blob/f9409436f83aeb79fbaf090181cd81b784f1b8ce/urllib3/poolmanager.py#L75 # noqa: E501 @@ -63,13 +58,13 @@ def __init__(self, configuration, pools_size=4, maxsize=None): addition_pool_args = {} if configuration.assert_hostname is not None: - addition_pool_args["assert_hostname"] = configuration.assert_hostname # noqa: E501 + addition_pool_args['assert_hostname'] = configuration.assert_hostname # noqa: E501 if configuration.retries is not None: - addition_pool_args["retries"] = configuration.retries + addition_pool_args['retries'] = configuration.retries if configuration.socket_options is not None: - addition_pool_args["socket_options"] = configuration.socket_options + addition_pool_args['socket_options'] = configuration.socket_options if maxsize is None: if configuration.connection_pool_maxsize is not None: @@ -101,17 +96,9 @@ def __init__(self, configuration, pools_size=4, maxsize=None): **addition_pool_args ) - def request( - self, - method, - url, - query_params=None, - headers=None, - body=None, - post_params=None, - _preload_content=True, - _request_timeout=None, - ): + def request(self, method, url, query_params=None, headers=None, + body=None, post_params=None, _preload_content=True, + _request_timeout=None): """Perform requests. :param method: http request method @@ -131,10 +118,13 @@ def request( (connection, read) timeouts. """ method = method.upper() - assert method in ["GET", "HEAD", "DELETE", "POST", "PUT", "PATCH", "OPTIONS"] + assert method in ['GET', 'HEAD', 'DELETE', 'POST', 'PUT', + 'PATCH', 'OPTIONS'] if post_params and body: - raise ApiValueError("body parameter cannot be used with post_params parameter.") + raise ApiValueError( + "body parameter cannot be used with post_params parameter." + ) post_params = post_params or {} headers = headers or {} @@ -143,66 +133,60 @@ def request( if _request_timeout: if isinstance(_request_timeout, (int, float)): # noqa: E501,F821 timeout = urllib3.Timeout(total=_request_timeout) - elif isinstance(_request_timeout, tuple) and len(_request_timeout) == 2: - timeout = urllib3.Timeout(connect=_request_timeout[0], read=_request_timeout[1]) + elif (isinstance(_request_timeout, tuple) and + len(_request_timeout) == 2): + timeout = urllib3.Timeout( + connect=_request_timeout[0], read=_request_timeout[1]) try: # For `POST`, `PUT`, `PATCH`, `OPTIONS`, `DELETE` - if method in ["POST", "PUT", "PATCH", "OPTIONS", "DELETE"]: + if method in ['POST', 'PUT', 'PATCH', 'OPTIONS', 'DELETE']: # Only set a default Content-Type for POST, PUT, PATCH and OPTIONS requests - if (method != "DELETE") and ("Content-Type" not in headers): - headers["Content-Type"] = "application/json" + if (method != 'DELETE') and ('Content-Type' not in headers): + headers['Content-Type'] = 'application/json' if query_params: - url += "?" + urlencode(query_params) - if ("Content-Type" not in headers) or (re.search("json", headers["Content-Type"], re.IGNORECASE)): + url += '?' + urlencode(query_params) + if ('Content-Type' not in headers) or (re.search('json', headers['Content-Type'], re.IGNORECASE)): request_body = None if body is not None: request_body = json.dumps(body) r = self.pool_manager.request( - method, - url, + method, url, body=request_body, preload_content=_preload_content, timeout=timeout, - headers=headers, - ) - elif headers["Content-Type"] == "application/x-www-form-urlencoded": # noqa: E501 + headers=headers) + elif headers['Content-Type'] == 'application/x-www-form-urlencoded': # noqa: E501 r = self.pool_manager.request( - method, - url, + method, url, fields=post_params, encode_multipart=False, preload_content=_preload_content, timeout=timeout, - headers=headers, - ) - elif headers["Content-Type"] == "multipart/form-data": + headers=headers) + elif headers['Content-Type'] == 'multipart/form-data': # must del headers['Content-Type'], or the correct # Content-Type which generated by urllib3 will be # overwritten. - del headers["Content-Type"] + del headers['Content-Type'] r = self.pool_manager.request( - method, - url, + method, url, fields=post_params, encode_multipart=True, preload_content=_preload_content, timeout=timeout, - headers=headers, - ) + headers=headers) # Pass a `string` parameter directly in the body to support # other content types than Json when `body` argument is # provided in serialized form elif isinstance(body, str) or isinstance(body, bytes): request_body = body r = self.pool_manager.request( - method, - url, + method, url, body=request_body, preload_content=_preload_content, timeout=timeout, - headers=headers, - ) + headers=headers) else: # Cannot generate the request from given parameters msg = """Cannot prepare a request message for provided @@ -211,9 +195,11 @@ def request( raise ApiException(status=0, reason=msg) # For `GET`, `HEAD` else: - r = self.pool_manager.request( - method, url, fields=query_params, preload_content=_preload_content, timeout=timeout, headers=headers - ) + r = self.pool_manager.request(method, url, + fields=query_params, + preload_content=_preload_content, + timeout=timeout, + headers=headers) except urllib3.exceptions.SSLError as e: msg = "{0}\n{1}".format(type(e).__name__, str(e)) raise ApiException(status=0, reason=msg) @@ -241,117 +227,67 @@ def request( return r - def GET(self, url, headers=None, query_params=None, _preload_content=True, _request_timeout=None): - return self.request( - "GET", - url, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - query_params=query_params, - ) - - def HEAD(self, url, headers=None, query_params=None, _preload_content=True, _request_timeout=None): - return self.request( - "HEAD", - url, - headers=headers, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - query_params=query_params, - ) - - def OPTIONS( - self, - url, - headers=None, - query_params=None, - post_params=None, - body=None, - _preload_content=True, - _request_timeout=None, - ): - return self.request( - "OPTIONS", - url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) - - def DELETE(self, url, headers=None, query_params=None, body=None, _preload_content=True, _request_timeout=None): - return self.request( - "DELETE", - url, - headers=headers, - query_params=query_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) - - def POST( - self, - url, - headers=None, - query_params=None, - post_params=None, - body=None, - _preload_content=True, - _request_timeout=None, - ): - return self.request( - "POST", - url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) - - def PUT( - self, - url, - headers=None, - query_params=None, - post_params=None, - body=None, - _preload_content=True, - _request_timeout=None, - ): - return self.request( - "PUT", - url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) - - def PATCH( - self, - url, - headers=None, - query_params=None, - post_params=None, - body=None, - _preload_content=True, - _request_timeout=None, - ): - return self.request( - "PATCH", - url, - headers=headers, - query_params=query_params, - post_params=post_params, - _preload_content=_preload_content, - _request_timeout=_request_timeout, - body=body, - ) + def GET(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("GET", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def HEAD(self, url, headers=None, query_params=None, _preload_content=True, + _request_timeout=None): + return self.request("HEAD", url, + headers=headers, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + query_params=query_params) + + def OPTIONS(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("OPTIONS", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def DELETE(self, url, headers=None, query_params=None, body=None, + _preload_content=True, _request_timeout=None): + return self.request("DELETE", url, + headers=headers, + query_params=query_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def POST(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("POST", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def PUT(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PUT", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) + + def PATCH(self, url, headers=None, query_params=None, post_params=None, + body=None, _preload_content=True, _request_timeout=None): + return self.request("PATCH", url, + headers=headers, + query_params=query_params, + post_params=post_params, + _preload_content=_preload_content, + _request_timeout=_request_timeout, + body=body) diff --git a/pinecone/core/exceptions.py b/pinecone/core/exceptions.py deleted file mode 100644 index cd4577726..000000000 --- a/pinecone/core/exceptions.py +++ /dev/null @@ -1,6 +0,0 @@ -class PineconeException(Exception): - """The base exception class for all Pinecone client exceptions.""" - - -class PineconeProtocolError(PineconeException): - """Raised when something unexpected happens mid-request/response.""" diff --git a/pinecone/core/grpc/__init__.py b/pinecone/core/grpc/__init__.py deleted file mode 100644 index 8b1378917..000000000 --- a/pinecone/core/grpc/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/pinecone/core/grpc/protos/__init__.py b/pinecone/core/grpc/protos/__init__.py deleted file mode 100644 index 8b1378917..000000000 --- a/pinecone/core/grpc/protos/__init__.py +++ /dev/null @@ -1 +0,0 @@ - diff --git a/pinecone/core/grpc/protos/vector_column_service_pb2.py b/pinecone/core/grpc/protos/vector_column_service_pb2.py deleted file mode 100644 index 1b4ebadc1..000000000 --- a/pinecone/core/grpc/protos/vector_column_service_pb2.py +++ /dev/null @@ -1,1293 +0,0 @@ -# -*- coding: utf-8 -*- -# Generated by the protocol buffer compiler. DO NOT EDIT! -# source: vector_column_service.proto -"""Generated protocol buffer code.""" -from google.protobuf import descriptor as _descriptor -from google.protobuf import message as _message -from google.protobuf import reflection as _reflection -from google.protobuf import symbol_database as _symbol_database - -# @@protoc_insertion_point(imports) - -_sym_db = _symbol_database.Default() - - -from google.protobuf import struct_pb2 as google_dot_protobuf_dot_struct__pb2 - - -DESCRIPTOR = _descriptor.FileDescriptor( - name="vector_column_service.proto", - package="pinecone_columnar", - syntax="proto3", - serialized_options=b"\n\021io.pinecone.protoZ+github.com/pinecone-io/go-pinecone/pinecone", - create_key=_descriptor._internal_create_key, - serialized_pb=b'\n\x1bvector_column_service.proto\x12\x11pinecone_columnar\x1a\x1cgoogle/protobuf/struct.proto"K\n\x07NdArray\x12\x0e\n\x06\x62uffer\x18\x01 \x01(\x0c\x12\r\n\x05shape\x18\x02 \x03(\r\x12\r\n\x05\x64type\x18\x03 \x01(\t\x12\x12\n\ncompressed\x18\x04 \x01(\x08"\xbc\x01\n\rScoredResults\x12\'\n\x03ids\x18\x01 \x01(\x0b\x32\x1a.pinecone_columnar.NdArray\x12*\n\x06scores\x18\x02 \x01(\x0b\x32\x1a.pinecone_columnar.NdArray\x12(\n\x04\x64\x61ta\x18\x03 \x01(\x0b\x32\x1a.pinecone_columnar.NdArray\x12,\n\x08metadata\x18\x04 \x01(\x0b\x32\x1a.pinecone_columnar.NdArray"\x84\x01\n\rUpsertRequest\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x0b\n\x03ids\x18\x02 \x03(\t\x12(\n\x04\x64\x61ta\x18\x03 \x01(\x0b\x32\x1a.pinecone_columnar.NdArray\x12)\n\x08metadata\x18\x04 \x03(\x0b\x32\x17.google.protobuf.Struct"(\n\x0eUpsertResponse\x12\x16\n\x0eupserted_count\x18\x01 \x01(\r"C\n\rDeleteRequest\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x0b\n\x03ids\x18\x02 \x03(\t\x12\x12\n\ndelete_all\x18\x03 \x01(\x08"\x10\n\x0e\x44\x65leteResponse".\n\x0c\x46\x65tchRequest\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x0b\n\x03ids\x18\x02 \x03(\t"\x87\x01\n\rFetchResponse\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x0b\n\x03ids\x18\x02 \x03(\t\x12+\n\x07vectors\x18\x03 \x03(\x0b\x32\x1a.pinecone_columnar.NdArray\x12)\n\x08metadata\x18\x04 \x03(\x0b\x32\x17.google.protobuf.Struct"\xa1\x02\n\x0cQueryRequest\x12\x11\n\tnamespace\x18\x01 \x01(\t\x12\x1b\n\x13namespace_overrides\x18\x06 \x03(\t\x12\r\n\x05top_k\x18\x02 \x01(\r\x12\x17\n\x0ftop_k_overrides\x18\x05 \x03(\r\x12\'\n\x06\x66ilter\x18\x07 \x01(\x0b\x32\x17.google.protobuf.Struct\x12\x31\n\x10\x66ilter_overrides\x18\x08 \x03(\x0b\x32\x17.google.protobuf.Struct\x12\x16\n\x0einclude_values\x18\x03 \x01(\x08\x12\x18\n\x10include_metadata\x18\t \x01(\x08\x12+\n\x07queries\x18\x04 \x01(\x0b\x32\x1a.pinecone_columnar.NdArray"B\n\rQueryResponse\x12\x31\n\x07matches\x18\x01 \x03(\x0b\x32 .pinecone_columnar.ScoredResults"\x1b\n\x19\x44\x65scribeIndexStatsRequest"(\n\x10NamespaceSummary\x12\x14\n\x0cvector_count\x18\x01 \x01(\r"\xda\x01\n\x1a\x44\x65scribeIndexStatsResponse\x12Q\n\nnamespaces\x18\x01 \x03(\x0b\x32=.pinecone_columnar.DescribeIndexStatsResponse.NamespacesEntry\x12\x11\n\tdimension\x18\x02 \x01(\r\x1aV\n\x0fNamespacesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x32\n\x05value\x18\x02 \x01(\x0b\x32#.pinecone_columnar.NamespaceSummary:\x02\x38\x01\x32\xc8\x03\n\x13VectorColumnService\x12O\n\x06Upsert\x12 .pinecone_columnar.UpsertRequest\x1a!.pinecone_columnar.UpsertResponse"\x00\x12O\n\x06\x44\x65lete\x12 .pinecone_columnar.DeleteRequest\x1a!.pinecone_columnar.DeleteResponse"\x00\x12L\n\x05\x46\x65tch\x12\x1f.pinecone_columnar.FetchRequest\x1a .pinecone_columnar.FetchResponse"\x00\x12L\n\x05Query\x12\x1f.pinecone_columnar.QueryRequest\x1a .pinecone_columnar.QueryResponse"\x00\x12s\n\x12\x44\x65scribeIndexStats\x12,.pinecone_columnar.DescribeIndexStatsRequest\x1a-.pinecone_columnar.DescribeIndexStatsResponse"\x00\x42@\n\x11io.pinecone.protoZ+github.com/pinecone-io/go-pinecone/pineconeb\x06proto3', - dependencies=[ - google_dot_protobuf_dot_struct__pb2.DESCRIPTOR, - ], -) - - -_NDARRAY = _descriptor.Descriptor( - name="NdArray", - full_name="pinecone_columnar.NdArray", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="buffer", - full_name="pinecone_columnar.NdArray.buffer", - index=0, - number=1, - type=12, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"", - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="shape", - full_name="pinecone_columnar.NdArray.shape", - index=1, - number=2, - type=13, - cpp_type=3, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="dtype", - full_name="pinecone_columnar.NdArray.dtype", - index=2, - number=3, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="compressed", - full_name="pinecone_columnar.NdArray.compressed", - index=3, - number=4, - type=8, - cpp_type=7, - label=1, - has_default_value=False, - default_value=False, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=80, - serialized_end=155, -) - - -_SCOREDRESULTS = _descriptor.Descriptor( - name="ScoredResults", - full_name="pinecone_columnar.ScoredResults", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="ids", - full_name="pinecone_columnar.ScoredResults.ids", - index=0, - number=1, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="scores", - full_name="pinecone_columnar.ScoredResults.scores", - index=1, - number=2, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="data", - full_name="pinecone_columnar.ScoredResults.data", - index=2, - number=3, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="metadata", - full_name="pinecone_columnar.ScoredResults.metadata", - index=3, - number=4, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=158, - serialized_end=346, -) - - -_UPSERTREQUEST = _descriptor.Descriptor( - name="UpsertRequest", - full_name="pinecone_columnar.UpsertRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="namespace", - full_name="pinecone_columnar.UpsertRequest.namespace", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="ids", - full_name="pinecone_columnar.UpsertRequest.ids", - index=1, - number=2, - type=9, - cpp_type=9, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="data", - full_name="pinecone_columnar.UpsertRequest.data", - index=2, - number=3, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="metadata", - full_name="pinecone_columnar.UpsertRequest.metadata", - index=3, - number=4, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=349, - serialized_end=481, -) - - -_UPSERTRESPONSE = _descriptor.Descriptor( - name="UpsertResponse", - full_name="pinecone_columnar.UpsertResponse", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="upserted_count", - full_name="pinecone_columnar.UpsertResponse.upserted_count", - index=0, - number=1, - type=13, - cpp_type=3, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=483, - serialized_end=523, -) - - -_DELETEREQUEST = _descriptor.Descriptor( - name="DeleteRequest", - full_name="pinecone_columnar.DeleteRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="namespace", - full_name="pinecone_columnar.DeleteRequest.namespace", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="ids", - full_name="pinecone_columnar.DeleteRequest.ids", - index=1, - number=2, - type=9, - cpp_type=9, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="delete_all", - full_name="pinecone_columnar.DeleteRequest.delete_all", - index=2, - number=3, - type=8, - cpp_type=7, - label=1, - has_default_value=False, - default_value=False, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=525, - serialized_end=592, -) - - -_DELETERESPONSE = _descriptor.Descriptor( - name="DeleteResponse", - full_name="pinecone_columnar.DeleteResponse", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=594, - serialized_end=610, -) - - -_FETCHREQUEST = _descriptor.Descriptor( - name="FetchRequest", - full_name="pinecone_columnar.FetchRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="namespace", - full_name="pinecone_columnar.FetchRequest.namespace", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="ids", - full_name="pinecone_columnar.FetchRequest.ids", - index=1, - number=2, - type=9, - cpp_type=9, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=612, - serialized_end=658, -) - - -_FETCHRESPONSE = _descriptor.Descriptor( - name="FetchResponse", - full_name="pinecone_columnar.FetchResponse", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="namespace", - full_name="pinecone_columnar.FetchResponse.namespace", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="ids", - full_name="pinecone_columnar.FetchResponse.ids", - index=1, - number=2, - type=9, - cpp_type=9, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="vectors", - full_name="pinecone_columnar.FetchResponse.vectors", - index=2, - number=3, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="metadata", - full_name="pinecone_columnar.FetchResponse.metadata", - index=3, - number=4, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=661, - serialized_end=796, -) - - -_QUERYREQUEST = _descriptor.Descriptor( - name="QueryRequest", - full_name="pinecone_columnar.QueryRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="namespace", - full_name="pinecone_columnar.QueryRequest.namespace", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="namespace_overrides", - full_name="pinecone_columnar.QueryRequest.namespace_overrides", - index=1, - number=6, - type=9, - cpp_type=9, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="top_k", - full_name="pinecone_columnar.QueryRequest.top_k", - index=2, - number=2, - type=13, - cpp_type=3, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="top_k_overrides", - full_name="pinecone_columnar.QueryRequest.top_k_overrides", - index=3, - number=5, - type=13, - cpp_type=3, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="filter", - full_name="pinecone_columnar.QueryRequest.filter", - index=4, - number=7, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="filter_overrides", - full_name="pinecone_columnar.QueryRequest.filter_overrides", - index=5, - number=8, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="include_values", - full_name="pinecone_columnar.QueryRequest.include_values", - index=6, - number=3, - type=8, - cpp_type=7, - label=1, - has_default_value=False, - default_value=False, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="include_metadata", - full_name="pinecone_columnar.QueryRequest.include_metadata", - index=7, - number=9, - type=8, - cpp_type=7, - label=1, - has_default_value=False, - default_value=False, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="queries", - full_name="pinecone_columnar.QueryRequest.queries", - index=8, - number=4, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=799, - serialized_end=1088, -) - - -_QUERYRESPONSE = _descriptor.Descriptor( - name="QueryResponse", - full_name="pinecone_columnar.QueryResponse", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="matches", - full_name="pinecone_columnar.QueryResponse.matches", - index=0, - number=1, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1090, - serialized_end=1156, -) - - -_DESCRIBEINDEXSTATSREQUEST = _descriptor.Descriptor( - name="DescribeIndexStatsRequest", - full_name="pinecone_columnar.DescribeIndexStatsRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1158, - serialized_end=1185, -) - - -_NAMESPACESUMMARY = _descriptor.Descriptor( - name="NamespaceSummary", - full_name="pinecone_columnar.NamespaceSummary", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="vector_count", - full_name="pinecone_columnar.NamespaceSummary.vector_count", - index=0, - number=1, - type=13, - cpp_type=3, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1187, - serialized_end=1227, -) - - -_DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY = _descriptor.Descriptor( - name="NamespacesEntry", - full_name="pinecone_columnar.DescribeIndexStatsResponse.NamespacesEntry", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="key", - full_name="pinecone_columnar.DescribeIndexStatsResponse.NamespacesEntry.key", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="value", - full_name="pinecone_columnar.DescribeIndexStatsResponse.NamespacesEntry.value", - index=1, - number=2, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=b"8\001", - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1362, - serialized_end=1448, -) - -_DESCRIBEINDEXSTATSRESPONSE = _descriptor.Descriptor( - name="DescribeIndexStatsResponse", - full_name="pinecone_columnar.DescribeIndexStatsResponse", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="namespaces", - full_name="pinecone_columnar.DescribeIndexStatsResponse.namespaces", - index=0, - number=1, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="dimension", - full_name="pinecone_columnar.DescribeIndexStatsResponse.dimension", - index=1, - number=2, - type=13, - cpp_type=3, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[ - _DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY, - ], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1230, - serialized_end=1448, -) - -_SCOREDRESULTS.fields_by_name["ids"].message_type = _NDARRAY -_SCOREDRESULTS.fields_by_name["scores"].message_type = _NDARRAY -_SCOREDRESULTS.fields_by_name["data"].message_type = _NDARRAY -_SCOREDRESULTS.fields_by_name["metadata"].message_type = _NDARRAY -_UPSERTREQUEST.fields_by_name["data"].message_type = _NDARRAY -_UPSERTREQUEST.fields_by_name["metadata"].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT -_FETCHRESPONSE.fields_by_name["vectors"].message_type = _NDARRAY -_FETCHRESPONSE.fields_by_name["metadata"].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT -_QUERYREQUEST.fields_by_name["filter"].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT -_QUERYREQUEST.fields_by_name["filter_overrides"].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT -_QUERYREQUEST.fields_by_name["queries"].message_type = _NDARRAY -_QUERYRESPONSE.fields_by_name["matches"].message_type = _SCOREDRESULTS -_DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY.fields_by_name["value"].message_type = _NAMESPACESUMMARY -_DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY.containing_type = _DESCRIBEINDEXSTATSRESPONSE -_DESCRIBEINDEXSTATSRESPONSE.fields_by_name["namespaces"].message_type = _DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY -DESCRIPTOR.message_types_by_name["NdArray"] = _NDARRAY -DESCRIPTOR.message_types_by_name["ScoredResults"] = _SCOREDRESULTS -DESCRIPTOR.message_types_by_name["UpsertRequest"] = _UPSERTREQUEST -DESCRIPTOR.message_types_by_name["UpsertResponse"] = _UPSERTRESPONSE -DESCRIPTOR.message_types_by_name["DeleteRequest"] = _DELETEREQUEST -DESCRIPTOR.message_types_by_name["DeleteResponse"] = _DELETERESPONSE -DESCRIPTOR.message_types_by_name["FetchRequest"] = _FETCHREQUEST -DESCRIPTOR.message_types_by_name["FetchResponse"] = _FETCHRESPONSE -DESCRIPTOR.message_types_by_name["QueryRequest"] = _QUERYREQUEST -DESCRIPTOR.message_types_by_name["QueryResponse"] = _QUERYRESPONSE -DESCRIPTOR.message_types_by_name["DescribeIndexStatsRequest"] = _DESCRIBEINDEXSTATSREQUEST -DESCRIPTOR.message_types_by_name["NamespaceSummary"] = _NAMESPACESUMMARY -DESCRIPTOR.message_types_by_name["DescribeIndexStatsResponse"] = _DESCRIBEINDEXSTATSRESPONSE -_sym_db.RegisterFileDescriptor(DESCRIPTOR) - -NdArray = _reflection.GeneratedProtocolMessageType( - "NdArray", - (_message.Message,), - { - "DESCRIPTOR": _NDARRAY, - "__module__": "vector_column_service_pb2" - # @@protoc_insertion_point(class_scope:pinecone_columnar.NdArray) - }, -) -_sym_db.RegisterMessage(NdArray) - -ScoredResults = _reflection.GeneratedProtocolMessageType( - "ScoredResults", - (_message.Message,), - { - "DESCRIPTOR": _SCOREDRESULTS, - "__module__": "vector_column_service_pb2" - # @@protoc_insertion_point(class_scope:pinecone_columnar.ScoredResults) - }, -) -_sym_db.RegisterMessage(ScoredResults) - -UpsertRequest = _reflection.GeneratedProtocolMessageType( - "UpsertRequest", - (_message.Message,), - { - "DESCRIPTOR": _UPSERTREQUEST, - "__module__": "vector_column_service_pb2" - # @@protoc_insertion_point(class_scope:pinecone_columnar.UpsertRequest) - }, -) -_sym_db.RegisterMessage(UpsertRequest) - -UpsertResponse = _reflection.GeneratedProtocolMessageType( - "UpsertResponse", - (_message.Message,), - { - "DESCRIPTOR": _UPSERTRESPONSE, - "__module__": "vector_column_service_pb2" - # @@protoc_insertion_point(class_scope:pinecone_columnar.UpsertResponse) - }, -) -_sym_db.RegisterMessage(UpsertResponse) - -DeleteRequest = _reflection.GeneratedProtocolMessageType( - "DeleteRequest", - (_message.Message,), - { - "DESCRIPTOR": _DELETEREQUEST, - "__module__": "vector_column_service_pb2" - # @@protoc_insertion_point(class_scope:pinecone_columnar.DeleteRequest) - }, -) -_sym_db.RegisterMessage(DeleteRequest) - -DeleteResponse = _reflection.GeneratedProtocolMessageType( - "DeleteResponse", - (_message.Message,), - { - "DESCRIPTOR": _DELETERESPONSE, - "__module__": "vector_column_service_pb2" - # @@protoc_insertion_point(class_scope:pinecone_columnar.DeleteResponse) - }, -) -_sym_db.RegisterMessage(DeleteResponse) - -FetchRequest = _reflection.GeneratedProtocolMessageType( - "FetchRequest", - (_message.Message,), - { - "DESCRIPTOR": _FETCHREQUEST, - "__module__": "vector_column_service_pb2" - # @@protoc_insertion_point(class_scope:pinecone_columnar.FetchRequest) - }, -) -_sym_db.RegisterMessage(FetchRequest) - -FetchResponse = _reflection.GeneratedProtocolMessageType( - "FetchResponse", - (_message.Message,), - { - "DESCRIPTOR": _FETCHRESPONSE, - "__module__": "vector_column_service_pb2" - # @@protoc_insertion_point(class_scope:pinecone_columnar.FetchResponse) - }, -) -_sym_db.RegisterMessage(FetchResponse) - -QueryRequest = _reflection.GeneratedProtocolMessageType( - "QueryRequest", - (_message.Message,), - { - "DESCRIPTOR": _QUERYREQUEST, - "__module__": "vector_column_service_pb2" - # @@protoc_insertion_point(class_scope:pinecone_columnar.QueryRequest) - }, -) -_sym_db.RegisterMessage(QueryRequest) - -QueryResponse = _reflection.GeneratedProtocolMessageType( - "QueryResponse", - (_message.Message,), - { - "DESCRIPTOR": _QUERYRESPONSE, - "__module__": "vector_column_service_pb2" - # @@protoc_insertion_point(class_scope:pinecone_columnar.QueryResponse) - }, -) -_sym_db.RegisterMessage(QueryResponse) - -DescribeIndexStatsRequest = _reflection.GeneratedProtocolMessageType( - "DescribeIndexStatsRequest", - (_message.Message,), - { - "DESCRIPTOR": _DESCRIBEINDEXSTATSREQUEST, - "__module__": "vector_column_service_pb2" - # @@protoc_insertion_point(class_scope:pinecone_columnar.DescribeIndexStatsRequest) - }, -) -_sym_db.RegisterMessage(DescribeIndexStatsRequest) - -NamespaceSummary = _reflection.GeneratedProtocolMessageType( - "NamespaceSummary", - (_message.Message,), - { - "DESCRIPTOR": _NAMESPACESUMMARY, - "__module__": "vector_column_service_pb2" - # @@protoc_insertion_point(class_scope:pinecone_columnar.NamespaceSummary) - }, -) -_sym_db.RegisterMessage(NamespaceSummary) - -DescribeIndexStatsResponse = _reflection.GeneratedProtocolMessageType( - "DescribeIndexStatsResponse", - (_message.Message,), - { - "NamespacesEntry": _reflection.GeneratedProtocolMessageType( - "NamespacesEntry", - (_message.Message,), - { - "DESCRIPTOR": _DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY, - "__module__": "vector_column_service_pb2" - # @@protoc_insertion_point(class_scope:pinecone_columnar.DescribeIndexStatsResponse.NamespacesEntry) - }, - ), - "DESCRIPTOR": _DESCRIBEINDEXSTATSRESPONSE, - "__module__": "vector_column_service_pb2" - # @@protoc_insertion_point(class_scope:pinecone_columnar.DescribeIndexStatsResponse) - }, -) -_sym_db.RegisterMessage(DescribeIndexStatsResponse) -_sym_db.RegisterMessage(DescribeIndexStatsResponse.NamespacesEntry) - - -DESCRIPTOR._options = None -_DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY._options = None - -_VECTORCOLUMNSERVICE = _descriptor.ServiceDescriptor( - name="VectorColumnService", - full_name="pinecone_columnar.VectorColumnService", - file=DESCRIPTOR, - index=0, - serialized_options=None, - create_key=_descriptor._internal_create_key, - serialized_start=1451, - serialized_end=1907, - methods=[ - _descriptor.MethodDescriptor( - name="Upsert", - full_name="pinecone_columnar.VectorColumnService.Upsert", - index=0, - containing_service=None, - input_type=_UPSERTREQUEST, - output_type=_UPSERTRESPONSE, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name="Delete", - full_name="pinecone_columnar.VectorColumnService.Delete", - index=1, - containing_service=None, - input_type=_DELETEREQUEST, - output_type=_DELETERESPONSE, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name="Fetch", - full_name="pinecone_columnar.VectorColumnService.Fetch", - index=2, - containing_service=None, - input_type=_FETCHREQUEST, - output_type=_FETCHRESPONSE, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name="Query", - full_name="pinecone_columnar.VectorColumnService.Query", - index=3, - containing_service=None, - input_type=_QUERYREQUEST, - output_type=_QUERYRESPONSE, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name="DescribeIndexStats", - full_name="pinecone_columnar.VectorColumnService.DescribeIndexStats", - index=4, - containing_service=None, - input_type=_DESCRIBEINDEXSTATSREQUEST, - output_type=_DESCRIBEINDEXSTATSRESPONSE, - serialized_options=None, - create_key=_descriptor._internal_create_key, - ), - ], -) -_sym_db.RegisterServiceDescriptor(_VECTORCOLUMNSERVICE) - -DESCRIPTOR.services_by_name["VectorColumnService"] = _VECTORCOLUMNSERVICE - -# @@protoc_insertion_point(module_scope) diff --git a/pinecone/core/grpc/protos/vector_column_service_pb2.pyi b/pinecone/core/grpc/protos/vector_column_service_pb2.pyi deleted file mode 100644 index 3b85ddb13..000000000 --- a/pinecone/core/grpc/protos/vector_column_service_pb2.pyi +++ /dev/null @@ -1,350 +0,0 @@ -# @generated by generate_proto_mypy_stubs.py. Do not edit! -import sys -from google.protobuf.descriptor import ( - Descriptor as google___protobuf___descriptor___Descriptor, - FileDescriptor as google___protobuf___descriptor___FileDescriptor, -) - -from google.protobuf.internal.containers import ( - RepeatedCompositeFieldContainer as google___protobuf___internal___containers___RepeatedCompositeFieldContainer, - RepeatedScalarFieldContainer as google___protobuf___internal___containers___RepeatedScalarFieldContainer, -) - -from google.protobuf.message import ( - Message as google___protobuf___message___Message, -) - -from google.protobuf.struct_pb2 import ( - Struct as google___protobuf___struct_pb2___Struct, -) - -from typing import ( - Iterable as typing___Iterable, - Mapping as typing___Mapping, - MutableMapping as typing___MutableMapping, - Optional as typing___Optional, - Text as typing___Text, -) - -from typing_extensions import ( - Literal as typing_extensions___Literal, -) - -builtin___bool = bool -builtin___bytes = bytes -builtin___float = float -builtin___int = int - -DESCRIPTOR: google___protobuf___descriptor___FileDescriptor = ... - -class NdArray(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - buffer: builtin___bytes = ... - shape: google___protobuf___internal___containers___RepeatedScalarFieldContainer[builtin___int] = ... - dtype: typing___Text = ... - compressed: builtin___bool = ... - - def __init__( - self, - *, - buffer: typing___Optional[builtin___bytes] = None, - shape: typing___Optional[typing___Iterable[builtin___int]] = None, - dtype: typing___Optional[typing___Text] = None, - compressed: typing___Optional[builtin___bool] = None, - ) -> None: ... - def ClearField( - self, - field_name: typing_extensions___Literal[ - "buffer", b"buffer", "compressed", b"compressed", "dtype", b"dtype", "shape", b"shape" - ], - ) -> None: ... - -type___NdArray = NdArray - -class ScoredResults(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - - @property - def ids(self) -> type___NdArray: ... - @property - def scores(self) -> type___NdArray: ... - @property - def data(self) -> type___NdArray: ... - @property - def metadata(self) -> type___NdArray: ... - def __init__( - self, - *, - ids: typing___Optional[type___NdArray] = None, - scores: typing___Optional[type___NdArray] = None, - data: typing___Optional[type___NdArray] = None, - metadata: typing___Optional[type___NdArray] = None, - ) -> None: ... - def HasField( - self, - field_name: typing_extensions___Literal[ - "data", b"data", "ids", b"ids", "metadata", b"metadata", "scores", b"scores" - ], - ) -> builtin___bool: ... - def ClearField( - self, - field_name: typing_extensions___Literal[ - "data", b"data", "ids", b"ids", "metadata", b"metadata", "scores", b"scores" - ], - ) -> None: ... - -type___ScoredResults = ScoredResults - -class UpsertRequest(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - namespace: typing___Text = ... - ids: google___protobuf___internal___containers___RepeatedScalarFieldContainer[typing___Text] = ... - - @property - def data(self) -> type___NdArray: ... - @property - def metadata( - self, - ) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[ - google___protobuf___struct_pb2___Struct - ]: ... - def __init__( - self, - *, - namespace: typing___Optional[typing___Text] = None, - ids: typing___Optional[typing___Iterable[typing___Text]] = None, - data: typing___Optional[type___NdArray] = None, - metadata: typing___Optional[typing___Iterable[google___protobuf___struct_pb2___Struct]] = None, - ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal["data", b"data"]) -> builtin___bool: ... - def ClearField( - self, - field_name: typing_extensions___Literal[ - "data", b"data", "ids", b"ids", "metadata", b"metadata", "namespace", b"namespace" - ], - ) -> None: ... - -type___UpsertRequest = UpsertRequest - -class UpsertResponse(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - upserted_count: builtin___int = ... - - def __init__( - self, - *, - upserted_count: typing___Optional[builtin___int] = None, - ) -> None: ... - def ClearField(self, field_name: typing_extensions___Literal["upserted_count", b"upserted_count"]) -> None: ... - -type___UpsertResponse = UpsertResponse - -class DeleteRequest(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - namespace: typing___Text = ... - ids: google___protobuf___internal___containers___RepeatedScalarFieldContainer[typing___Text] = ... - delete_all: builtin___bool = ... - - def __init__( - self, - *, - namespace: typing___Optional[typing___Text] = None, - ids: typing___Optional[typing___Iterable[typing___Text]] = None, - delete_all: typing___Optional[builtin___bool] = None, - ) -> None: ... - def ClearField( - self, - field_name: typing_extensions___Literal["delete_all", b"delete_all", "ids", b"ids", "namespace", b"namespace"], - ) -> None: ... - -type___DeleteRequest = DeleteRequest - -class DeleteResponse(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - - def __init__( - self, - ) -> None: ... - -type___DeleteResponse = DeleteResponse - -class FetchRequest(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - namespace: typing___Text = ... - ids: google___protobuf___internal___containers___RepeatedScalarFieldContainer[typing___Text] = ... - - def __init__( - self, - *, - namespace: typing___Optional[typing___Text] = None, - ids: typing___Optional[typing___Iterable[typing___Text]] = None, - ) -> None: ... - def ClearField(self, field_name: typing_extensions___Literal["ids", b"ids", "namespace", b"namespace"]) -> None: ... - -type___FetchRequest = FetchRequest - -class FetchResponse(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - namespace: typing___Text = ... - ids: google___protobuf___internal___containers___RepeatedScalarFieldContainer[typing___Text] = ... - - @property - def vectors( - self, - ) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[type___NdArray]: ... - @property - def metadata( - self, - ) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[ - google___protobuf___struct_pb2___Struct - ]: ... - def __init__( - self, - *, - namespace: typing___Optional[typing___Text] = None, - ids: typing___Optional[typing___Iterable[typing___Text]] = None, - vectors: typing___Optional[typing___Iterable[type___NdArray]] = None, - metadata: typing___Optional[typing___Iterable[google___protobuf___struct_pb2___Struct]] = None, - ) -> None: ... - def ClearField( - self, - field_name: typing_extensions___Literal[ - "ids", b"ids", "metadata", b"metadata", "namespace", b"namespace", "vectors", b"vectors" - ], - ) -> None: ... - -type___FetchResponse = FetchResponse - -class QueryRequest(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - namespace: typing___Text = ... - namespace_overrides: google___protobuf___internal___containers___RepeatedScalarFieldContainer[typing___Text] = ... - top_k: builtin___int = ... - top_k_overrides: google___protobuf___internal___containers___RepeatedScalarFieldContainer[builtin___int] = ... - include_values: builtin___bool = ... - include_metadata: builtin___bool = ... - - @property - def filter(self) -> google___protobuf___struct_pb2___Struct: ... - @property - def filter_overrides( - self, - ) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[ - google___protobuf___struct_pb2___Struct - ]: ... - @property - def queries(self) -> type___NdArray: ... - def __init__( - self, - *, - namespace: typing___Optional[typing___Text] = None, - namespace_overrides: typing___Optional[typing___Iterable[typing___Text]] = None, - top_k: typing___Optional[builtin___int] = None, - top_k_overrides: typing___Optional[typing___Iterable[builtin___int]] = None, - filter: typing___Optional[google___protobuf___struct_pb2___Struct] = None, - filter_overrides: typing___Optional[typing___Iterable[google___protobuf___struct_pb2___Struct]] = None, - include_values: typing___Optional[builtin___bool] = None, - include_metadata: typing___Optional[builtin___bool] = None, - queries: typing___Optional[type___NdArray] = None, - ) -> None: ... - def HasField( - self, field_name: typing_extensions___Literal["filter", b"filter", "queries", b"queries"] - ) -> builtin___bool: ... - def ClearField( - self, - field_name: typing_extensions___Literal[ - "filter", - b"filter", - "filter_overrides", - b"filter_overrides", - "include_metadata", - b"include_metadata", - "include_values", - b"include_values", - "namespace", - b"namespace", - "namespace_overrides", - b"namespace_overrides", - "queries", - b"queries", - "top_k", - b"top_k", - "top_k_overrides", - b"top_k_overrides", - ], - ) -> None: ... - -type___QueryRequest = QueryRequest - -class QueryResponse(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - - @property - def matches( - self, - ) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[type___ScoredResults]: ... - def __init__( - self, - *, - matches: typing___Optional[typing___Iterable[type___ScoredResults]] = None, - ) -> None: ... - def ClearField(self, field_name: typing_extensions___Literal["matches", b"matches"]) -> None: ... - -type___QueryResponse = QueryResponse - -class DescribeIndexStatsRequest(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - - def __init__( - self, - ) -> None: ... - -type___DescribeIndexStatsRequest = DescribeIndexStatsRequest - -class NamespaceSummary(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - vector_count: builtin___int = ... - - def __init__( - self, - *, - vector_count: typing___Optional[builtin___int] = None, - ) -> None: ... - def ClearField(self, field_name: typing_extensions___Literal["vector_count", b"vector_count"]) -> None: ... - -type___NamespaceSummary = NamespaceSummary - -class DescribeIndexStatsResponse(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - - class NamespacesEntry(google___protobuf___message___Message): - DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - key: typing___Text = ... - - @property - def value(self) -> type___NamespaceSummary: ... - def __init__( - self, - *, - key: typing___Optional[typing___Text] = None, - value: typing___Optional[type___NamespaceSummary] = None, - ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal["value", b"value"]) -> builtin___bool: ... - def ClearField(self, field_name: typing_extensions___Literal["key", b"key", "value", b"value"]) -> None: ... - type___NamespacesEntry = NamespacesEntry - - dimension: builtin___int = ... - - @property - def namespaces(self) -> typing___MutableMapping[typing___Text, type___NamespaceSummary]: ... - def __init__( - self, - *, - namespaces: typing___Optional[typing___Mapping[typing___Text, type___NamespaceSummary]] = None, - dimension: typing___Optional[builtin___int] = None, - ) -> None: ... - def ClearField( - self, field_name: typing_extensions___Literal["dimension", b"dimension", "namespaces", b"namespaces"] - ) -> None: ... - -type___DescribeIndexStatsResponse = DescribeIndexStatsResponse diff --git a/pinecone/core/grpc/protos/vector_column_service_pb2_grpc.py b/pinecone/core/grpc/protos/vector_column_service_pb2_grpc.py deleted file mode 100644 index 677e12b4b..000000000 --- a/pinecone/core/grpc/protos/vector_column_service_pb2_grpc.py +++ /dev/null @@ -1,267 +0,0 @@ -# Generated by the gRPC Python protocol compiler plugin. DO NOT EDIT! -"""Client and server classes corresponding to protobuf-defined services.""" -import grpc - -import pinecone.core.grpc.protos.vector_column_service_pb2 as vector__column__service__pb2 - - -class VectorColumnServiceStub(object): - """The `VectorColumnService` interface is exposed by Pinecone vector index services. - The `Upsert` operation is for uploading the data (the vector ids and values) to be indexed. - """ - - def __init__(self, channel): - """Constructor. - - Args: - channel: A grpc.Channel. - """ - self.Upsert = channel.unary_unary( - "/pinecone_columnar.VectorColumnService/Upsert", - request_serializer=vector__column__service__pb2.UpsertRequest.SerializeToString, - response_deserializer=vector__column__service__pb2.UpsertResponse.FromString, - ) - self.Delete = channel.unary_unary( - "/pinecone_columnar.VectorColumnService/Delete", - request_serializer=vector__column__service__pb2.DeleteRequest.SerializeToString, - response_deserializer=vector__column__service__pb2.DeleteResponse.FromString, - ) - self.Fetch = channel.unary_unary( - "/pinecone_columnar.VectorColumnService/Fetch", - request_serializer=vector__column__service__pb2.FetchRequest.SerializeToString, - response_deserializer=vector__column__service__pb2.FetchResponse.FromString, - ) - self.Query = channel.unary_unary( - "/pinecone_columnar.VectorColumnService/Query", - request_serializer=vector__column__service__pb2.QueryRequest.SerializeToString, - response_deserializer=vector__column__service__pb2.QueryResponse.FromString, - ) - self.DescribeIndexStats = channel.unary_unary( - "/pinecone_columnar.VectorColumnService/DescribeIndexStats", - request_serializer=vector__column__service__pb2.DescribeIndexStatsRequest.SerializeToString, - response_deserializer=vector__column__service__pb2.DescribeIndexStatsResponse.FromString, - ) - - -class VectorColumnServiceServicer(object): - """The `VectorColumnService` interface is exposed by Pinecone vector index services. - The `Upsert` operation is for uploading the data (the vector ids and values) to be indexed. - """ - - def Upsert(self, request, context): - """If a user upserts a new value for an existing vector id, it overwrites the previous value.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def Delete(self, request, context): - """The `Delete` operation deletes multiple vectors ids from a single namespace. - Specifying `delete_all` will delete all vectors from the default namespace. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def Fetch(self, request, context): - """The `Fetch` operation returns a vector value by id.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def Query(self, request, context): - """The `Query` operation queries the index for the nearest stored vectors to one - or more query vectors, and returns their ids and/or values. - """ - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - def DescribeIndexStats(self, request, context): - """The `DescribeIndexStats` operation returns summary statistics about the index contents.""" - context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") - - -def add_VectorColumnServiceServicer_to_server(servicer, server): - rpc_method_handlers = { - "Upsert": grpc.unary_unary_rpc_method_handler( - servicer.Upsert, - request_deserializer=vector__column__service__pb2.UpsertRequest.FromString, - response_serializer=vector__column__service__pb2.UpsertResponse.SerializeToString, - ), - "Delete": grpc.unary_unary_rpc_method_handler( - servicer.Delete, - request_deserializer=vector__column__service__pb2.DeleteRequest.FromString, - response_serializer=vector__column__service__pb2.DeleteResponse.SerializeToString, - ), - "Fetch": grpc.unary_unary_rpc_method_handler( - servicer.Fetch, - request_deserializer=vector__column__service__pb2.FetchRequest.FromString, - response_serializer=vector__column__service__pb2.FetchResponse.SerializeToString, - ), - "Query": grpc.unary_unary_rpc_method_handler( - servicer.Query, - request_deserializer=vector__column__service__pb2.QueryRequest.FromString, - response_serializer=vector__column__service__pb2.QueryResponse.SerializeToString, - ), - "DescribeIndexStats": grpc.unary_unary_rpc_method_handler( - servicer.DescribeIndexStats, - request_deserializer=vector__column__service__pb2.DescribeIndexStatsRequest.FromString, - response_serializer=vector__column__service__pb2.DescribeIndexStatsResponse.SerializeToString, - ), - } - generic_handler = grpc.method_handlers_generic_handler("pinecone_columnar.VectorColumnService", rpc_method_handlers) - server.add_generic_rpc_handlers((generic_handler,)) - - -# This class is part of an EXPERIMENTAL API. -class VectorColumnService(object): - """The `VectorColumnService` interface is exposed by Pinecone vector index services. - The `Upsert` operation is for uploading the data (the vector ids and values) to be indexed. - """ - - @staticmethod - def Upsert( - request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None, - ): - return grpc.experimental.unary_unary( - request, - target, - "/pinecone_columnar.VectorColumnService/Upsert", - vector__column__service__pb2.UpsertRequest.SerializeToString, - vector__column__service__pb2.UpsertResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - ) - - @staticmethod - def Delete( - request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None, - ): - return grpc.experimental.unary_unary( - request, - target, - "/pinecone_columnar.VectorColumnService/Delete", - vector__column__service__pb2.DeleteRequest.SerializeToString, - vector__column__service__pb2.DeleteResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - ) - - @staticmethod - def Fetch( - request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None, - ): - return grpc.experimental.unary_unary( - request, - target, - "/pinecone_columnar.VectorColumnService/Fetch", - vector__column__service__pb2.FetchRequest.SerializeToString, - vector__column__service__pb2.FetchResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - ) - - @staticmethod - def Query( - request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None, - ): - return grpc.experimental.unary_unary( - request, - target, - "/pinecone_columnar.VectorColumnService/Query", - vector__column__service__pb2.QueryRequest.SerializeToString, - vector__column__service__pb2.QueryResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - ) - - @staticmethod - def DescribeIndexStats( - request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None, - ): - return grpc.experimental.unary_unary( - request, - target, - "/pinecone_columnar.VectorColumnService/DescribeIndexStats", - vector__column__service__pb2.DescribeIndexStatsRequest.SerializeToString, - vector__column__service__pb2.DescribeIndexStatsResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - ) diff --git a/pinecone/core/grpc/protos/vector_service_pb2.py b/pinecone/core/grpc/protos/vector_service_pb2.py index 276c606d9..665ead6c7 100644 --- a/pinecone/core/grpc/protos/vector_service_pb2.py +++ b/pinecone/core/grpc/protos/vector_service_pb2.py @@ -6,7 +6,6 @@ from google.protobuf import message as _message from google.protobuf import reflection as _reflection from google.protobuf import symbol_database as _symbol_database - # @@protoc_insertion_point(imports) _sym_db = _symbol_database.Default() @@ -19,1905 +18,1211 @@ DESCRIPTOR = _descriptor.FileDescriptor( - name="vector_service.proto", - package="", - syntax="proto3", - serialized_options=b'\n\021io.pinecone.protoP\001Z/github.com/pinecone-io/new-go-pinecone/pinecone\222A\366\002\022K\n\014Pinecone API";\n\017Pinecone.io Ops\022\023https://pinecone.io\032\023support@pinecone.io\0329{index_name}-{project_name}.svc.{environment}.pinecone.io*\001\0022\020application/json:\020application/jsonZx\nv\n\nApiKeyAuth\022h\010\002\022YAn API Key is required to call Pinecone APIs. Get yours at https://www.pinecone.io/start/\032\007Api-Key \002b\020\n\016\n\nApiKeyAuth\022\000r9\n\031More Pinecone.io API docs\022\034https://www.pinecone.io/docs', - create_key=_descriptor._internal_create_key, - serialized_pb=b'\n\x14vector_service.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1cgoogle/api/annotations.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a.protoc-gen-openapiv2/options/annotations.proto"~\n\x0cSparseValues\x12\x35\n\x07indices\x18\x01 \x03(\rB$\x92\x41\x1eJ\x16[1, 312, 822, 14, 980]x\xe8\x07\x80\x01\x01\xe0\x41\x02\x12\x37\n\x06values\x18\x02 \x03(\x02\x42\'\x92\x41!J\x19[0.1, 0.2, 0.3, 0.4, 0.5]x\xe8\x07\x80\x01\x01\xe0\x41\x02"\xfd\x01\n\x06Vector\x12,\n\x02id\x18\x01 \x01(\tB \x92\x41\x1aJ\x12"example-vector-1"x\x80\x04\x80\x01\x01\xe0\x41\x02\x12G\n\x06values\x18\x02 \x03(\x02\x42\x37\x92\x41\x31J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\xa0\x9c\x01\x80\x01\x01\xe0\x41\x02\x12$\n\rsparse_values\x18\x04 \x01(\x0b\x32\r.SparseValues\x12V\n\x08metadata\x18\x03 \x01(\x0b\x32\x17.google.protobuf.StructB+\x92\x41(J&{"genre": "documentary", "year": 2019}"\x93\x02\n\x0cScoredVector\x12,\n\x02id\x18\x01 \x01(\tB \x92\x41\x1aJ\x12"example-vector-1"x\x80\x04\x80\x01\x01\xe0\x41\x02\x12\x18\n\x05score\x18\x02 \x01(\x02\x42\t\x92\x41\x06J\x04\x30.08\x12=\n\x06values\x18\x03 \x03(\x02\x42-\x92\x41*J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]\x12$\n\rsparse_values\x18\x05 \x01(\x0b\x32\r.SparseValues\x12V\n\x08metadata\x18\x04 \x01(\x0b\x32\x17.google.protobuf.StructB+\x92\x41(J&{"genre": "documentary", "year": 2019}"d\n\rUpsertRequest\x12&\n\x07vectors\x18\x01 \x03(\x0b\x32\x07.VectorB\x0c\x92\x41\x06x\xe8\x07\x80\x01\x01\xe0\x41\x02\x12+\n\tnamespace\x18\x02 \x01(\tB\x18\x92\x41\x15J\x13"example-namespace""1\n\x0eUpsertResponse\x12\x1f\n\x0eupserted_count\x18\x01 \x01(\rB\x07\x92\x41\x04J\x02\x31\x30"\xb6\x01\n\rDeleteRequest\x12(\n\x03ids\x18\x01 \x03(\tB\x1b\x92\x41\x18J\x10["id-0", "id-1"]x\xe8\x07\x80\x01\x01\x12%\n\ndelete_all\x18\x02 \x01(\x08\x42\x11\x92\x41\x0e:\x05\x66\x61lseJ\x05\x66\x61lse\x12+\n\tnamespace\x18\x03 \x01(\tB\x18\x92\x41\x15J\x13"example-namespace"\x12\'\n\x06\x66ilter\x18\x04 \x01(\x0b\x32\x17.google.protobuf.Struct"\x10\n\x0e\x44\x65leteResponse"h\n\x0c\x46\x65tchRequest\x12+\n\x03ids\x18\x01 \x03(\tB\x1e\x92\x41\x18J\x10["id-0", "id-1"]x\xe8\x07\x80\x01\x01\xe0\x41\x02\x12+\n\tnamespace\x18\x02 \x01(\tB\x18\x92\x41\x15J\x13"example-namespace""\xa3\x01\n\rFetchResponse\x12,\n\x07vectors\x18\x01 \x03(\x0b\x32\x1b.FetchResponse.VectorsEntry\x12+\n\tnamespace\x18\x02 \x01(\tB\x18\x92\x41\x15J\x13"example-namespace"\x1a\x37\n\x0cVectorsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x16\n\x05value\x18\x02 \x01(\x0b\x32\x07.Vector:\x02\x38\x01"\xd0\x02\n\x0bQueryVector\x12G\n\x06values\x18\x01 \x03(\x02\x42\x37\x92\x41\x31J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\xa0\x9c\x01\x80\x01\x01\xe0\x41\x02\x12$\n\rsparse_values\x18\x05 \x01(\x0b\x32\r.SparseValues\x12(\n\x05top_k\x18\x02 \x01(\rB\x19\x92\x41\x16J\x02\x31\x30Y\x00\x00\x00\x00\x00\x88\xc3@i\x00\x00\x00\x00\x00\x00\xf0?\x12+\n\tnamespace\x18\x03 \x01(\tB\x18\x92\x41\x15J\x13"example-namespace"\x12{\n\x06\x66ilter\x18\x04 \x01(\x0b\x32\x17.google.protobuf.StructBR\x92\x41OJM{"genre": {"$in": ["comedy", "documentary", "drama"]}, "year": {"$eq": 2019}}"\xfa\x03\n\x0cQueryRequest\x12+\n\tnamespace\x18\x01 \x01(\tB\x18\x92\x41\x15J\x13"example-namespace"\x12+\n\x05top_k\x18\x02 \x01(\rB\x1c\x92\x41\x16J\x02\x31\x30Y\x00\x00\x00\x00\x00\x88\xc3@i\x00\x00\x00\x00\x00\x00\xf0?\xe0\x41\x02\x12{\n\x06\x66ilter\x18\x03 \x01(\x0b\x32\x17.google.protobuf.StructBR\x92\x41OJM{"genre": {"$in": ["comedy", "documentary", "drama"]}, "year": {"$eq": 2019}}\x12(\n\x0einclude_values\x18\x04 \x01(\x08\x42\x10\x92\x41\r:\x05\x66\x61lseJ\x04true\x12*\n\x10include_metadata\x18\x05 \x01(\x08\x42\x10\x92\x41\r:\x05\x66\x61lseJ\x04true\x12)\n\x07queries\x18\x06 \x03(\x0b\x32\x0c.QueryVectorB\n\x18\x01\x92\x41\x05x\n\x80\x01\x01\x12\x44\n\x06vector\x18\x07 \x03(\x02\x42\x34\x92\x41\x31J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\xa0\x9c\x01\x80\x01\x01\x12$\n\rsparse_vector\x18\t \x01(\x0b\x32\r.SparseValues\x12&\n\x02id\x18\x08 \x01(\tB\x1a\x92\x41\x17J\x12"example-vector-1"x\x80\x04"a\n\x12SingleQueryResults\x12\x1e\n\x07matches\x18\x01 \x03(\x0b\x32\r.ScoredVector\x12+\n\tnamespace\x18\x02 \x01(\tB\x18\x92\x41\x15J\x13"example-namespace""l\n\rQueryResponse\x12(\n\x07results\x18\x01 \x03(\x0b\x32\x13.SingleQueryResultsB\x02\x18\x01\x12\x1e\n\x07matches\x18\x02 \x03(\x0b\x32\r.ScoredVector\x12\x11\n\tnamespace\x18\x03 \x01(\t"\xb2\x02\n\rUpdateRequest\x12,\n\x02id\x18\x01 \x01(\tB \x92\x41\x1aJ\x12"example-vector-1"x\x80\x04\x80\x01\x01\xe0\x41\x02\x12\x44\n\x06values\x18\x02 \x03(\x02\x42\x34\x92\x41\x31J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\xa0\x9c\x01\x80\x01\x01\x12$\n\rsparse_values\x18\x05 \x01(\x0b\x32\r.SparseValues\x12Z\n\x0cset_metadata\x18\x03 \x01(\x0b\x32\x17.google.protobuf.StructB+\x92\x41(J&{"genre": "documentary", "year": 2019}\x12+\n\tnamespace\x18\x04 \x01(\tB\x18\x92\x41\x15J\x13"example-namespace""\x10\n\x0eUpdateResponse"D\n\x19\x44\x65scribeIndexStatsRequest\x12\'\n\x06\x66ilter\x18\x01 \x01(\x0b\x32\x17.google.protobuf.Struct"4\n\x10NamespaceSummary\x12 \n\x0cvector_count\x18\x01 \x01(\rB\n\x92\x41\x07J\x05\x35\x30\x30\x30\x30"\x9a\x03\n\x1a\x44\x65scribeIndexStatsResponse\x12?\n\nnamespaces\x18\x01 \x03(\x0b\x32+.DescribeIndexStatsResponse.NamespacesEntry\x12\x1c\n\tdimension\x18\x02 \x01(\rB\t\x92\x41\x06J\x04\x31\x30\x32\x34\x12 \n\x0eindex_fullness\x18\x03 \x01(\x02\x42\x08\x92\x41\x05J\x03\x30.4\x12&\n\x12total_vector_count\x18\x04 \x01(\rB\n\x92\x41\x07J\x05\x38\x30\x30\x30\x30\x1a\x44\n\x0fNamespacesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12 \n\x05value\x18\x02 \x01(\x0b\x32\x11.NamespaceSummary:\x02\x38\x01:\x8c\x01\x92\x41\x88\x01\x32\x85\x01{"namespaces": {"": {"vectorCount": 50000}, "example-namespace-2": {"vectorCount": 30000}}, "dimension": 1024, "index_fullness": 0.4}2\xbd\x05\n\rVectorService\x12\x63\n\x06Upsert\x12\x0e.UpsertRequest\x1a\x0f.UpsertResponse"8\x82\xd3\xe4\x93\x02\x14"\x0f/vectors/upsert:\x01*\x92\x41\x1b\n\x11Vector Operations*\x06upsert\x12v\n\x06\x44\x65lete\x12\x0e.DeleteRequest\x1a\x0f.DeleteResponse"K\x82\xd3\xe4\x93\x02\'"\x0f/vectors/delete:\x01*Z\x11*\x0f/vectors/delete\x92\x41\x1b\n\x11Vector Operations*\x06\x64\x65lete\x12[\n\x05\x46\x65tch\x12\r.FetchRequest\x1a\x0e.FetchResponse"3\x82\xd3\xe4\x93\x02\x10\x12\x0e/vectors/fetch\x92\x41\x1a\n\x11Vector Operations*\x05\x66\x65tch\x12V\n\x05Query\x12\r.QueryRequest\x1a\x0e.QueryResponse".\x82\xd3\xe4\x93\x02\x0b"\x06/query:\x01*\x92\x41\x1a\n\x11Vector Operations*\x05query\x12\x63\n\x06Update\x12\x0e.UpdateRequest\x1a\x0f.UpdateResponse"8\x82\xd3\xe4\x93\x02\x14"\x0f/vectors/update:\x01*\x92\x41\x1b\n\x11Vector Operations*\x06update\x12\xb4\x01\n\x12\x44\x65scribeIndexStats\x12\x1a.DescribeIndexStatsRequest\x1a\x1b.DescribeIndexStatsResponse"e\x82\xd3\xe4\x93\x02\x33"\x15/describe_index_stats:\x01*Z\x17\x12\x15/describe_index_stats\x92\x41)\n\x11Vector Operations*\x14\x64\x65scribe_index_statsB\xc0\x03\n\x11io.pinecone.protoP\x01Z/github.com/pinecone-io/new-go-pinecone/pinecone\x92\x41\xf6\x02\x12K\n\x0cPinecone API";\n\x0fPinecone.io Ops\x12\x13https://pinecone.io\x1a\x13support@pinecone.io\x1a\x39{index_name}-{project_name}.svc.{environment}.pinecone.io*\x01\x02\x32\x10\x61pplication/json:\x10\x61pplication/jsonZx\nv\n\nApiKeyAuth\x12h\x08\x02\x12YAn API Key is required to call Pinecone APIs. Get yours at https://www.pinecone.io/start/\x1a\x07\x41pi-Key \x02\x62\x10\n\x0e\n\nApiKeyAuth\x12\x00r9\n\x19More Pinecone.io API docs\x12\x1chttps://www.pinecone.io/docsb\x06proto3', - dependencies=[ - google_dot_protobuf_dot_struct__pb2.DESCRIPTOR, - google_dot_api_dot_annotations__pb2.DESCRIPTOR, - google_dot_api_dot_field__behavior__pb2.DESCRIPTOR, - protoc__gen__openapiv2_dot_options_dot_annotations__pb2.DESCRIPTOR, - ], -) + name='vector_service.proto', + package='', + syntax='proto3', + serialized_options=b'\n\021io.pinecone.protoP\001Z/github.com/pinecone-io/new-go-pinecone/pinecone\222A\366\002\022K\n\014Pinecone API\";\n\017Pinecone.io Ops\022\023https://pinecone.io\032\023support@pinecone.io\0329{index_name}-{project_name}.svc.{environment}.pinecone.io*\001\0022\020application/json:\020application/jsonZx\nv\n\nApiKeyAuth\022h\010\002\022YAn API Key is required to call Pinecone APIs. Get yours at https://www.pinecone.io/start/\032\007Api-Key \002b\020\n\016\n\nApiKeyAuth\022\000r9\n\031More Pinecone.io API docs\022\034https://www.pinecone.io/docs', + create_key=_descriptor._internal_create_key, + serialized_pb=b'\n\x14vector_service.proto\x1a\x1cgoogle/protobuf/struct.proto\x1a\x1cgoogle/api/annotations.proto\x1a\x1fgoogle/api/field_behavior.proto\x1a.protoc-gen-openapiv2/options/annotations.proto\"~\n\x0cSparseValues\x12\x35\n\x07indices\x18\x01 \x03(\rB$\x92\x41\x1eJ\x16[1, 312, 822, 14, 980]x\xe8\x07\x80\x01\x01\xe0\x41\x02\x12\x37\n\x06values\x18\x02 \x03(\x02\x42\'\x92\x41!J\x19[0.1, 0.2, 0.3, 0.4, 0.5]x\xe8\x07\x80\x01\x01\xe0\x41\x02\"\xfd\x01\n\x06Vector\x12,\n\x02id\x18\x01 \x01(\tB \x92\x41\x1aJ\x12\"example-vector-1\"x\x80\x04\x80\x01\x01\xe0\x41\x02\x12G\n\x06values\x18\x02 \x03(\x02\x42\x37\x92\x41\x31J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\xa0\x9c\x01\x80\x01\x01\xe0\x41\x02\x12$\n\rsparse_values\x18\x04 \x01(\x0b\x32\r.SparseValues\x12V\n\x08metadata\x18\x03 \x01(\x0b\x32\x17.google.protobuf.StructB+\x92\x41(J&{\"genre\": \"documentary\", \"year\": 2019}\"\x93\x02\n\x0cScoredVector\x12,\n\x02id\x18\x01 \x01(\tB \x92\x41\x1aJ\x12\"example-vector-1\"x\x80\x04\x80\x01\x01\xe0\x41\x02\x12\x18\n\x05score\x18\x02 \x01(\x02\x42\t\x92\x41\x06J\x04\x30.08\x12=\n\x06values\x18\x03 \x03(\x02\x42-\x92\x41*J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]\x12$\n\rsparse_values\x18\x05 \x01(\x0b\x32\r.SparseValues\x12V\n\x08metadata\x18\x04 \x01(\x0b\x32\x17.google.protobuf.StructB+\x92\x41(J&{\"genre\": \"documentary\", \"year\": 2019}\"d\n\rUpsertRequest\x12&\n\x07vectors\x18\x01 \x03(\x0b\x32\x07.VectorB\x0c\x92\x41\x06x\xe8\x07\x80\x01\x01\xe0\x41\x02\x12+\n\tnamespace\x18\x02 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\"1\n\x0eUpsertResponse\x12\x1f\n\x0eupserted_count\x18\x01 \x01(\rB\x07\x92\x41\x04J\x02\x31\x30\"\xb6\x01\n\rDeleteRequest\x12(\n\x03ids\x18\x01 \x03(\tB\x1b\x92\x41\x18J\x10[\"id-0\", \"id-1\"]x\xe8\x07\x80\x01\x01\x12%\n\ndelete_all\x18\x02 \x01(\x08\x42\x11\x92\x41\x0e:\x05\x66\x61lseJ\x05\x66\x61lse\x12+\n\tnamespace\x18\x03 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\x12\'\n\x06\x66ilter\x18\x04 \x01(\x0b\x32\x17.google.protobuf.Struct\"\x10\n\x0e\x44\x65leteResponse\"h\n\x0c\x46\x65tchRequest\x12+\n\x03ids\x18\x01 \x03(\tB\x1e\x92\x41\x18J\x10[\"id-0\", \"id-1\"]x\xe8\x07\x80\x01\x01\xe0\x41\x02\x12+\n\tnamespace\x18\x02 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\"\xa3\x01\n\rFetchResponse\x12,\n\x07vectors\x18\x01 \x03(\x0b\x32\x1b.FetchResponse.VectorsEntry\x12+\n\tnamespace\x18\x02 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\x1a\x37\n\x0cVectorsEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12\x16\n\x05value\x18\x02 \x01(\x0b\x32\x07.Vector:\x02\x38\x01\"\xd0\x02\n\x0bQueryVector\x12G\n\x06values\x18\x01 \x03(\x02\x42\x37\x92\x41\x31J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\xa0\x9c\x01\x80\x01\x01\xe0\x41\x02\x12$\n\rsparse_values\x18\x05 \x01(\x0b\x32\r.SparseValues\x12(\n\x05top_k\x18\x02 \x01(\rB\x19\x92\x41\x16J\x02\x31\x30Y\x00\x00\x00\x00\x00\x88\xc3@i\x00\x00\x00\x00\x00\x00\xf0?\x12+\n\tnamespace\x18\x03 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\x12{\n\x06\x66ilter\x18\x04 \x01(\x0b\x32\x17.google.protobuf.StructBR\x92\x41OJM{\"genre\": {\"$in\": [\"comedy\", \"documentary\", \"drama\"]}, \"year\": {\"$eq\": 2019}}\"\xfa\x03\n\x0cQueryRequest\x12+\n\tnamespace\x18\x01 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\x12+\n\x05top_k\x18\x02 \x01(\rB\x1c\x92\x41\x16J\x02\x31\x30Y\x00\x00\x00\x00\x00\x88\xc3@i\x00\x00\x00\x00\x00\x00\xf0?\xe0\x41\x02\x12{\n\x06\x66ilter\x18\x03 \x01(\x0b\x32\x17.google.protobuf.StructBR\x92\x41OJM{\"genre\": {\"$in\": [\"comedy\", \"documentary\", \"drama\"]}, \"year\": {\"$eq\": 2019}}\x12(\n\x0einclude_values\x18\x04 \x01(\x08\x42\x10\x92\x41\r:\x05\x66\x61lseJ\x04true\x12*\n\x10include_metadata\x18\x05 \x01(\x08\x42\x10\x92\x41\r:\x05\x66\x61lseJ\x04true\x12)\n\x07queries\x18\x06 \x03(\x0b\x32\x0c.QueryVectorB\n\x18\x01\x92\x41\x05x\n\x80\x01\x01\x12\x44\n\x06vector\x18\x07 \x03(\x02\x42\x34\x92\x41\x31J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\xa0\x9c\x01\x80\x01\x01\x12$\n\rsparse_vector\x18\t \x01(\x0b\x32\r.SparseValues\x12&\n\x02id\x18\x08 \x01(\tB\x1a\x92\x41\x17J\x12\"example-vector-1\"x\x80\x04\"a\n\x12SingleQueryResults\x12\x1e\n\x07matches\x18\x01 \x03(\x0b\x32\r.ScoredVector\x12+\n\tnamespace\x18\x02 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\"l\n\rQueryResponse\x12(\n\x07results\x18\x01 \x03(\x0b\x32\x13.SingleQueryResultsB\x02\x18\x01\x12\x1e\n\x07matches\x18\x02 \x03(\x0b\x32\r.ScoredVector\x12\x11\n\tnamespace\x18\x03 \x01(\t\"\xb2\x02\n\rUpdateRequest\x12,\n\x02id\x18\x01 \x01(\tB \x92\x41\x1aJ\x12\"example-vector-1\"x\x80\x04\x80\x01\x01\xe0\x41\x02\x12\x44\n\x06values\x18\x02 \x03(\x02\x42\x34\x92\x41\x31J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\xa0\x9c\x01\x80\x01\x01\x12$\n\rsparse_values\x18\x05 \x01(\x0b\x32\r.SparseValues\x12Z\n\x0cset_metadata\x18\x03 \x01(\x0b\x32\x17.google.protobuf.StructB+\x92\x41(J&{\"genre\": \"documentary\", \"year\": 2019}\x12+\n\tnamespace\x18\x04 \x01(\tB\x18\x92\x41\x15J\x13\"example-namespace\"\"\x10\n\x0eUpdateResponse\"D\n\x19\x44\x65scribeIndexStatsRequest\x12\'\n\x06\x66ilter\x18\x01 \x01(\x0b\x32\x17.google.protobuf.Struct\"4\n\x10NamespaceSummary\x12 \n\x0cvector_count\x18\x01 \x01(\rB\n\x92\x41\x07J\x05\x35\x30\x30\x30\x30\"\x9a\x03\n\x1a\x44\x65scribeIndexStatsResponse\x12?\n\nnamespaces\x18\x01 \x03(\x0b\x32+.DescribeIndexStatsResponse.NamespacesEntry\x12\x1c\n\tdimension\x18\x02 \x01(\rB\t\x92\x41\x06J\x04\x31\x30\x32\x34\x12 \n\x0eindex_fullness\x18\x03 \x01(\x02\x42\x08\x92\x41\x05J\x03\x30.4\x12&\n\x12total_vector_count\x18\x04 \x01(\rB\n\x92\x41\x07J\x05\x38\x30\x30\x30\x30\x1a\x44\n\x0fNamespacesEntry\x12\x0b\n\x03key\x18\x01 \x01(\t\x12 \n\x05value\x18\x02 \x01(\x0b\x32\x11.NamespaceSummary:\x02\x38\x01:\x8c\x01\x92\x41\x88\x01\x32\x85\x01{\"namespaces\": {\"\": {\"vectorCount\": 50000}, \"example-namespace-2\": {\"vectorCount\": 30000}}, \"dimension\": 1024, \"index_fullness\": 0.4}2\xbd\x05\n\rVectorService\x12\x63\n\x06Upsert\x12\x0e.UpsertRequest\x1a\x0f.UpsertResponse\"8\x82\xd3\xe4\x93\x02\x14\"\x0f/vectors/upsert:\x01*\x92\x41\x1b\n\x11Vector Operations*\x06upsert\x12v\n\x06\x44\x65lete\x12\x0e.DeleteRequest\x1a\x0f.DeleteResponse\"K\x82\xd3\xe4\x93\x02\'\"\x0f/vectors/delete:\x01*Z\x11*\x0f/vectors/delete\x92\x41\x1b\n\x11Vector Operations*\x06\x64\x65lete\x12[\n\x05\x46\x65tch\x12\r.FetchRequest\x1a\x0e.FetchResponse\"3\x82\xd3\xe4\x93\x02\x10\x12\x0e/vectors/fetch\x92\x41\x1a\n\x11Vector Operations*\x05\x66\x65tch\x12V\n\x05Query\x12\r.QueryRequest\x1a\x0e.QueryResponse\".\x82\xd3\xe4\x93\x02\x0b\"\x06/query:\x01*\x92\x41\x1a\n\x11Vector Operations*\x05query\x12\x63\n\x06Update\x12\x0e.UpdateRequest\x1a\x0f.UpdateResponse\"8\x82\xd3\xe4\x93\x02\x14\"\x0f/vectors/update:\x01*\x92\x41\x1b\n\x11Vector Operations*\x06update\x12\xb4\x01\n\x12\x44\x65scribeIndexStats\x12\x1a.DescribeIndexStatsRequest\x1a\x1b.DescribeIndexStatsResponse\"e\x82\xd3\xe4\x93\x02\x33\"\x15/describe_index_stats:\x01*Z\x17\x12\x15/describe_index_stats\x92\x41)\n\x11Vector Operations*\x14\x64\x65scribe_index_statsB\xc0\x03\n\x11io.pinecone.protoP\x01Z/github.com/pinecone-io/new-go-pinecone/pinecone\x92\x41\xf6\x02\x12K\n\x0cPinecone API\";\n\x0fPinecone.io Ops\x12\x13https://pinecone.io\x1a\x13support@pinecone.io\x1a\x39{index_name}-{project_name}.svc.{environment}.pinecone.io*\x01\x02\x32\x10\x61pplication/json:\x10\x61pplication/jsonZx\nv\n\nApiKeyAuth\x12h\x08\x02\x12YAn API Key is required to call Pinecone APIs. Get yours at https://www.pinecone.io/start/\x1a\x07\x41pi-Key \x02\x62\x10\n\x0e\n\nApiKeyAuth\x12\x00r9\n\x19More Pinecone.io API docs\x12\x1chttps://www.pinecone.io/docsb\x06proto3' + , + dependencies=[google_dot_protobuf_dot_struct__pb2.DESCRIPTOR,google_dot_api_dot_annotations__pb2.DESCRIPTOR,google_dot_api_dot_field__behavior__pb2.DESCRIPTOR,protoc__gen__openapiv2_dot_options_dot_annotations__pb2.DESCRIPTOR,]) + + _SPARSEVALUES = _descriptor.Descriptor( - name="SparseValues", - full_name="SparseValues", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="indices", - full_name="SparseValues.indices", - index=0, - number=1, - type=13, - cpp_type=3, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b"\222A\036J\026[1, 312, 822, 14, 980]x\350\007\200\001\001\340A\002", - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="values", - full_name="SparseValues.values", - index=1, - number=2, - type=2, - cpp_type=6, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b"\222A!J\031[0.1, 0.2, 0.3, 0.4, 0.5]x\350\007\200\001\001\340A\002", - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=165, - serialized_end=291, + name='SparseValues', + full_name='SparseValues', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='indices', full_name='SparseValues.indices', index=0, + number=1, type=13, cpp_type=3, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\036J\026[1, 312, 822, 14, 980]x\350\007\200\001\001\340A\002', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='values', full_name='SparseValues.values', index=1, + number=2, type=2, cpp_type=6, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A!J\031[0.1, 0.2, 0.3, 0.4, 0.5]x\350\007\200\001\001\340A\002', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=165, + serialized_end=291, ) _VECTOR = _descriptor.Descriptor( - name="Vector", - full_name="Vector", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="id", - full_name="Vector.id", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b'\222A\032J\022"example-vector-1"x\200\004\200\001\001\340A\002', - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="values", - full_name="Vector.values", - index=1, - number=2, - type=2, - cpp_type=6, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b"\222A1J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\240\234\001\200\001\001\340A\002", - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="sparse_values", - full_name="Vector.sparse_values", - index=2, - number=4, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="metadata", - full_name="Vector.metadata", - index=3, - number=3, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b'\222A(J&{"genre": "documentary", "year": 2019}', - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=294, - serialized_end=547, + name='Vector', + full_name='Vector', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='id', full_name='Vector.id', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=b"".decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\032J\022\"example-vector-1\"x\200\004\200\001\001\340A\002', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='values', full_name='Vector.values', index=1, + number=2, type=2, cpp_type=6, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A1J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\240\234\001\200\001\001\340A\002', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='sparse_values', full_name='Vector.sparse_values', index=2, + number=4, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='metadata', full_name='Vector.metadata', index=3, + number=3, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A(J&{\"genre\": \"documentary\", \"year\": 2019}', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=294, + serialized_end=547, ) _SCOREDVECTOR = _descriptor.Descriptor( - name="ScoredVector", - full_name="ScoredVector", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="id", - full_name="ScoredVector.id", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b'\222A\032J\022"example-vector-1"x\200\004\200\001\001\340A\002', - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="score", - full_name="ScoredVector.score", - index=1, - number=2, - type=2, - cpp_type=6, - label=1, - has_default_value=False, - default_value=float(0), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b"\222A\006J\0040.08", - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="values", - full_name="ScoredVector.values", - index=2, - number=3, - type=2, - cpp_type=6, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b"\222A*J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]", - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="sparse_values", - full_name="ScoredVector.sparse_values", - index=3, - number=5, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="metadata", - full_name="ScoredVector.metadata", - index=4, - number=4, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b'\222A(J&{"genre": "documentary", "year": 2019}', - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=550, - serialized_end=825, + name='ScoredVector', + full_name='ScoredVector', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='id', full_name='ScoredVector.id', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=b"".decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\032J\022\"example-vector-1\"x\200\004\200\001\001\340A\002', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='score', full_name='ScoredVector.score', index=1, + number=2, type=2, cpp_type=6, label=1, + has_default_value=False, default_value=float(0), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\006J\0040.08', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='values', full_name='ScoredVector.values', index=2, + number=3, type=2, cpp_type=6, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A*J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='sparse_values', full_name='ScoredVector.sparse_values', index=3, + number=5, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='metadata', full_name='ScoredVector.metadata', index=4, + number=4, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A(J&{\"genre\": \"documentary\", \"year\": 2019}', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=550, + serialized_end=825, ) _UPSERTREQUEST = _descriptor.Descriptor( - name="UpsertRequest", - full_name="UpsertRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="vectors", - full_name="UpsertRequest.vectors", - index=0, - number=1, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b"\222A\006x\350\007\200\001\001\340A\002", - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="namespace", - full_name="UpsertRequest.namespace", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b'\222A\025J\023"example-namespace"', - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=827, - serialized_end=927, + name='UpsertRequest', + full_name='UpsertRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='vectors', full_name='UpsertRequest.vectors', index=0, + number=1, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\006x\350\007\200\001\001\340A\002', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='namespace', full_name='UpsertRequest.namespace', index=1, + number=2, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=b"".decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\025J\023\"example-namespace\"', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=827, + serialized_end=927, ) _UPSERTRESPONSE = _descriptor.Descriptor( - name="UpsertResponse", - full_name="UpsertResponse", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="upserted_count", - full_name="UpsertResponse.upserted_count", - index=0, - number=1, - type=13, - cpp_type=3, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b"\222A\004J\00210", - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=929, - serialized_end=978, + name='UpsertResponse', + full_name='UpsertResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='upserted_count', full_name='UpsertResponse.upserted_count', index=0, + number=1, type=13, cpp_type=3, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\004J\00210', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=929, + serialized_end=978, ) _DELETEREQUEST = _descriptor.Descriptor( - name="DeleteRequest", - full_name="DeleteRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="ids", - full_name="DeleteRequest.ids", - index=0, - number=1, - type=9, - cpp_type=9, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b'\222A\030J\020["id-0", "id-1"]x\350\007\200\001\001', - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="delete_all", - full_name="DeleteRequest.delete_all", - index=1, - number=2, - type=8, - cpp_type=7, - label=1, - has_default_value=False, - default_value=False, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b"\222A\016:\005falseJ\005false", - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="namespace", - full_name="DeleteRequest.namespace", - index=2, - number=3, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b'\222A\025J\023"example-namespace"', - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="filter", - full_name="DeleteRequest.filter", - index=3, - number=4, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=981, - serialized_end=1163, + name='DeleteRequest', + full_name='DeleteRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='ids', full_name='DeleteRequest.ids', index=0, + number=1, type=9, cpp_type=9, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\030J\020[\"id-0\", \"id-1\"]x\350\007\200\001\001', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='delete_all', full_name='DeleteRequest.delete_all', index=1, + number=2, type=8, cpp_type=7, label=1, + has_default_value=False, default_value=False, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\016:\005falseJ\005false', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='namespace', full_name='DeleteRequest.namespace', index=2, + number=3, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=b"".decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\025J\023\"example-namespace\"', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='filter', full_name='DeleteRequest.filter', index=3, + number=4, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=981, + serialized_end=1163, ) _DELETERESPONSE = _descriptor.Descriptor( - name="DeleteResponse", - full_name="DeleteResponse", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1165, - serialized_end=1181, + name='DeleteResponse', + full_name='DeleteResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1165, + serialized_end=1181, ) _FETCHREQUEST = _descriptor.Descriptor( - name="FetchRequest", - full_name="FetchRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="ids", - full_name="FetchRequest.ids", - index=0, - number=1, - type=9, - cpp_type=9, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b'\222A\030J\020["id-0", "id-1"]x\350\007\200\001\001\340A\002', - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="namespace", - full_name="FetchRequest.namespace", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b'\222A\025J\023"example-namespace"', - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1183, - serialized_end=1287, + name='FetchRequest', + full_name='FetchRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='ids', full_name='FetchRequest.ids', index=0, + number=1, type=9, cpp_type=9, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\030J\020[\"id-0\", \"id-1\"]x\350\007\200\001\001\340A\002', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='namespace', full_name='FetchRequest.namespace', index=1, + number=2, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=b"".decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\025J\023\"example-namespace\"', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1183, + serialized_end=1287, ) _FETCHRESPONSE_VECTORSENTRY = _descriptor.Descriptor( - name="VectorsEntry", - full_name="FetchResponse.VectorsEntry", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="key", - full_name="FetchResponse.VectorsEntry.key", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="value", - full_name="FetchResponse.VectorsEntry.value", - index=1, - number=2, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=b"8\001", - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1398, - serialized_end=1453, + name='VectorsEntry', + full_name='FetchResponse.VectorsEntry', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='key', full_name='FetchResponse.VectorsEntry.key', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=b"".decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='value', full_name='FetchResponse.VectorsEntry.value', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=b'8\001', + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1398, + serialized_end=1453, ) _FETCHRESPONSE = _descriptor.Descriptor( - name="FetchResponse", - full_name="FetchResponse", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="vectors", - full_name="FetchResponse.vectors", - index=0, - number=1, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="namespace", - full_name="FetchResponse.namespace", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b'\222A\025J\023"example-namespace"', - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[ - _FETCHRESPONSE_VECTORSENTRY, - ], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1290, - serialized_end=1453, + name='FetchResponse', + full_name='FetchResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='vectors', full_name='FetchResponse.vectors', index=0, + number=1, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='namespace', full_name='FetchResponse.namespace', index=1, + number=2, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=b"".decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\025J\023\"example-namespace\"', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[_FETCHRESPONSE_VECTORSENTRY, ], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1290, + serialized_end=1453, ) _QUERYVECTOR = _descriptor.Descriptor( - name="QueryVector", - full_name="QueryVector", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="values", - full_name="QueryVector.values", - index=0, - number=1, - type=2, - cpp_type=6, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b"\222A1J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\240\234\001\200\001\001\340A\002", - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="sparse_values", - full_name="QueryVector.sparse_values", - index=1, - number=5, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="top_k", - full_name="QueryVector.top_k", - index=2, - number=2, - type=13, - cpp_type=3, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b"\222A\026J\00210Y\000\000\000\000\000\210\303@i\000\000\000\000\000\000\360?", - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="namespace", - full_name="QueryVector.namespace", - index=3, - number=3, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b'\222A\025J\023"example-namespace"', - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="filter", - full_name="QueryVector.filter", - index=4, - number=4, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b'\222AOJM{"genre": {"$in": ["comedy", "documentary", "drama"]}, "year": {"$eq": 2019}}', - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1456, - serialized_end=1792, + name='QueryVector', + full_name='QueryVector', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='values', full_name='QueryVector.values', index=0, + number=1, type=2, cpp_type=6, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A1J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\240\234\001\200\001\001\340A\002', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='sparse_values', full_name='QueryVector.sparse_values', index=1, + number=5, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='top_k', full_name='QueryVector.top_k', index=2, + number=2, type=13, cpp_type=3, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\026J\00210Y\000\000\000\000\000\210\303@i\000\000\000\000\000\000\360?', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='namespace', full_name='QueryVector.namespace', index=3, + number=3, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=b"".decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\025J\023\"example-namespace\"', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='filter', full_name='QueryVector.filter', index=4, + number=4, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222AOJM{\"genre\": {\"$in\": [\"comedy\", \"documentary\", \"drama\"]}, \"year\": {\"$eq\": 2019}}', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1456, + serialized_end=1792, ) _QUERYREQUEST = _descriptor.Descriptor( - name="QueryRequest", - full_name="QueryRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="namespace", - full_name="QueryRequest.namespace", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b'\222A\025J\023"example-namespace"', - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="top_k", - full_name="QueryRequest.top_k", - index=1, - number=2, - type=13, - cpp_type=3, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b"\222A\026J\00210Y\000\000\000\000\000\210\303@i\000\000\000\000\000\000\360?\340A\002", - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="filter", - full_name="QueryRequest.filter", - index=2, - number=3, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b'\222AOJM{"genre": {"$in": ["comedy", "documentary", "drama"]}, "year": {"$eq": 2019}}', - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="include_values", - full_name="QueryRequest.include_values", - index=3, - number=4, - type=8, - cpp_type=7, - label=1, - has_default_value=False, - default_value=False, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b"\222A\r:\005falseJ\004true", - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="include_metadata", - full_name="QueryRequest.include_metadata", - index=4, - number=5, - type=8, - cpp_type=7, - label=1, - has_default_value=False, - default_value=False, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b"\222A\r:\005falseJ\004true", - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="queries", - full_name="QueryRequest.queries", - index=5, - number=6, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b"\030\001\222A\005x\n\200\001\001", - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="vector", - full_name="QueryRequest.vector", - index=6, - number=7, - type=2, - cpp_type=6, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b"\222A1J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\240\234\001\200\001\001", - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="sparse_vector", - full_name="QueryRequest.sparse_vector", - index=7, - number=9, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="id", - full_name="QueryRequest.id", - index=8, - number=8, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b'\222A\027J\022"example-vector-1"x\200\004', - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=1795, - serialized_end=2301, + name='QueryRequest', + full_name='QueryRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='namespace', full_name='QueryRequest.namespace', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=b"".decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\025J\023\"example-namespace\"', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='top_k', full_name='QueryRequest.top_k', index=1, + number=2, type=13, cpp_type=3, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\026J\00210Y\000\000\000\000\000\210\303@i\000\000\000\000\000\000\360?\340A\002', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='filter', full_name='QueryRequest.filter', index=2, + number=3, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222AOJM{\"genre\": {\"$in\": [\"comedy\", \"documentary\", \"drama\"]}, \"year\": {\"$eq\": 2019}}', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='include_values', full_name='QueryRequest.include_values', index=3, + number=4, type=8, cpp_type=7, label=1, + has_default_value=False, default_value=False, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\r:\005falseJ\004true', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='include_metadata', full_name='QueryRequest.include_metadata', index=4, + number=5, type=8, cpp_type=7, label=1, + has_default_value=False, default_value=False, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\r:\005falseJ\004true', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='queries', full_name='QueryRequest.queries', index=5, + number=6, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\030\001\222A\005x\n\200\001\001', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='vector', full_name='QueryRequest.vector', index=6, + number=7, type=2, cpp_type=6, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A1J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\240\234\001\200\001\001', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='sparse_vector', full_name='QueryRequest.sparse_vector', index=7, + number=9, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='id', full_name='QueryRequest.id', index=8, + number=8, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=b"".decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\027J\022\"example-vector-1\"x\200\004', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=1795, + serialized_end=2301, ) _SINGLEQUERYRESULTS = _descriptor.Descriptor( - name="SingleQueryResults", - full_name="SingleQueryResults", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="matches", - full_name="SingleQueryResults.matches", - index=0, - number=1, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="namespace", - full_name="SingleQueryResults.namespace", - index=1, - number=2, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b'\222A\025J\023"example-namespace"', - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=2303, - serialized_end=2400, + name='SingleQueryResults', + full_name='SingleQueryResults', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='matches', full_name='SingleQueryResults.matches', index=0, + number=1, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='namespace', full_name='SingleQueryResults.namespace', index=1, + number=2, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=b"".decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\025J\023\"example-namespace\"', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=2303, + serialized_end=2400, ) _QUERYRESPONSE = _descriptor.Descriptor( - name="QueryResponse", - full_name="QueryResponse", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="results", - full_name="QueryResponse.results", - index=0, - number=1, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b"\030\001", - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="matches", - full_name="QueryResponse.matches", - index=1, - number=2, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="namespace", - full_name="QueryResponse.namespace", - index=2, - number=3, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=2402, - serialized_end=2510, + name='QueryResponse', + full_name='QueryResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='results', full_name='QueryResponse.results', index=0, + number=1, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\030\001', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='matches', full_name='QueryResponse.matches', index=1, + number=2, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='namespace', full_name='QueryResponse.namespace', index=2, + number=3, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=b"".decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=2402, + serialized_end=2510, ) _UPDATEREQUEST = _descriptor.Descriptor( - name="UpdateRequest", - full_name="UpdateRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="id", - full_name="UpdateRequest.id", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b'\222A\032J\022"example-vector-1"x\200\004\200\001\001\340A\002', - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="values", - full_name="UpdateRequest.values", - index=1, - number=2, - type=2, - cpp_type=6, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b"\222A1J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\240\234\001\200\001\001", - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="sparse_values", - full_name="UpdateRequest.sparse_values", - index=2, - number=5, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="set_metadata", - full_name="UpdateRequest.set_metadata", - index=3, - number=3, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b'\222A(J&{"genre": "documentary", "year": 2019}', - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="namespace", - full_name="UpdateRequest.namespace", - index=4, - number=4, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b'\222A\025J\023"example-namespace"', - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=2513, - serialized_end=2819, + name='UpdateRequest', + full_name='UpdateRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='id', full_name='UpdateRequest.id', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=b"".decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\032J\022\"example-vector-1\"x\200\004\200\001\001\340A\002', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='values', full_name='UpdateRequest.values', index=1, + number=2, type=2, cpp_type=6, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A1J([0.1, 0.2, 0.3, 0.4, 0.5, 0.6, 0.7, 0.8]x\240\234\001\200\001\001', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='sparse_values', full_name='UpdateRequest.sparse_values', index=2, + number=5, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='set_metadata', full_name='UpdateRequest.set_metadata', index=3, + number=3, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A(J&{\"genre\": \"documentary\", \"year\": 2019}', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='namespace', full_name='UpdateRequest.namespace', index=4, + number=4, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=b"".decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\025J\023\"example-namespace\"', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=2513, + serialized_end=2819, ) _UPDATERESPONSE = _descriptor.Descriptor( - name="UpdateResponse", - full_name="UpdateResponse", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=2821, - serialized_end=2837, + name='UpdateResponse', + full_name='UpdateResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=2821, + serialized_end=2837, ) _DESCRIBEINDEXSTATSREQUEST = _descriptor.Descriptor( - name="DescribeIndexStatsRequest", - full_name="DescribeIndexStatsRequest", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="filter", - full_name="DescribeIndexStatsRequest.filter", - index=0, - number=1, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=2839, - serialized_end=2907, + name='DescribeIndexStatsRequest', + full_name='DescribeIndexStatsRequest', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='filter', full_name='DescribeIndexStatsRequest.filter', index=0, + number=1, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=2839, + serialized_end=2907, ) _NAMESPACESUMMARY = _descriptor.Descriptor( - name="NamespaceSummary", - full_name="NamespaceSummary", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="vector_count", - full_name="NamespaceSummary.vector_count", - index=0, - number=1, - type=13, - cpp_type=3, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b"\222A\007J\00550000", - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=None, - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=2909, - serialized_end=2961, + name='NamespaceSummary', + full_name='NamespaceSummary', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='vector_count', full_name='NamespaceSummary.vector_count', index=0, + number=1, type=13, cpp_type=3, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\007J\00550000', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=None, + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=2909, + serialized_end=2961, ) _DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY = _descriptor.Descriptor( - name="NamespacesEntry", - full_name="DescribeIndexStatsResponse.NamespacesEntry", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="key", - full_name="DescribeIndexStatsResponse.NamespacesEntry.key", - index=0, - number=1, - type=9, - cpp_type=9, - label=1, - has_default_value=False, - default_value=b"".decode("utf-8"), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="value", - full_name="DescribeIndexStatsResponse.NamespacesEntry.value", - index=1, - number=2, - type=11, - cpp_type=10, - label=1, - has_default_value=False, - default_value=None, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[], - enum_types=[], - serialized_options=b"8\001", - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=3163, - serialized_end=3231, + name='NamespacesEntry', + full_name='DescribeIndexStatsResponse.NamespacesEntry', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='key', full_name='DescribeIndexStatsResponse.NamespacesEntry.key', index=0, + number=1, type=9, cpp_type=9, label=1, + has_default_value=False, default_value=b"".decode('utf-8'), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='value', full_name='DescribeIndexStatsResponse.NamespacesEntry.value', index=1, + number=2, type=11, cpp_type=10, label=1, + has_default_value=False, default_value=None, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[], + enum_types=[ + ], + serialized_options=b'8\001', + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=3163, + serialized_end=3231, ) _DESCRIBEINDEXSTATSRESPONSE = _descriptor.Descriptor( - name="DescribeIndexStatsResponse", - full_name="DescribeIndexStatsResponse", - filename=None, - file=DESCRIPTOR, - containing_type=None, - create_key=_descriptor._internal_create_key, - fields=[ - _descriptor.FieldDescriptor( - name="namespaces", - full_name="DescribeIndexStatsResponse.namespaces", - index=0, - number=1, - type=11, - cpp_type=10, - label=3, - has_default_value=False, - default_value=[], - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=None, - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="dimension", - full_name="DescribeIndexStatsResponse.dimension", - index=1, - number=2, - type=13, - cpp_type=3, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b"\222A\006J\0041024", - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="index_fullness", - full_name="DescribeIndexStatsResponse.index_fullness", - index=2, - number=3, - type=2, - cpp_type=6, - label=1, - has_default_value=False, - default_value=float(0), - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b"\222A\005J\0030.4", - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - _descriptor.FieldDescriptor( - name="total_vector_count", - full_name="DescribeIndexStatsResponse.total_vector_count", - index=3, - number=4, - type=13, - cpp_type=3, - label=1, - has_default_value=False, - default_value=0, - message_type=None, - enum_type=None, - containing_type=None, - is_extension=False, - extension_scope=None, - serialized_options=b"\222A\007J\00580000", - file=DESCRIPTOR, - create_key=_descriptor._internal_create_key, - ), - ], - extensions=[], - nested_types=[ - _DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY, - ], - enum_types=[], - serialized_options=b'\222A\210\0012\205\001{"namespaces": {"": {"vectorCount": 50000}, "example-namespace-2": {"vectorCount": 30000}}, "dimension": 1024, "index_fullness": 0.4}', - is_extendable=False, - syntax="proto3", - extension_ranges=[], - oneofs=[], - serialized_start=2964, - serialized_end=3374, + name='DescribeIndexStatsResponse', + full_name='DescribeIndexStatsResponse', + filename=None, + file=DESCRIPTOR, + containing_type=None, + create_key=_descriptor._internal_create_key, + fields=[ + _descriptor.FieldDescriptor( + name='namespaces', full_name='DescribeIndexStatsResponse.namespaces', index=0, + number=1, type=11, cpp_type=10, label=3, + has_default_value=False, default_value=[], + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=None, file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='dimension', full_name='DescribeIndexStatsResponse.dimension', index=1, + number=2, type=13, cpp_type=3, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\006J\0041024', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='index_fullness', full_name='DescribeIndexStatsResponse.index_fullness', index=2, + number=3, type=2, cpp_type=6, label=1, + has_default_value=False, default_value=float(0), + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\005J\0030.4', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + _descriptor.FieldDescriptor( + name='total_vector_count', full_name='DescribeIndexStatsResponse.total_vector_count', index=3, + number=4, type=13, cpp_type=3, label=1, + has_default_value=False, default_value=0, + message_type=None, enum_type=None, containing_type=None, + is_extension=False, extension_scope=None, + serialized_options=b'\222A\007J\00580000', file=DESCRIPTOR, create_key=_descriptor._internal_create_key), + ], + extensions=[ + ], + nested_types=[_DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY, ], + enum_types=[ + ], + serialized_options=b'\222A\210\0012\205\001{\"namespaces\": {\"\": {\"vectorCount\": 50000}, \"example-namespace-2\": {\"vectorCount\": 30000}}, \"dimension\": 1024, \"index_fullness\": 0.4}', + is_extendable=False, + syntax='proto3', + extension_ranges=[], + oneofs=[ + ], + serialized_start=2964, + serialized_end=3374, ) -_VECTOR.fields_by_name["sparse_values"].message_type = _SPARSEVALUES -_VECTOR.fields_by_name["metadata"].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT -_SCOREDVECTOR.fields_by_name["sparse_values"].message_type = _SPARSEVALUES -_SCOREDVECTOR.fields_by_name["metadata"].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT -_UPSERTREQUEST.fields_by_name["vectors"].message_type = _VECTOR -_DELETEREQUEST.fields_by_name["filter"].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT -_FETCHRESPONSE_VECTORSENTRY.fields_by_name["value"].message_type = _VECTOR +_VECTOR.fields_by_name['sparse_values'].message_type = _SPARSEVALUES +_VECTOR.fields_by_name['metadata'].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT +_SCOREDVECTOR.fields_by_name['sparse_values'].message_type = _SPARSEVALUES +_SCOREDVECTOR.fields_by_name['metadata'].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT +_UPSERTREQUEST.fields_by_name['vectors'].message_type = _VECTOR +_DELETEREQUEST.fields_by_name['filter'].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT +_FETCHRESPONSE_VECTORSENTRY.fields_by_name['value'].message_type = _VECTOR _FETCHRESPONSE_VECTORSENTRY.containing_type = _FETCHRESPONSE -_FETCHRESPONSE.fields_by_name["vectors"].message_type = _FETCHRESPONSE_VECTORSENTRY -_QUERYVECTOR.fields_by_name["sparse_values"].message_type = _SPARSEVALUES -_QUERYVECTOR.fields_by_name["filter"].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT -_QUERYREQUEST.fields_by_name["filter"].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT -_QUERYREQUEST.fields_by_name["queries"].message_type = _QUERYVECTOR -_QUERYREQUEST.fields_by_name["sparse_vector"].message_type = _SPARSEVALUES -_SINGLEQUERYRESULTS.fields_by_name["matches"].message_type = _SCOREDVECTOR -_QUERYRESPONSE.fields_by_name["results"].message_type = _SINGLEQUERYRESULTS -_QUERYRESPONSE.fields_by_name["matches"].message_type = _SCOREDVECTOR -_UPDATEREQUEST.fields_by_name["sparse_values"].message_type = _SPARSEVALUES -_UPDATEREQUEST.fields_by_name["set_metadata"].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT -_DESCRIBEINDEXSTATSREQUEST.fields_by_name["filter"].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT -_DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY.fields_by_name["value"].message_type = _NAMESPACESUMMARY +_FETCHRESPONSE.fields_by_name['vectors'].message_type = _FETCHRESPONSE_VECTORSENTRY +_QUERYVECTOR.fields_by_name['sparse_values'].message_type = _SPARSEVALUES +_QUERYVECTOR.fields_by_name['filter'].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT +_QUERYREQUEST.fields_by_name['filter'].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT +_QUERYREQUEST.fields_by_name['queries'].message_type = _QUERYVECTOR +_QUERYREQUEST.fields_by_name['sparse_vector'].message_type = _SPARSEVALUES +_SINGLEQUERYRESULTS.fields_by_name['matches'].message_type = _SCOREDVECTOR +_QUERYRESPONSE.fields_by_name['results'].message_type = _SINGLEQUERYRESULTS +_QUERYRESPONSE.fields_by_name['matches'].message_type = _SCOREDVECTOR +_UPDATEREQUEST.fields_by_name['sparse_values'].message_type = _SPARSEVALUES +_UPDATEREQUEST.fields_by_name['set_metadata'].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT +_DESCRIBEINDEXSTATSREQUEST.fields_by_name['filter'].message_type = google_dot_protobuf_dot_struct__pb2._STRUCT +_DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY.fields_by_name['value'].message_type = _NAMESPACESUMMARY _DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY.containing_type = _DESCRIBEINDEXSTATSRESPONSE -_DESCRIBEINDEXSTATSRESPONSE.fields_by_name["namespaces"].message_type = _DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY -DESCRIPTOR.message_types_by_name["SparseValues"] = _SPARSEVALUES -DESCRIPTOR.message_types_by_name["Vector"] = _VECTOR -DESCRIPTOR.message_types_by_name["ScoredVector"] = _SCOREDVECTOR -DESCRIPTOR.message_types_by_name["UpsertRequest"] = _UPSERTREQUEST -DESCRIPTOR.message_types_by_name["UpsertResponse"] = _UPSERTRESPONSE -DESCRIPTOR.message_types_by_name["DeleteRequest"] = _DELETEREQUEST -DESCRIPTOR.message_types_by_name["DeleteResponse"] = _DELETERESPONSE -DESCRIPTOR.message_types_by_name["FetchRequest"] = _FETCHREQUEST -DESCRIPTOR.message_types_by_name["FetchResponse"] = _FETCHRESPONSE -DESCRIPTOR.message_types_by_name["QueryVector"] = _QUERYVECTOR -DESCRIPTOR.message_types_by_name["QueryRequest"] = _QUERYREQUEST -DESCRIPTOR.message_types_by_name["SingleQueryResults"] = _SINGLEQUERYRESULTS -DESCRIPTOR.message_types_by_name["QueryResponse"] = _QUERYRESPONSE -DESCRIPTOR.message_types_by_name["UpdateRequest"] = _UPDATEREQUEST -DESCRIPTOR.message_types_by_name["UpdateResponse"] = _UPDATERESPONSE -DESCRIPTOR.message_types_by_name["DescribeIndexStatsRequest"] = _DESCRIBEINDEXSTATSREQUEST -DESCRIPTOR.message_types_by_name["NamespaceSummary"] = _NAMESPACESUMMARY -DESCRIPTOR.message_types_by_name["DescribeIndexStatsResponse"] = _DESCRIBEINDEXSTATSRESPONSE +_DESCRIBEINDEXSTATSRESPONSE.fields_by_name['namespaces'].message_type = _DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY +DESCRIPTOR.message_types_by_name['SparseValues'] = _SPARSEVALUES +DESCRIPTOR.message_types_by_name['Vector'] = _VECTOR +DESCRIPTOR.message_types_by_name['ScoredVector'] = _SCOREDVECTOR +DESCRIPTOR.message_types_by_name['UpsertRequest'] = _UPSERTREQUEST +DESCRIPTOR.message_types_by_name['UpsertResponse'] = _UPSERTRESPONSE +DESCRIPTOR.message_types_by_name['DeleteRequest'] = _DELETEREQUEST +DESCRIPTOR.message_types_by_name['DeleteResponse'] = _DELETERESPONSE +DESCRIPTOR.message_types_by_name['FetchRequest'] = _FETCHREQUEST +DESCRIPTOR.message_types_by_name['FetchResponse'] = _FETCHRESPONSE +DESCRIPTOR.message_types_by_name['QueryVector'] = _QUERYVECTOR +DESCRIPTOR.message_types_by_name['QueryRequest'] = _QUERYREQUEST +DESCRIPTOR.message_types_by_name['SingleQueryResults'] = _SINGLEQUERYRESULTS +DESCRIPTOR.message_types_by_name['QueryResponse'] = _QUERYRESPONSE +DESCRIPTOR.message_types_by_name['UpdateRequest'] = _UPDATEREQUEST +DESCRIPTOR.message_types_by_name['UpdateResponse'] = _UPDATERESPONSE +DESCRIPTOR.message_types_by_name['DescribeIndexStatsRequest'] = _DESCRIBEINDEXSTATSREQUEST +DESCRIPTOR.message_types_by_name['NamespaceSummary'] = _NAMESPACESUMMARY +DESCRIPTOR.message_types_by_name['DescribeIndexStatsResponse'] = _DESCRIBEINDEXSTATSRESPONSE _sym_db.RegisterFileDescriptor(DESCRIPTOR) -SparseValues = _reflection.GeneratedProtocolMessageType( - "SparseValues", - (_message.Message,), - { - "DESCRIPTOR": _SPARSEVALUES, - "__module__": "vector_service_pb2" - # @@protoc_insertion_point(class_scope:SparseValues) - }, -) +SparseValues = _reflection.GeneratedProtocolMessageType('SparseValues', (_message.Message,), { + 'DESCRIPTOR' : _SPARSEVALUES, + '__module__' : 'vector_service_pb2' + # @@protoc_insertion_point(class_scope:SparseValues) + }) _sym_db.RegisterMessage(SparseValues) -Vector = _reflection.GeneratedProtocolMessageType( - "Vector", - (_message.Message,), - { - "DESCRIPTOR": _VECTOR, - "__module__": "vector_service_pb2" - # @@protoc_insertion_point(class_scope:Vector) - }, -) +Vector = _reflection.GeneratedProtocolMessageType('Vector', (_message.Message,), { + 'DESCRIPTOR' : _VECTOR, + '__module__' : 'vector_service_pb2' + # @@protoc_insertion_point(class_scope:Vector) + }) _sym_db.RegisterMessage(Vector) -ScoredVector = _reflection.GeneratedProtocolMessageType( - "ScoredVector", - (_message.Message,), - { - "DESCRIPTOR": _SCOREDVECTOR, - "__module__": "vector_service_pb2" - # @@protoc_insertion_point(class_scope:ScoredVector) - }, -) +ScoredVector = _reflection.GeneratedProtocolMessageType('ScoredVector', (_message.Message,), { + 'DESCRIPTOR' : _SCOREDVECTOR, + '__module__' : 'vector_service_pb2' + # @@protoc_insertion_point(class_scope:ScoredVector) + }) _sym_db.RegisterMessage(ScoredVector) -UpsertRequest = _reflection.GeneratedProtocolMessageType( - "UpsertRequest", - (_message.Message,), - { - "DESCRIPTOR": _UPSERTREQUEST, - "__module__": "vector_service_pb2" - # @@protoc_insertion_point(class_scope:UpsertRequest) - }, -) +UpsertRequest = _reflection.GeneratedProtocolMessageType('UpsertRequest', (_message.Message,), { + 'DESCRIPTOR' : _UPSERTREQUEST, + '__module__' : 'vector_service_pb2' + # @@protoc_insertion_point(class_scope:UpsertRequest) + }) _sym_db.RegisterMessage(UpsertRequest) -UpsertResponse = _reflection.GeneratedProtocolMessageType( - "UpsertResponse", - (_message.Message,), - { - "DESCRIPTOR": _UPSERTRESPONSE, - "__module__": "vector_service_pb2" - # @@protoc_insertion_point(class_scope:UpsertResponse) - }, -) +UpsertResponse = _reflection.GeneratedProtocolMessageType('UpsertResponse', (_message.Message,), { + 'DESCRIPTOR' : _UPSERTRESPONSE, + '__module__' : 'vector_service_pb2' + # @@protoc_insertion_point(class_scope:UpsertResponse) + }) _sym_db.RegisterMessage(UpsertResponse) -DeleteRequest = _reflection.GeneratedProtocolMessageType( - "DeleteRequest", - (_message.Message,), - { - "DESCRIPTOR": _DELETEREQUEST, - "__module__": "vector_service_pb2" - # @@protoc_insertion_point(class_scope:DeleteRequest) - }, -) +DeleteRequest = _reflection.GeneratedProtocolMessageType('DeleteRequest', (_message.Message,), { + 'DESCRIPTOR' : _DELETEREQUEST, + '__module__' : 'vector_service_pb2' + # @@protoc_insertion_point(class_scope:DeleteRequest) + }) _sym_db.RegisterMessage(DeleteRequest) -DeleteResponse = _reflection.GeneratedProtocolMessageType( - "DeleteResponse", - (_message.Message,), - { - "DESCRIPTOR": _DELETERESPONSE, - "__module__": "vector_service_pb2" - # @@protoc_insertion_point(class_scope:DeleteResponse) - }, -) +DeleteResponse = _reflection.GeneratedProtocolMessageType('DeleteResponse', (_message.Message,), { + 'DESCRIPTOR' : _DELETERESPONSE, + '__module__' : 'vector_service_pb2' + # @@protoc_insertion_point(class_scope:DeleteResponse) + }) _sym_db.RegisterMessage(DeleteResponse) -FetchRequest = _reflection.GeneratedProtocolMessageType( - "FetchRequest", - (_message.Message,), - { - "DESCRIPTOR": _FETCHREQUEST, - "__module__": "vector_service_pb2" - # @@protoc_insertion_point(class_scope:FetchRequest) - }, -) +FetchRequest = _reflection.GeneratedProtocolMessageType('FetchRequest', (_message.Message,), { + 'DESCRIPTOR' : _FETCHREQUEST, + '__module__' : 'vector_service_pb2' + # @@protoc_insertion_point(class_scope:FetchRequest) + }) _sym_db.RegisterMessage(FetchRequest) -FetchResponse = _reflection.GeneratedProtocolMessageType( - "FetchResponse", - (_message.Message,), - { - "VectorsEntry": _reflection.GeneratedProtocolMessageType( - "VectorsEntry", - (_message.Message,), - { - "DESCRIPTOR": _FETCHRESPONSE_VECTORSENTRY, - "__module__": "vector_service_pb2" - # @@protoc_insertion_point(class_scope:FetchResponse.VectorsEntry) - }, - ), - "DESCRIPTOR": _FETCHRESPONSE, - "__module__": "vector_service_pb2" - # @@protoc_insertion_point(class_scope:FetchResponse) - }, -) +FetchResponse = _reflection.GeneratedProtocolMessageType('FetchResponse', (_message.Message,), { + + 'VectorsEntry' : _reflection.GeneratedProtocolMessageType('VectorsEntry', (_message.Message,), { + 'DESCRIPTOR' : _FETCHRESPONSE_VECTORSENTRY, + '__module__' : 'vector_service_pb2' + # @@protoc_insertion_point(class_scope:FetchResponse.VectorsEntry) + }) + , + 'DESCRIPTOR' : _FETCHRESPONSE, + '__module__' : 'vector_service_pb2' + # @@protoc_insertion_point(class_scope:FetchResponse) + }) _sym_db.RegisterMessage(FetchResponse) _sym_db.RegisterMessage(FetchResponse.VectorsEntry) -QueryVector = _reflection.GeneratedProtocolMessageType( - "QueryVector", - (_message.Message,), - { - "DESCRIPTOR": _QUERYVECTOR, - "__module__": "vector_service_pb2" - # @@protoc_insertion_point(class_scope:QueryVector) - }, -) +QueryVector = _reflection.GeneratedProtocolMessageType('QueryVector', (_message.Message,), { + 'DESCRIPTOR' : _QUERYVECTOR, + '__module__' : 'vector_service_pb2' + # @@protoc_insertion_point(class_scope:QueryVector) + }) _sym_db.RegisterMessage(QueryVector) -QueryRequest = _reflection.GeneratedProtocolMessageType( - "QueryRequest", - (_message.Message,), - { - "DESCRIPTOR": _QUERYREQUEST, - "__module__": "vector_service_pb2" - # @@protoc_insertion_point(class_scope:QueryRequest) - }, -) +QueryRequest = _reflection.GeneratedProtocolMessageType('QueryRequest', (_message.Message,), { + 'DESCRIPTOR' : _QUERYREQUEST, + '__module__' : 'vector_service_pb2' + # @@protoc_insertion_point(class_scope:QueryRequest) + }) _sym_db.RegisterMessage(QueryRequest) -SingleQueryResults = _reflection.GeneratedProtocolMessageType( - "SingleQueryResults", - (_message.Message,), - { - "DESCRIPTOR": _SINGLEQUERYRESULTS, - "__module__": "vector_service_pb2" - # @@protoc_insertion_point(class_scope:SingleQueryResults) - }, -) +SingleQueryResults = _reflection.GeneratedProtocolMessageType('SingleQueryResults', (_message.Message,), { + 'DESCRIPTOR' : _SINGLEQUERYRESULTS, + '__module__' : 'vector_service_pb2' + # @@protoc_insertion_point(class_scope:SingleQueryResults) + }) _sym_db.RegisterMessage(SingleQueryResults) -QueryResponse = _reflection.GeneratedProtocolMessageType( - "QueryResponse", - (_message.Message,), - { - "DESCRIPTOR": _QUERYRESPONSE, - "__module__": "vector_service_pb2" - # @@protoc_insertion_point(class_scope:QueryResponse) - }, -) +QueryResponse = _reflection.GeneratedProtocolMessageType('QueryResponse', (_message.Message,), { + 'DESCRIPTOR' : _QUERYRESPONSE, + '__module__' : 'vector_service_pb2' + # @@protoc_insertion_point(class_scope:QueryResponse) + }) _sym_db.RegisterMessage(QueryResponse) -UpdateRequest = _reflection.GeneratedProtocolMessageType( - "UpdateRequest", - (_message.Message,), - { - "DESCRIPTOR": _UPDATEREQUEST, - "__module__": "vector_service_pb2" - # @@protoc_insertion_point(class_scope:UpdateRequest) - }, -) +UpdateRequest = _reflection.GeneratedProtocolMessageType('UpdateRequest', (_message.Message,), { + 'DESCRIPTOR' : _UPDATEREQUEST, + '__module__' : 'vector_service_pb2' + # @@protoc_insertion_point(class_scope:UpdateRequest) + }) _sym_db.RegisterMessage(UpdateRequest) -UpdateResponse = _reflection.GeneratedProtocolMessageType( - "UpdateResponse", - (_message.Message,), - { - "DESCRIPTOR": _UPDATERESPONSE, - "__module__": "vector_service_pb2" - # @@protoc_insertion_point(class_scope:UpdateResponse) - }, -) +UpdateResponse = _reflection.GeneratedProtocolMessageType('UpdateResponse', (_message.Message,), { + 'DESCRIPTOR' : _UPDATERESPONSE, + '__module__' : 'vector_service_pb2' + # @@protoc_insertion_point(class_scope:UpdateResponse) + }) _sym_db.RegisterMessage(UpdateResponse) -DescribeIndexStatsRequest = _reflection.GeneratedProtocolMessageType( - "DescribeIndexStatsRequest", - (_message.Message,), - { - "DESCRIPTOR": _DESCRIBEINDEXSTATSREQUEST, - "__module__": "vector_service_pb2" - # @@protoc_insertion_point(class_scope:DescribeIndexStatsRequest) - }, -) +DescribeIndexStatsRequest = _reflection.GeneratedProtocolMessageType('DescribeIndexStatsRequest', (_message.Message,), { + 'DESCRIPTOR' : _DESCRIBEINDEXSTATSREQUEST, + '__module__' : 'vector_service_pb2' + # @@protoc_insertion_point(class_scope:DescribeIndexStatsRequest) + }) _sym_db.RegisterMessage(DescribeIndexStatsRequest) -NamespaceSummary = _reflection.GeneratedProtocolMessageType( - "NamespaceSummary", - (_message.Message,), - { - "DESCRIPTOR": _NAMESPACESUMMARY, - "__module__": "vector_service_pb2" - # @@protoc_insertion_point(class_scope:NamespaceSummary) - }, -) +NamespaceSummary = _reflection.GeneratedProtocolMessageType('NamespaceSummary', (_message.Message,), { + 'DESCRIPTOR' : _NAMESPACESUMMARY, + '__module__' : 'vector_service_pb2' + # @@protoc_insertion_point(class_scope:NamespaceSummary) + }) _sym_db.RegisterMessage(NamespaceSummary) -DescribeIndexStatsResponse = _reflection.GeneratedProtocolMessageType( - "DescribeIndexStatsResponse", - (_message.Message,), - { - "NamespacesEntry": _reflection.GeneratedProtocolMessageType( - "NamespacesEntry", - (_message.Message,), - { - "DESCRIPTOR": _DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY, - "__module__": "vector_service_pb2" - # @@protoc_insertion_point(class_scope:DescribeIndexStatsResponse.NamespacesEntry) - }, - ), - "DESCRIPTOR": _DESCRIBEINDEXSTATSRESPONSE, - "__module__": "vector_service_pb2" - # @@protoc_insertion_point(class_scope:DescribeIndexStatsResponse) - }, -) +DescribeIndexStatsResponse = _reflection.GeneratedProtocolMessageType('DescribeIndexStatsResponse', (_message.Message,), { + + 'NamespacesEntry' : _reflection.GeneratedProtocolMessageType('NamespacesEntry', (_message.Message,), { + 'DESCRIPTOR' : _DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY, + '__module__' : 'vector_service_pb2' + # @@protoc_insertion_point(class_scope:DescribeIndexStatsResponse.NamespacesEntry) + }) + , + 'DESCRIPTOR' : _DESCRIBEINDEXSTATSRESPONSE, + '__module__' : 'vector_service_pb2' + # @@protoc_insertion_point(class_scope:DescribeIndexStatsResponse) + }) _sym_db.RegisterMessage(DescribeIndexStatsResponse) _sym_db.RegisterMessage(DescribeIndexStatsResponse.NamespacesEntry) DESCRIPTOR._options = None -_SPARSEVALUES.fields_by_name["indices"]._options = None -_SPARSEVALUES.fields_by_name["values"]._options = None -_VECTOR.fields_by_name["id"]._options = None -_VECTOR.fields_by_name["values"]._options = None -_VECTOR.fields_by_name["metadata"]._options = None -_SCOREDVECTOR.fields_by_name["id"]._options = None -_SCOREDVECTOR.fields_by_name["score"]._options = None -_SCOREDVECTOR.fields_by_name["values"]._options = None -_SCOREDVECTOR.fields_by_name["metadata"]._options = None -_UPSERTREQUEST.fields_by_name["vectors"]._options = None -_UPSERTREQUEST.fields_by_name["namespace"]._options = None -_UPSERTRESPONSE.fields_by_name["upserted_count"]._options = None -_DELETEREQUEST.fields_by_name["ids"]._options = None -_DELETEREQUEST.fields_by_name["delete_all"]._options = None -_DELETEREQUEST.fields_by_name["namespace"]._options = None -_FETCHREQUEST.fields_by_name["ids"]._options = None -_FETCHREQUEST.fields_by_name["namespace"]._options = None +_SPARSEVALUES.fields_by_name['indices']._options = None +_SPARSEVALUES.fields_by_name['values']._options = None +_VECTOR.fields_by_name['id']._options = None +_VECTOR.fields_by_name['values']._options = None +_VECTOR.fields_by_name['metadata']._options = None +_SCOREDVECTOR.fields_by_name['id']._options = None +_SCOREDVECTOR.fields_by_name['score']._options = None +_SCOREDVECTOR.fields_by_name['values']._options = None +_SCOREDVECTOR.fields_by_name['metadata']._options = None +_UPSERTREQUEST.fields_by_name['vectors']._options = None +_UPSERTREQUEST.fields_by_name['namespace']._options = None +_UPSERTRESPONSE.fields_by_name['upserted_count']._options = None +_DELETEREQUEST.fields_by_name['ids']._options = None +_DELETEREQUEST.fields_by_name['delete_all']._options = None +_DELETEREQUEST.fields_by_name['namespace']._options = None +_FETCHREQUEST.fields_by_name['ids']._options = None +_FETCHREQUEST.fields_by_name['namespace']._options = None _FETCHRESPONSE_VECTORSENTRY._options = None -_FETCHRESPONSE.fields_by_name["namespace"]._options = None -_QUERYVECTOR.fields_by_name["values"]._options = None -_QUERYVECTOR.fields_by_name["top_k"]._options = None -_QUERYVECTOR.fields_by_name["namespace"]._options = None -_QUERYVECTOR.fields_by_name["filter"]._options = None -_QUERYREQUEST.fields_by_name["namespace"]._options = None -_QUERYREQUEST.fields_by_name["top_k"]._options = None -_QUERYREQUEST.fields_by_name["filter"]._options = None -_QUERYREQUEST.fields_by_name["include_values"]._options = None -_QUERYREQUEST.fields_by_name["include_metadata"]._options = None -_QUERYREQUEST.fields_by_name["queries"]._options = None -_QUERYREQUEST.fields_by_name["vector"]._options = None -_QUERYREQUEST.fields_by_name["id"]._options = None -_SINGLEQUERYRESULTS.fields_by_name["namespace"]._options = None -_QUERYRESPONSE.fields_by_name["results"]._options = None -_UPDATEREQUEST.fields_by_name["id"]._options = None -_UPDATEREQUEST.fields_by_name["values"]._options = None -_UPDATEREQUEST.fields_by_name["set_metadata"]._options = None -_UPDATEREQUEST.fields_by_name["namespace"]._options = None -_NAMESPACESUMMARY.fields_by_name["vector_count"]._options = None +_FETCHRESPONSE.fields_by_name['namespace']._options = None +_QUERYVECTOR.fields_by_name['values']._options = None +_QUERYVECTOR.fields_by_name['top_k']._options = None +_QUERYVECTOR.fields_by_name['namespace']._options = None +_QUERYVECTOR.fields_by_name['filter']._options = None +_QUERYREQUEST.fields_by_name['namespace']._options = None +_QUERYREQUEST.fields_by_name['top_k']._options = None +_QUERYREQUEST.fields_by_name['filter']._options = None +_QUERYREQUEST.fields_by_name['include_values']._options = None +_QUERYREQUEST.fields_by_name['include_metadata']._options = None +_QUERYREQUEST.fields_by_name['queries']._options = None +_QUERYREQUEST.fields_by_name['vector']._options = None +_QUERYREQUEST.fields_by_name['id']._options = None +_SINGLEQUERYRESULTS.fields_by_name['namespace']._options = None +_QUERYRESPONSE.fields_by_name['results']._options = None +_UPDATEREQUEST.fields_by_name['id']._options = None +_UPDATEREQUEST.fields_by_name['values']._options = None +_UPDATEREQUEST.fields_by_name['set_metadata']._options = None +_UPDATEREQUEST.fields_by_name['namespace']._options = None +_NAMESPACESUMMARY.fields_by_name['vector_count']._options = None _DESCRIBEINDEXSTATSRESPONSE_NAMESPACESENTRY._options = None -_DESCRIBEINDEXSTATSRESPONSE.fields_by_name["dimension"]._options = None -_DESCRIBEINDEXSTATSRESPONSE.fields_by_name["index_fullness"]._options = None -_DESCRIBEINDEXSTATSRESPONSE.fields_by_name["total_vector_count"]._options = None +_DESCRIBEINDEXSTATSRESPONSE.fields_by_name['dimension']._options = None +_DESCRIBEINDEXSTATSRESPONSE.fields_by_name['index_fullness']._options = None +_DESCRIBEINDEXSTATSRESPONSE.fields_by_name['total_vector_count']._options = None _DESCRIBEINDEXSTATSRESPONSE._options = None _VECTORSERVICE = _descriptor.ServiceDescriptor( - name="VectorService", - full_name="VectorService", - file=DESCRIPTOR, + name='VectorService', + full_name='VectorService', + file=DESCRIPTOR, + index=0, + serialized_options=None, + create_key=_descriptor._internal_create_key, + serialized_start=3377, + serialized_end=4078, + methods=[ + _descriptor.MethodDescriptor( + name='Upsert', + full_name='VectorService.Upsert', index=0, - serialized_options=None, + containing_service=None, + input_type=_UPSERTREQUEST, + output_type=_UPSERTRESPONSE, + serialized_options=b'\202\323\344\223\002\024\"\017/vectors/upsert:\001*\222A\033\n\021Vector Operations*\006upsert', create_key=_descriptor._internal_create_key, - serialized_start=3377, - serialized_end=4078, - methods=[ - _descriptor.MethodDescriptor( - name="Upsert", - full_name="VectorService.Upsert", - index=0, - containing_service=None, - input_type=_UPSERTREQUEST, - output_type=_UPSERTRESPONSE, - serialized_options=b'\202\323\344\223\002\024"\017/vectors/upsert:\001*\222A\033\n\021Vector Operations*\006upsert', - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name="Delete", - full_name="VectorService.Delete", - index=1, - containing_service=None, - input_type=_DELETEREQUEST, - output_type=_DELETERESPONSE, - serialized_options=b"\202\323\344\223\002'\"\017/vectors/delete:\001*Z\021*\017/vectors/delete\222A\033\n\021Vector Operations*\006delete", - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name="Fetch", - full_name="VectorService.Fetch", - index=2, - containing_service=None, - input_type=_FETCHREQUEST, - output_type=_FETCHRESPONSE, - serialized_options=b"\202\323\344\223\002\020\022\016/vectors/fetch\222A\032\n\021Vector Operations*\005fetch", - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name="Query", - full_name="VectorService.Query", - index=3, - containing_service=None, - input_type=_QUERYREQUEST, - output_type=_QUERYRESPONSE, - serialized_options=b'\202\323\344\223\002\013"\006/query:\001*\222A\032\n\021Vector Operations*\005query', - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name="Update", - full_name="VectorService.Update", - index=4, - containing_service=None, - input_type=_UPDATEREQUEST, - output_type=_UPDATERESPONSE, - serialized_options=b'\202\323\344\223\002\024"\017/vectors/update:\001*\222A\033\n\021Vector Operations*\006update', - create_key=_descriptor._internal_create_key, - ), - _descriptor.MethodDescriptor( - name="DescribeIndexStats", - full_name="VectorService.DescribeIndexStats", - index=5, - containing_service=None, - input_type=_DESCRIBEINDEXSTATSREQUEST, - output_type=_DESCRIBEINDEXSTATSRESPONSE, - serialized_options=b'\202\323\344\223\0023"\025/describe_index_stats:\001*Z\027\022\025/describe_index_stats\222A)\n\021Vector Operations*\024describe_index_stats', - create_key=_descriptor._internal_create_key, - ), - ], -) + ), + _descriptor.MethodDescriptor( + name='Delete', + full_name='VectorService.Delete', + index=1, + containing_service=None, + input_type=_DELETEREQUEST, + output_type=_DELETERESPONSE, + serialized_options=b'\202\323\344\223\002\'\"\017/vectors/delete:\001*Z\021*\017/vectors/delete\222A\033\n\021Vector Operations*\006delete', + create_key=_descriptor._internal_create_key, + ), + _descriptor.MethodDescriptor( + name='Fetch', + full_name='VectorService.Fetch', + index=2, + containing_service=None, + input_type=_FETCHREQUEST, + output_type=_FETCHRESPONSE, + serialized_options=b'\202\323\344\223\002\020\022\016/vectors/fetch\222A\032\n\021Vector Operations*\005fetch', + create_key=_descriptor._internal_create_key, + ), + _descriptor.MethodDescriptor( + name='Query', + full_name='VectorService.Query', + index=3, + containing_service=None, + input_type=_QUERYREQUEST, + output_type=_QUERYRESPONSE, + serialized_options=b'\202\323\344\223\002\013\"\006/query:\001*\222A\032\n\021Vector Operations*\005query', + create_key=_descriptor._internal_create_key, + ), + _descriptor.MethodDescriptor( + name='Update', + full_name='VectorService.Update', + index=4, + containing_service=None, + input_type=_UPDATEREQUEST, + output_type=_UPDATERESPONSE, + serialized_options=b'\202\323\344\223\002\024\"\017/vectors/update:\001*\222A\033\n\021Vector Operations*\006update', + create_key=_descriptor._internal_create_key, + ), + _descriptor.MethodDescriptor( + name='DescribeIndexStats', + full_name='VectorService.DescribeIndexStats', + index=5, + containing_service=None, + input_type=_DESCRIBEINDEXSTATSREQUEST, + output_type=_DESCRIBEINDEXSTATSRESPONSE, + serialized_options=b'\202\323\344\223\0023\"\025/describe_index_stats:\001*Z\027\022\025/describe_index_stats\222A)\n\021Vector Operations*\024describe_index_stats', + create_key=_descriptor._internal_create_key, + ), +]) _sym_db.RegisterServiceDescriptor(_VECTORSERVICE) -DESCRIPTOR.services_by_name["VectorService"] = _VECTORSERVICE +DESCRIPTOR.services_by_name['VectorService'] = _VECTORSERVICE # @@protoc_insertion_point(module_scope) diff --git a/pinecone/core/grpc/protos/vector_service_pb2.pyi b/pinecone/core/grpc/protos/vector_service_pb2.pyi index a8c3c4d00..0c2c73f62 100644 --- a/pinecone/core/grpc/protos/vector_service_pb2.pyi +++ b/pinecone/core/grpc/protos/vector_service_pb2.pyi @@ -30,11 +30,13 @@ from typing_extensions import ( Literal as typing_extensions___Literal, ) + builtin___bool = bool builtin___bytes = bytes builtin___float = float builtin___int = int + DESCRIPTOR: google___protobuf___descriptor___FileDescriptor = ... class SparseValues(google___protobuf___message___Message): @@ -42,16 +44,12 @@ class SparseValues(google___protobuf___message___Message): indices: google___protobuf___internal___containers___RepeatedScalarFieldContainer[builtin___int] = ... values: google___protobuf___internal___containers___RepeatedScalarFieldContainer[builtin___float] = ... - def __init__( - self, + def __init__(self, *, - indices: typing___Optional[typing___Iterable[builtin___int]] = None, - values: typing___Optional[typing___Iterable[builtin___float]] = None, - ) -> None: ... - def ClearField( - self, field_name: typing_extensions___Literal["indices", b"indices", "values", b"values"] - ) -> None: ... - + indices : typing___Optional[typing___Iterable[builtin___int]] = None, + values : typing___Optional[typing___Iterable[builtin___float]] = None, + ) -> None: ... + def ClearField(self, field_name: typing_extensions___Literal[u"indices",b"indices",u"values",b"values"]) -> None: ... type___SparseValues = SparseValues class Vector(google___protobuf___message___Message): @@ -61,26 +59,19 @@ class Vector(google___protobuf___message___Message): @property def sparse_values(self) -> type___SparseValues: ... + @property def metadata(self) -> google___protobuf___struct_pb2___Struct: ... - def __init__( - self, - *, - id: typing___Optional[typing___Text] = None, - values: typing___Optional[typing___Iterable[builtin___float]] = None, - sparse_values: typing___Optional[type___SparseValues] = None, - metadata: typing___Optional[google___protobuf___struct_pb2___Struct] = None, - ) -> None: ... - def HasField( - self, field_name: typing_extensions___Literal["metadata", b"metadata", "sparse_values", b"sparse_values"] - ) -> builtin___bool: ... - def ClearField( - self, - field_name: typing_extensions___Literal[ - "id", b"id", "metadata", b"metadata", "sparse_values", b"sparse_values", "values", b"values" - ], - ) -> None: ... + def __init__(self, + *, + id : typing___Optional[typing___Text] = None, + values : typing___Optional[typing___Iterable[builtin___float]] = None, + sparse_values : typing___Optional[type___SparseValues] = None, + metadata : typing___Optional[google___protobuf___struct_pb2___Struct] = None, + ) -> None: ... + def HasField(self, field_name: typing_extensions___Literal[u"metadata",b"metadata",u"sparse_values",b"sparse_values"]) -> builtin___bool: ... + def ClearField(self, field_name: typing_extensions___Literal[u"id",b"id",u"metadata",b"metadata",u"sparse_values",b"sparse_values",u"values",b"values"]) -> None: ... type___Vector = Vector class ScoredVector(google___protobuf___message___Message): @@ -91,36 +82,20 @@ class ScoredVector(google___protobuf___message___Message): @property def sparse_values(self) -> type___SparseValues: ... + @property def metadata(self) -> google___protobuf___struct_pb2___Struct: ... - def __init__( - self, - *, - id: typing___Optional[typing___Text] = None, - score: typing___Optional[builtin___float] = None, - values: typing___Optional[typing___Iterable[builtin___float]] = None, - sparse_values: typing___Optional[type___SparseValues] = None, - metadata: typing___Optional[google___protobuf___struct_pb2___Struct] = None, - ) -> None: ... - def HasField( - self, field_name: typing_extensions___Literal["metadata", b"metadata", "sparse_values", b"sparse_values"] - ) -> builtin___bool: ... - def ClearField( - self, - field_name: typing_extensions___Literal[ - "id", - b"id", - "metadata", - b"metadata", - "score", - b"score", - "sparse_values", - b"sparse_values", - "values", - b"values", - ], - ) -> None: ... + def __init__(self, + *, + id : typing___Optional[typing___Text] = None, + score : typing___Optional[builtin___float] = None, + values : typing___Optional[typing___Iterable[builtin___float]] = None, + sparse_values : typing___Optional[type___SparseValues] = None, + metadata : typing___Optional[google___protobuf___struct_pb2___Struct] = None, + ) -> None: ... + def HasField(self, field_name: typing_extensions___Literal[u"metadata",b"metadata",u"sparse_values",b"sparse_values"]) -> builtin___bool: ... + def ClearField(self, field_name: typing_extensions___Literal[u"id",b"id",u"metadata",b"metadata",u"score",b"score",u"sparse_values",b"sparse_values",u"values",b"values"]) -> None: ... type___ScoredVector = ScoredVector class UpsertRequest(google___protobuf___message___Message): @@ -129,29 +104,24 @@ class UpsertRequest(google___protobuf___message___Message): @property def vectors(self) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[type___Vector]: ... - def __init__( - self, - *, - vectors: typing___Optional[typing___Iterable[type___Vector]] = None, - namespace: typing___Optional[typing___Text] = None, - ) -> None: ... - def ClearField( - self, field_name: typing_extensions___Literal["namespace", b"namespace", "vectors", b"vectors"] - ) -> None: ... + def __init__(self, + *, + vectors : typing___Optional[typing___Iterable[type___Vector]] = None, + namespace : typing___Optional[typing___Text] = None, + ) -> None: ... + def ClearField(self, field_name: typing_extensions___Literal[u"namespace",b"namespace",u"vectors",b"vectors"]) -> None: ... type___UpsertRequest = UpsertRequest class UpsertResponse(google___protobuf___message___Message): DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... upserted_count: builtin___int = ... - def __init__( - self, + def __init__(self, *, - upserted_count: typing___Optional[builtin___int] = None, - ) -> None: ... - def ClearField(self, field_name: typing_extensions___Literal["upserted_count", b"upserted_count"]) -> None: ... - + upserted_count : typing___Optional[builtin___int] = None, + ) -> None: ... + def ClearField(self, field_name: typing_extensions___Literal[u"upserted_count",b"upserted_count"]) -> None: ... type___UpsertResponse = UpsertResponse class DeleteRequest(google___protobuf___message___Message): @@ -162,31 +132,23 @@ class DeleteRequest(google___protobuf___message___Message): @property def filter(self) -> google___protobuf___struct_pb2___Struct: ... - def __init__( - self, - *, - ids: typing___Optional[typing___Iterable[typing___Text]] = None, - delete_all: typing___Optional[builtin___bool] = None, - namespace: typing___Optional[typing___Text] = None, - filter: typing___Optional[google___protobuf___struct_pb2___Struct] = None, - ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal["filter", b"filter"]) -> builtin___bool: ... - def ClearField( - self, - field_name: typing_extensions___Literal[ - "delete_all", b"delete_all", "filter", b"filter", "ids", b"ids", "namespace", b"namespace" - ], - ) -> None: ... + def __init__(self, + *, + ids : typing___Optional[typing___Iterable[typing___Text]] = None, + delete_all : typing___Optional[builtin___bool] = None, + namespace : typing___Optional[typing___Text] = None, + filter : typing___Optional[google___protobuf___struct_pb2___Struct] = None, + ) -> None: ... + def HasField(self, field_name: typing_extensions___Literal[u"filter",b"filter"]) -> builtin___bool: ... + def ClearField(self, field_name: typing_extensions___Literal[u"delete_all",b"delete_all",u"filter",b"filter",u"ids",b"ids",u"namespace",b"namespace"]) -> None: ... type___DeleteRequest = DeleteRequest class DeleteResponse(google___protobuf___message___Message): DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - def __init__( - self, - ) -> None: ... - + def __init__(self, + ) -> None: ... type___DeleteResponse = DeleteResponse class FetchRequest(google___protobuf___message___Message): @@ -194,49 +156,43 @@ class FetchRequest(google___protobuf___message___Message): ids: google___protobuf___internal___containers___RepeatedScalarFieldContainer[typing___Text] = ... namespace: typing___Text = ... - def __init__( - self, + def __init__(self, *, - ids: typing___Optional[typing___Iterable[typing___Text]] = None, - namespace: typing___Optional[typing___Text] = None, - ) -> None: ... - def ClearField(self, field_name: typing_extensions___Literal["ids", b"ids", "namespace", b"namespace"]) -> None: ... - + ids : typing___Optional[typing___Iterable[typing___Text]] = None, + namespace : typing___Optional[typing___Text] = None, + ) -> None: ... + def ClearField(self, field_name: typing_extensions___Literal[u"ids",b"ids",u"namespace",b"namespace"]) -> None: ... type___FetchRequest = FetchRequest class FetchResponse(google___protobuf___message___Message): DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - class VectorsEntry(google___protobuf___message___Message): DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... key: typing___Text = ... @property def value(self) -> type___Vector: ... - def __init__( - self, + + def __init__(self, *, - key: typing___Optional[typing___Text] = None, - value: typing___Optional[type___Vector] = None, - ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal["value", b"value"]) -> builtin___bool: ... - def ClearField(self, field_name: typing_extensions___Literal["key", b"key", "value", b"value"]) -> None: ... + key : typing___Optional[typing___Text] = None, + value : typing___Optional[type___Vector] = None, + ) -> None: ... + def HasField(self, field_name: typing_extensions___Literal[u"value",b"value"]) -> builtin___bool: ... + def ClearField(self, field_name: typing_extensions___Literal[u"key",b"key",u"value",b"value"]) -> None: ... type___VectorsEntry = VectorsEntry namespace: typing___Text = ... @property def vectors(self) -> typing___MutableMapping[typing___Text, type___Vector]: ... - def __init__( - self, - *, - vectors: typing___Optional[typing___Mapping[typing___Text, type___Vector]] = None, - namespace: typing___Optional[typing___Text] = None, - ) -> None: ... - def ClearField( - self, field_name: typing_extensions___Literal["namespace", b"namespace", "vectors", b"vectors"] - ) -> None: ... + def __init__(self, + *, + vectors : typing___Optional[typing___Mapping[typing___Text, type___Vector]] = None, + namespace : typing___Optional[typing___Text] = None, + ) -> None: ... + def ClearField(self, field_name: typing_extensions___Literal[u"namespace",b"namespace",u"vectors",b"vectors"]) -> None: ... type___FetchResponse = FetchResponse class QueryVector(google___protobuf___message___Message): @@ -247,36 +203,20 @@ class QueryVector(google___protobuf___message___Message): @property def sparse_values(self) -> type___SparseValues: ... + @property def filter(self) -> google___protobuf___struct_pb2___Struct: ... - def __init__( - self, - *, - values: typing___Optional[typing___Iterable[builtin___float]] = None, - sparse_values: typing___Optional[type___SparseValues] = None, - top_k: typing___Optional[builtin___int] = None, - namespace: typing___Optional[typing___Text] = None, - filter: typing___Optional[google___protobuf___struct_pb2___Struct] = None, - ) -> None: ... - def HasField( - self, field_name: typing_extensions___Literal["filter", b"filter", "sparse_values", b"sparse_values"] - ) -> builtin___bool: ... - def ClearField( - self, - field_name: typing_extensions___Literal[ - "filter", - b"filter", - "namespace", - b"namespace", - "sparse_values", - b"sparse_values", - "top_k", - b"top_k", - "values", - b"values", - ], - ) -> None: ... + def __init__(self, + *, + values : typing___Optional[typing___Iterable[builtin___float]] = None, + sparse_values : typing___Optional[type___SparseValues] = None, + top_k : typing___Optional[builtin___int] = None, + namespace : typing___Optional[typing___Text] = None, + filter : typing___Optional[google___protobuf___struct_pb2___Struct] = None, + ) -> None: ... + def HasField(self, field_name: typing_extensions___Literal[u"filter",b"filter",u"sparse_values",b"sparse_values"]) -> builtin___bool: ... + def ClearField(self, field_name: typing_extensions___Literal[u"filter",b"filter",u"namespace",b"namespace",u"sparse_values",b"sparse_values",u"top_k",b"top_k",u"values",b"values"]) -> None: ... type___QueryVector = QueryVector class QueryRequest(google___protobuf___message___Message): @@ -290,52 +230,27 @@ class QueryRequest(google___protobuf___message___Message): @property def filter(self) -> google___protobuf___struct_pb2___Struct: ... + @property - def queries( - self, - ) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[type___QueryVector]: ... + def queries(self) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[type___QueryVector]: ... + @property def sparse_vector(self) -> type___SparseValues: ... - def __init__( - self, - *, - namespace: typing___Optional[typing___Text] = None, - top_k: typing___Optional[builtin___int] = None, - filter: typing___Optional[google___protobuf___struct_pb2___Struct] = None, - include_values: typing___Optional[builtin___bool] = None, - include_metadata: typing___Optional[builtin___bool] = None, - queries: typing___Optional[typing___Iterable[type___QueryVector]] = None, - vector: typing___Optional[typing___Iterable[builtin___float]] = None, - sparse_vector: typing___Optional[type___SparseValues] = None, - id: typing___Optional[typing___Text] = None, - ) -> None: ... - def HasField( - self, field_name: typing_extensions___Literal["filter", b"filter", "sparse_vector", b"sparse_vector"] - ) -> builtin___bool: ... - def ClearField( - self, - field_name: typing_extensions___Literal[ - "filter", - b"filter", - "id", - b"id", - "include_metadata", - b"include_metadata", - "include_values", - b"include_values", - "namespace", - b"namespace", - "queries", - b"queries", - "sparse_vector", - b"sparse_vector", - "top_k", - b"top_k", - "vector", - b"vector", - ], - ) -> None: ... + def __init__(self, + *, + namespace : typing___Optional[typing___Text] = None, + top_k : typing___Optional[builtin___int] = None, + filter : typing___Optional[google___protobuf___struct_pb2___Struct] = None, + include_values : typing___Optional[builtin___bool] = None, + include_metadata : typing___Optional[builtin___bool] = None, + queries : typing___Optional[typing___Iterable[type___QueryVector]] = None, + vector : typing___Optional[typing___Iterable[builtin___float]] = None, + sparse_vector : typing___Optional[type___SparseValues] = None, + id : typing___Optional[typing___Text] = None, + ) -> None: ... + def HasField(self, field_name: typing_extensions___Literal[u"filter",b"filter",u"sparse_vector",b"sparse_vector"]) -> builtin___bool: ... + def ClearField(self, field_name: typing_extensions___Literal[u"filter",b"filter",u"id",b"id",u"include_metadata",b"include_metadata",u"include_values",b"include_values",u"namespace",b"namespace",u"queries",b"queries",u"sparse_vector",b"sparse_vector",u"top_k",b"top_k",u"vector",b"vector"]) -> None: ... type___QueryRequest = QueryRequest class SingleQueryResults(google___protobuf___message___Message): @@ -343,19 +258,14 @@ class SingleQueryResults(google___protobuf___message___Message): namespace: typing___Text = ... @property - def matches( - self, - ) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[type___ScoredVector]: ... - def __init__( - self, - *, - matches: typing___Optional[typing___Iterable[type___ScoredVector]] = None, - namespace: typing___Optional[typing___Text] = None, - ) -> None: ... - def ClearField( - self, field_name: typing_extensions___Literal["matches", b"matches", "namespace", b"namespace"] - ) -> None: ... + def matches(self) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[type___ScoredVector]: ... + def __init__(self, + *, + matches : typing___Optional[typing___Iterable[type___ScoredVector]] = None, + namespace : typing___Optional[typing___Text] = None, + ) -> None: ... + def ClearField(self, field_name: typing_extensions___Literal[u"matches",b"matches",u"namespace",b"namespace"]) -> None: ... type___SingleQueryResults = SingleQueryResults class QueryResponse(google___protobuf___message___Message): @@ -363,27 +273,18 @@ class QueryResponse(google___protobuf___message___Message): namespace: typing___Text = ... @property - def results( - self, - ) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[type___SingleQueryResults]: ... + def results(self) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[type___SingleQueryResults]: ... + @property - def matches( - self, - ) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[type___ScoredVector]: ... - def __init__( - self, - *, - results: typing___Optional[typing___Iterable[type___SingleQueryResults]] = None, - matches: typing___Optional[typing___Iterable[type___ScoredVector]] = None, - namespace: typing___Optional[typing___Text] = None, - ) -> None: ... - def ClearField( - self, - field_name: typing_extensions___Literal[ - "matches", b"matches", "namespace", b"namespace", "results", b"results" - ], - ) -> None: ... + def matches(self) -> google___protobuf___internal___containers___RepeatedCompositeFieldContainer[type___ScoredVector]: ... + def __init__(self, + *, + results : typing___Optional[typing___Iterable[type___SingleQueryResults]] = None, + matches : typing___Optional[typing___Iterable[type___ScoredVector]] = None, + namespace : typing___Optional[typing___Text] = None, + ) -> None: ... + def ClearField(self, field_name: typing_extensions___Literal[u"matches",b"matches",u"namespace",b"namespace",u"results",b"results"]) -> None: ... type___QueryResponse = QueryResponse class UpdateRequest(google___protobuf___message___Message): @@ -394,46 +295,27 @@ class UpdateRequest(google___protobuf___message___Message): @property def sparse_values(self) -> type___SparseValues: ... + @property def set_metadata(self) -> google___protobuf___struct_pb2___Struct: ... - def __init__( - self, - *, - id: typing___Optional[typing___Text] = None, - values: typing___Optional[typing___Iterable[builtin___float]] = None, - sparse_values: typing___Optional[type___SparseValues] = None, - set_metadata: typing___Optional[google___protobuf___struct_pb2___Struct] = None, - namespace: typing___Optional[typing___Text] = None, - ) -> None: ... - def HasField( - self, - field_name: typing_extensions___Literal["set_metadata", b"set_metadata", "sparse_values", b"sparse_values"], - ) -> builtin___bool: ... - def ClearField( - self, - field_name: typing_extensions___Literal[ - "id", - b"id", - "namespace", - b"namespace", - "set_metadata", - b"set_metadata", - "sparse_values", - b"sparse_values", - "values", - b"values", - ], - ) -> None: ... + def __init__(self, + *, + id : typing___Optional[typing___Text] = None, + values : typing___Optional[typing___Iterable[builtin___float]] = None, + sparse_values : typing___Optional[type___SparseValues] = None, + set_metadata : typing___Optional[google___protobuf___struct_pb2___Struct] = None, + namespace : typing___Optional[typing___Text] = None, + ) -> None: ... + def HasField(self, field_name: typing_extensions___Literal[u"set_metadata",b"set_metadata",u"sparse_values",b"sparse_values"]) -> builtin___bool: ... + def ClearField(self, field_name: typing_extensions___Literal[u"id",b"id",u"namespace",b"namespace",u"set_metadata",b"set_metadata",u"sparse_values",b"sparse_values",u"values",b"values"]) -> None: ... type___UpdateRequest = UpdateRequest class UpdateResponse(google___protobuf___message___Message): DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - def __init__( - self, - ) -> None: ... - + def __init__(self, + ) -> None: ... type___UpdateResponse = UpdateResponse class DescribeIndexStatsRequest(google___protobuf___message___Message): @@ -441,46 +323,42 @@ class DescribeIndexStatsRequest(google___protobuf___message___Message): @property def filter(self) -> google___protobuf___struct_pb2___Struct: ... - def __init__( - self, - *, - filter: typing___Optional[google___protobuf___struct_pb2___Struct] = None, - ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal["filter", b"filter"]) -> builtin___bool: ... - def ClearField(self, field_name: typing_extensions___Literal["filter", b"filter"]) -> None: ... + def __init__(self, + *, + filter : typing___Optional[google___protobuf___struct_pb2___Struct] = None, + ) -> None: ... + def HasField(self, field_name: typing_extensions___Literal[u"filter",b"filter"]) -> builtin___bool: ... + def ClearField(self, field_name: typing_extensions___Literal[u"filter",b"filter"]) -> None: ... type___DescribeIndexStatsRequest = DescribeIndexStatsRequest class NamespaceSummary(google___protobuf___message___Message): DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... vector_count: builtin___int = ... - def __init__( - self, + def __init__(self, *, - vector_count: typing___Optional[builtin___int] = None, - ) -> None: ... - def ClearField(self, field_name: typing_extensions___Literal["vector_count", b"vector_count"]) -> None: ... - + vector_count : typing___Optional[builtin___int] = None, + ) -> None: ... + def ClearField(self, field_name: typing_extensions___Literal[u"vector_count",b"vector_count"]) -> None: ... type___NamespaceSummary = NamespaceSummary class DescribeIndexStatsResponse(google___protobuf___message___Message): DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... - class NamespacesEntry(google___protobuf___message___Message): DESCRIPTOR: google___protobuf___descriptor___Descriptor = ... key: typing___Text = ... @property def value(self) -> type___NamespaceSummary: ... - def __init__( - self, + + def __init__(self, *, - key: typing___Optional[typing___Text] = None, - value: typing___Optional[type___NamespaceSummary] = None, - ) -> None: ... - def HasField(self, field_name: typing_extensions___Literal["value", b"value"]) -> builtin___bool: ... - def ClearField(self, field_name: typing_extensions___Literal["key", b"key", "value", b"value"]) -> None: ... + key : typing___Optional[typing___Text] = None, + value : typing___Optional[type___NamespaceSummary] = None, + ) -> None: ... + def HasField(self, field_name: typing_extensions___Literal[u"value",b"value"]) -> builtin___bool: ... + def ClearField(self, field_name: typing_extensions___Literal[u"key",b"key",u"value",b"value"]) -> None: ... type___NamespacesEntry = NamespacesEntry dimension: builtin___int = ... @@ -489,26 +367,13 @@ class DescribeIndexStatsResponse(google___protobuf___message___Message): @property def namespaces(self) -> typing___MutableMapping[typing___Text, type___NamespaceSummary]: ... - def __init__( - self, - *, - namespaces: typing___Optional[typing___Mapping[typing___Text, type___NamespaceSummary]] = None, - dimension: typing___Optional[builtin___int] = None, - index_fullness: typing___Optional[builtin___float] = None, - total_vector_count: typing___Optional[builtin___int] = None, - ) -> None: ... - def ClearField( - self, - field_name: typing_extensions___Literal[ - "dimension", - b"dimension", - "index_fullness", - b"index_fullness", - "namespaces", - b"namespaces", - "total_vector_count", - b"total_vector_count", - ], - ) -> None: ... + def __init__(self, + *, + namespaces : typing___Optional[typing___Mapping[typing___Text, type___NamespaceSummary]] = None, + dimension : typing___Optional[builtin___int] = None, + index_fullness : typing___Optional[builtin___float] = None, + total_vector_count : typing___Optional[builtin___int] = None, + ) -> None: ... + def ClearField(self, field_name: typing_extensions___Literal[u"dimension",b"dimension",u"index_fullness",b"index_fullness",u"namespaces",b"namespaces",u"total_vector_count",b"total_vector_count"]) -> None: ... type___DescribeIndexStatsResponse = DescribeIndexStatsResponse diff --git a/pinecone/core/grpc/protos/vector_service_pb2_grpc.py b/pinecone/core/grpc/protos/vector_service_pb2_grpc.py index 2d7a899db..9688e5aed 100644 --- a/pinecone/core/grpc/protos/vector_service_pb2_grpc.py +++ b/pinecone/core/grpc/protos/vector_service_pb2_grpc.py @@ -4,7 +4,6 @@ import pinecone.core.grpc.protos.vector_service_pb2 as vector__service__pb2 - class VectorServiceStub(object): """The `VectorService` interface is exposed by Pinecone's vector index services. This service could also be called a `gRPC` service or a `REST`-like api. @@ -17,35 +16,35 @@ def __init__(self, channel): channel: A grpc.Channel. """ self.Upsert = channel.unary_unary( - "/VectorService/Upsert", - request_serializer=vector__service__pb2.UpsertRequest.SerializeToString, - response_deserializer=vector__service__pb2.UpsertResponse.FromString, - ) + '/VectorService/Upsert', + request_serializer=vector__service__pb2.UpsertRequest.SerializeToString, + response_deserializer=vector__service__pb2.UpsertResponse.FromString, + ) self.Delete = channel.unary_unary( - "/VectorService/Delete", - request_serializer=vector__service__pb2.DeleteRequest.SerializeToString, - response_deserializer=vector__service__pb2.DeleteResponse.FromString, - ) + '/VectorService/Delete', + request_serializer=vector__service__pb2.DeleteRequest.SerializeToString, + response_deserializer=vector__service__pb2.DeleteResponse.FromString, + ) self.Fetch = channel.unary_unary( - "/VectorService/Fetch", - request_serializer=vector__service__pb2.FetchRequest.SerializeToString, - response_deserializer=vector__service__pb2.FetchResponse.FromString, - ) + '/VectorService/Fetch', + request_serializer=vector__service__pb2.FetchRequest.SerializeToString, + response_deserializer=vector__service__pb2.FetchResponse.FromString, + ) self.Query = channel.unary_unary( - "/VectorService/Query", - request_serializer=vector__service__pb2.QueryRequest.SerializeToString, - response_deserializer=vector__service__pb2.QueryResponse.FromString, - ) + '/VectorService/Query', + request_serializer=vector__service__pb2.QueryRequest.SerializeToString, + response_deserializer=vector__service__pb2.QueryResponse.FromString, + ) self.Update = channel.unary_unary( - "/VectorService/Update", - request_serializer=vector__service__pb2.UpdateRequest.SerializeToString, - response_deserializer=vector__service__pb2.UpdateResponse.FromString, - ) + '/VectorService/Update', + request_serializer=vector__service__pb2.UpdateRequest.SerializeToString, + response_deserializer=vector__service__pb2.UpdateResponse.FromString, + ) self.DescribeIndexStats = channel.unary_unary( - "/VectorService/DescribeIndexStats", - request_serializer=vector__service__pb2.DescribeIndexStatsRequest.SerializeToString, - response_deserializer=vector__service__pb2.DescribeIndexStatsResponse.FromString, - ) + '/VectorService/DescribeIndexStats', + request_serializer=vector__service__pb2.DescribeIndexStatsRequest.SerializeToString, + response_deserializer=vector__service__pb2.DescribeIndexStatsResponse.FromString, + ) class VectorServiceServicer(object): @@ -60,8 +59,8 @@ def Upsert(self, request, context): If a new value is upserted for an existing vector id, it will overwrite the previous value. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') def Delete(self, request, context): """Delete @@ -70,8 +69,8 @@ def Delete(self, request, context): You can delete items by their id, from a single namespace. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') def Fetch(self, request, context): """Fetch @@ -80,8 +79,8 @@ def Fetch(self, request, context): The returned vectors include the vector data and/or metadata. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') def Query(self, request, context): """Query @@ -90,8 +89,8 @@ def Query(self, request, context): It retrieves the ids of the most similar items in a namespace, along with their similarity scores. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') def Update(self, request, context): """Update @@ -101,8 +100,8 @@ def Update(self, request, context): If a set_metadata is included, the values of the fields specified in it will be added or overwrite the previous value. """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') def DescribeIndexStats(self, request, context): """DescribeIndexStats @@ -115,223 +114,152 @@ def DescribeIndexStats(self, request, context): [`describe_index`](https://www.pinecone.io/docs/api/operation/describe_index/). """ context.set_code(grpc.StatusCode.UNIMPLEMENTED) - context.set_details("Method not implemented!") - raise NotImplementedError("Method not implemented!") + context.set_details('Method not implemented!') + raise NotImplementedError('Method not implemented!') def add_VectorServiceServicer_to_server(servicer, server): rpc_method_handlers = { - "Upsert": grpc.unary_unary_rpc_method_handler( - servicer.Upsert, - request_deserializer=vector__service__pb2.UpsertRequest.FromString, - response_serializer=vector__service__pb2.UpsertResponse.SerializeToString, - ), - "Delete": grpc.unary_unary_rpc_method_handler( - servicer.Delete, - request_deserializer=vector__service__pb2.DeleteRequest.FromString, - response_serializer=vector__service__pb2.DeleteResponse.SerializeToString, - ), - "Fetch": grpc.unary_unary_rpc_method_handler( - servicer.Fetch, - request_deserializer=vector__service__pb2.FetchRequest.FromString, - response_serializer=vector__service__pb2.FetchResponse.SerializeToString, - ), - "Query": grpc.unary_unary_rpc_method_handler( - servicer.Query, - request_deserializer=vector__service__pb2.QueryRequest.FromString, - response_serializer=vector__service__pb2.QueryResponse.SerializeToString, - ), - "Update": grpc.unary_unary_rpc_method_handler( - servicer.Update, - request_deserializer=vector__service__pb2.UpdateRequest.FromString, - response_serializer=vector__service__pb2.UpdateResponse.SerializeToString, - ), - "DescribeIndexStats": grpc.unary_unary_rpc_method_handler( - servicer.DescribeIndexStats, - request_deserializer=vector__service__pb2.DescribeIndexStatsRequest.FromString, - response_serializer=vector__service__pb2.DescribeIndexStatsResponse.SerializeToString, - ), + 'Upsert': grpc.unary_unary_rpc_method_handler( + servicer.Upsert, + request_deserializer=vector__service__pb2.UpsertRequest.FromString, + response_serializer=vector__service__pb2.UpsertResponse.SerializeToString, + ), + 'Delete': grpc.unary_unary_rpc_method_handler( + servicer.Delete, + request_deserializer=vector__service__pb2.DeleteRequest.FromString, + response_serializer=vector__service__pb2.DeleteResponse.SerializeToString, + ), + 'Fetch': grpc.unary_unary_rpc_method_handler( + servicer.Fetch, + request_deserializer=vector__service__pb2.FetchRequest.FromString, + response_serializer=vector__service__pb2.FetchResponse.SerializeToString, + ), + 'Query': grpc.unary_unary_rpc_method_handler( + servicer.Query, + request_deserializer=vector__service__pb2.QueryRequest.FromString, + response_serializer=vector__service__pb2.QueryResponse.SerializeToString, + ), + 'Update': grpc.unary_unary_rpc_method_handler( + servicer.Update, + request_deserializer=vector__service__pb2.UpdateRequest.FromString, + response_serializer=vector__service__pb2.UpdateResponse.SerializeToString, + ), + 'DescribeIndexStats': grpc.unary_unary_rpc_method_handler( + servicer.DescribeIndexStats, + request_deserializer=vector__service__pb2.DescribeIndexStatsRequest.FromString, + response_serializer=vector__service__pb2.DescribeIndexStatsResponse.SerializeToString, + ), } - generic_handler = grpc.method_handlers_generic_handler("VectorService", rpc_method_handlers) + generic_handler = grpc.method_handlers_generic_handler( + 'VectorService', rpc_method_handlers) server.add_generic_rpc_handlers((generic_handler,)) -# This class is part of an EXPERIMENTAL API. + # This class is part of an EXPERIMENTAL API. class VectorService(object): """The `VectorService` interface is exposed by Pinecone's vector index services. This service could also be called a `gRPC` service or a `REST`-like api. """ @staticmethod - def Upsert( - request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None, - ): - return grpc.experimental.unary_unary( - request, + def Upsert(request, target, - "/VectorService/Upsert", + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/VectorService/Upsert', vector__service__pb2.UpsertRequest.SerializeToString, vector__service__pb2.UpsertResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - ) + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) @staticmethod - def Delete( - request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None, - ): - return grpc.experimental.unary_unary( - request, + def Delete(request, target, - "/VectorService/Delete", + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/VectorService/Delete', vector__service__pb2.DeleteRequest.SerializeToString, vector__service__pb2.DeleteResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - ) + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) @staticmethod - def Fetch( - request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None, - ): - return grpc.experimental.unary_unary( - request, + def Fetch(request, target, - "/VectorService/Fetch", + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/VectorService/Fetch', vector__service__pb2.FetchRequest.SerializeToString, vector__service__pb2.FetchResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - ) + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) @staticmethod - def Query( - request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None, - ): - return grpc.experimental.unary_unary( - request, + def Query(request, target, - "/VectorService/Query", + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/VectorService/Query', vector__service__pb2.QueryRequest.SerializeToString, vector__service__pb2.QueryResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - ) + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) @staticmethod - def Update( - request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None, - ): - return grpc.experimental.unary_unary( - request, + def Update(request, target, - "/VectorService/Update", + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/VectorService/Update', vector__service__pb2.UpdateRequest.SerializeToString, vector__service__pb2.UpdateResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - ) + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) @staticmethod - def DescribeIndexStats( - request, - target, - options=(), - channel_credentials=None, - call_credentials=None, - insecure=False, - compression=None, - wait_for_ready=None, - timeout=None, - metadata=None, - ): - return grpc.experimental.unary_unary( - request, + def DescribeIndexStats(request, target, - "/VectorService/DescribeIndexStats", + options=(), + channel_credentials=None, + call_credentials=None, + insecure=False, + compression=None, + wait_for_ready=None, + timeout=None, + metadata=None): + return grpc.experimental.unary_unary(request, target, '/VectorService/DescribeIndexStats', vector__service__pb2.DescribeIndexStatsRequest.SerializeToString, vector__service__pb2.DescribeIndexStatsResponse.FromString, - options, - channel_credentials, - insecure, - call_credentials, - compression, - wait_for_ready, - timeout, - metadata, - ) + options, channel_credentials, + insecure, call_credentials, compression, wait_for_ready, timeout, metadata) diff --git a/pinecone/core/utils/__init__.py b/pinecone/core/utils/__init__.py deleted file mode 100644 index d4cca1643..000000000 --- a/pinecone/core/utils/__init__.py +++ /dev/null @@ -1,136 +0,0 @@ -import inspect -import logging -import re -import uuid -import warnings -from pathlib import Path -from typing import List - -import requests -import urllib3 - -try: - from pinecone.core.grpc.protos import vector_column_service_pb2 - from google.protobuf.struct_pb2 import Struct - from google.protobuf import json_format - import numpy as np - import lz4.frame -except Exception: - pass # ignore for non-[grpc] installations - -DNS_COMPATIBLE_REGEX = re.compile("^[a-z0-9]([a-z0-9]|[-])+[a-z0-9]$") - - -def dump_numpy_public(np_array: "np.ndarray", compressed: bool = False) -> "vector_column_service_pb2.NdArray": - """ - Dump numpy array to vector_column_service_pb2.NdArray - """ - warn_deprecated( - "dump_numpy_public and all numpy-related features will be removed in a future version", - deprecated_in="2.2.1", - removal_in="3.0.0", - ) - protobuf_arr = vector_column_service_pb2.NdArray() - protobuf_arr.dtype = str(np_array.dtype) - protobuf_arr.shape.extend(np_array.shape) - if compressed: - protobuf_arr.buffer = lz4.frame.compress(np_array.tobytes()) - protobuf_arr.compressed = True - else: - protobuf_arr.buffer = np_array.tobytes() - return protobuf_arr - - -def dump_strings_public(strs: List[str], compressed: bool = False) -> "vector_column_service_pb2.NdArray": - warn_deprecated( - "dump_strings_public and all numpy-related features will be removed in a future version", - deprecated_in="2.2.1", - removal_in="3.0.0", - ) - return dump_numpy_public(np.array(strs, dtype="S"), compressed=compressed) - - -def get_version(): - return Path(__file__).parent.parent.parent.joinpath("__version__").read_text().strip() - - -def get_environment(): - return Path(__file__).parent.parent.parent.joinpath("__environment__").read_text().strip() - - -def validate_dns_name(name): - if not DNS_COMPATIBLE_REGEX.match(name): - raise ValueError( - "{} is invalid - service names and node names must consist of lower case " - "alphanumeric characters or '-', start with an alphabetic character, and end with an " - "alphanumeric character (e.g. 'my-name', or 'abc-123')".format(name) - ) - - -def _generate_request_id() -> str: - return str(uuid.uuid4()) - - -def fix_tuple_length(t, n): - """Extend tuple t to length n by adding None items at the end of the tuple. Return the new tuple.""" - return t + ((None,) * (n - len(t))) if len(t) < n else t - - -def get_user_agent(): - client_id = f"python-client-{get_version()}" - user_agent_details = {"requests": requests.__version__, "urllib3": urllib3.__version__} - user_agent = "{} ({})".format(client_id, ", ".join([f"{k}:{v}" for k, v in user_agent_details.items()])) - return user_agent - - -def dict_to_proto_struct(d: dict) -> "Struct": - if not d: - d = {} - s = Struct() - s.update(d) - return s - - -def proto_struct_to_dict(s: "Struct") -> dict: - return json_format.MessageToDict(s) - - -def load_numpy_public(proto_arr: "vector_column_service_pb2.NdArray") -> "np.ndarray": - """ - Load numpy array from protobuf - :param proto_arr: - :return: - """ - warn_deprecated( - "load_numpy_public and all numpy-related features will be removed in a future version", - deprecated_in="2.2.1", - removal_in="3.0.0", - ) - if len(proto_arr.shape) == 0: - return np.array([]) - if proto_arr.compressed: - numpy_arr = np.frombuffer(lz4.frame.decompress(proto_arr.buffer), dtype=proto_arr.dtype) - else: - numpy_arr = np.frombuffer(proto_arr.buffer, dtype=proto_arr.dtype) - return numpy_arr.reshape(proto_arr.shape) - - -def load_strings_public(proto_arr: "vector_column_service_pb2.NdArray") -> List[str]: - warn_deprecated( - "load_strings_public and all numpy-related features will be removed in a future version", - deprecated_in="2.2.1", - removal_in="3.0.0", - ) - return [str(item, "utf-8") for item in load_numpy_public(proto_arr)] - - -def warn_deprecated(description: str = "", deprecated_in: str = None, removal_in: str = None): - message = f"DEPRECATED since v{deprecated_in} [Will be removed in v{removal_in}]: {description}" - warnings.warn(message, FutureWarning) - - -def check_kwargs(caller, given): - argspec = inspect.getfullargspec(caller) - diff = set(given).difference(argspec.args) - if diff: - logging.exception(caller.__name__ + " had unexpected keyword argument(s): " + ", ".join(diff), exc_info=False) diff --git a/pinecone/data/__init__.py b/pinecone/data/__init__.py new file mode 100644 index 000000000..a43d33ac4 --- /dev/null +++ b/pinecone/data/__init__.py @@ -0,0 +1 @@ +from .index import Index \ No newline at end of file diff --git a/pinecone/index.py b/pinecone/data/index.py similarity index 80% rename from pinecone/index.py rename to pinecone/data/index.py index 64d66d676..024351137 100644 --- a/pinecone/index.py +++ b/pinecone/data/index.py @@ -1,17 +1,14 @@ from tqdm.autonotebook import tqdm -from importlib.util import find_spec -import numbers -import numpy as np -from collections.abc import Iterable, Mapping +from collections.abc import Iterable from typing import Union, List, Tuple, Optional, Dict, Any -from .core.client.model.sparse_values import SparseValues -from pinecone import Config +from pinecone.config import Config + +from pinecone.core.client.models import SparseValues from pinecone.core.client import ApiClient -from .core.client.models import ( +from pinecone.core.client.models import ( FetchResponse, - ProtobufAny, QueryRequest, QueryResponse, QueryVector, @@ -28,13 +25,12 @@ DescribeIndexStatsRequest, ) from pinecone.core.client.api.vector_operations_api import VectorOperationsApi -from pinecone.core.utils import fix_tuple_length, get_user_agent, warn_deprecated -import copy +from ..utils import get_user_agent, fix_tuple_length +from .vector_factory import VectorFactory __all__ = [ "Index", "FetchResponse", - "ProtobufAny", "QueryRequest", "QueryResponse", "QueryVector", @@ -52,8 +48,7 @@ "SparseValues", ] -from .core.utils.constants import REQUIRED_VECTOR_FIELDS, OPTIONAL_VECTOR_FIELDS -from .core.utils.error_handling import validate_and_convert_errors +from ..utils.error_handling import validate_and_convert_errors _OPENAPI_ENDPOINT_PARAMS = ( "_return_http_data_only", @@ -65,7 +60,6 @@ "async_req", ) - def parse_query_response(response: QueryResponse, unary_query: bool): if unary_query: response._data_store.pop("results", None) @@ -74,32 +68,30 @@ def parse_query_response(response: QueryResponse, unary_query: bool): response._data_store.pop("namespace", None) return response - -def upsert_numpy_deprecation_notice(context): - numpy_deprecataion_notice = "The ability to pass a numpy ndarray as part of a dictionary argument to upsert() will be removed in a future version of the pinecone client. To remove this warning, use the numpy.ndarray.tolist method to convert your ndarray into a python list before calling upsert()." - message = " ".join([context, numpy_deprecataion_notice]) - warn_deprecated(message, deprecated_in="2.2.1", removal_in="3.0.0") - - -class Index(ApiClient): +class Index(): """ A client for interacting with a Pinecone index via REST API. For improved performance, use the Pinecone GRPC index client. """ - def __init__(self, index_name: str, pool_threads=1): - openapi_client_config = copy.deepcopy(Config.OPENAPI_CONFIG) - openapi_client_config.api_key = openapi_client_config.api_key or {} - openapi_client_config.api_key["ApiKeyAuth"] = openapi_client_config.api_key.get("ApiKeyAuth", Config.API_KEY) - openapi_client_config.server_variables = openapi_client_config.server_variables or {} - openapi_client_config.server_variables = { - **{"environment": Config.ENVIRONMENT, "index_name": index_name, "project_name": Config.PROJECT_NAME}, - **openapi_client_config.server_variables, - } - super().__init__(configuration=openapi_client_config, pool_threads=pool_threads) - self.user_agent = get_user_agent() - self._vector_api = VectorOperationsApi(self) + def __init__(self, api_key: str, host: str, pool_threads=1, **kwargs): + api_key = api_key or kwargs.get("api_key") + host = host or kwargs.get('host') + pool_threads = pool_threads or kwargs.get("pool_threads") + + self._config = Config(api_key=api_key, host=host, **kwargs) + + api_client = ApiClient(configuration=self._config.openapi_config, pool_threads=pool_threads) + api_client.user_agent = get_user_agent() + self._api_client = api_client + self._vector_api = VectorOperationsApi(api_client=api_client) + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + self._api_client.close() @validate_and_convert_errors def upsert( @@ -162,7 +154,7 @@ def upsert( Returns: UpsertResponse, includes the number of vectors upserted. """ - _check_type = kwargs.pop("_check_type", False) + _check_type = kwargs.pop("_check_type", True) if kwargs.get("async_req", False) and batch_size is not None: raise ValueError( @@ -191,81 +183,11 @@ def _upsert_batch( self, vectors: List[Vector], namespace: Optional[str], _check_type: bool, **kwargs ) -> UpsertResponse: args_dict = self._parse_non_empty_args([("namespace", namespace)]) - - def _dict_to_vector(item): - item_keys = set(item.keys()) - if not item_keys.issuperset(REQUIRED_VECTOR_FIELDS): - raise ValueError( - f"Vector dictionary is missing required fields: {list(REQUIRED_VECTOR_FIELDS - item_keys)}" - ) - - excessive_keys = item_keys - (REQUIRED_VECTOR_FIELDS | OPTIONAL_VECTOR_FIELDS) - if len(excessive_keys) > 0: - raise ValueError( - f"Found excess keys in the vector dictionary: {list(excessive_keys)}. " - f"The allowed keys are: {list(REQUIRED_VECTOR_FIELDS | OPTIONAL_VECTOR_FIELDS)}" - ) - - if "sparse_values" in item: - if not isinstance(item["sparse_values"], Mapping): - raise ValueError( - f"Column `sparse_values` is expected to be a dictionary, found {type(item['sparse_values'])}" - ) - - indices = item["sparse_values"].get("indices", None) - values = item["sparse_values"].get("values", None) - - if isinstance(values, np.ndarray): - upsert_numpy_deprecation_notice("Deprecated type passed in sparse_values['values'].") - values = values.tolist() - if isinstance(indices, np.ndarray): - upsert_numpy_deprecation_notice("Deprecated type passed in sparse_values['indices'].") - indices = indices.tolist() - try: - item["sparse_values"] = SparseValues(indices=indices, values=values) - except TypeError as e: - raise ValueError( - "Found unexpected data in column `sparse_values`. " - "Expected format is `'sparse_values': {'indices': List[int], 'values': List[float]}`." - ) from e - - if "metadata" in item: - metadata = item.get("metadata") - if not isinstance(metadata, Mapping): - raise TypeError(f"Column `metadata` is expected to be a dictionary, found {type(metadata)}") - - if isinstance(item["values"], np.ndarray): - upsert_numpy_deprecation_notice("Deprecated type passed in 'values'.") - item["values"] = item["values"].tolist() - - try: - return Vector(**item) - except TypeError as e: - # if not isinstance(item['values'], Iterable) or not isinstance(item['values'][0], numbers.Real): - # raise TypeError(f"Column `values` is expected to be a list of floats") - if not isinstance(item["values"], Iterable) or not isinstance(item["values"][0], numbers.Real): - raise TypeError(f"Column `values` is expected to be a list of floats") - raise - - def _vector_transform(item: Union[Vector, Tuple]): - if isinstance(item, Vector): - return item - elif isinstance(item, tuple): - if len(item) > 3: - raise ValueError( - f"Found a tuple of length {len(item)} which is not supported. " - f"Vectors can be represented as tuples either the form (id, values, metadata) or (id, values). " - f"To pass sparse values please use either dicts or a Vector objects as inputs." - ) - id, values, metadata = fix_tuple_length(item, 3) - return Vector(id=id, values=values, metadata=metadata or {}, _check_type=_check_type) - elif isinstance(item, Mapping): - return _dict_to_vector(item) - raise ValueError(f"Invalid vector value passed: cannot interpret type {type(item)}") + vec_builder = lambda v: VectorFactory.build(v, check_type=_check_type) return self._vector_api.upsert( UpsertRequest( - vectors=list(map(_vector_transform, vectors)), + vectors=list(map(vec_builder, vectors)), **args_dict, _check_type=_check_type, **{k: v for k, v in kwargs.items() if k not in _OPENAPI_ENDPOINT_PARAMS}, diff --git a/pinecone/data/vector_factory.py b/pinecone/data/vector_factory.py new file mode 100644 index 000000000..831df4f12 --- /dev/null +++ b/pinecone/data/vector_factory.py @@ -0,0 +1,111 @@ +import numbers + +from collections.abc import Iterable, Mapping +from typing import Union, Tuple, Dict + +from ..utils import fix_tuple_length, convert_to_list +from ..utils.constants import REQUIRED_VECTOR_FIELDS, OPTIONAL_VECTOR_FIELDS + +from pinecone.core.client.models import ( + Vector, + SparseValues +) + +class VectorDictionaryMissingKeysError(ValueError): + def __init__(self, item): + message = f"Vector dictionary is missing required fields: {list(REQUIRED_VECTOR_FIELDS - set(item.keys()))}" + super().__init__(message) + +class VectorDictionaryExcessKeysError(ValueError): + def __init__(self, item): + invalid_keys = list(set(item.keys()) - (REQUIRED_VECTOR_FIELDS | OPTIONAL_VECTOR_FIELDS)) + message = f"Found excess keys in the vector dictionary: {invalid_keys}. The allowed keys are: {list(REQUIRED_VECTOR_FIELDS | OPTIONAL_VECTOR_FIELDS)}" + super().__init__(message) + +class VectorTupleLengthError(ValueError): + def __init__(self, item): + message = f"Found a tuple of length {len(item)} which is not supported. Vectors can be represented as tuples either the form (id, values, metadata) or (id, values). To pass sparse values please use either dicts or a Vector objects as inputs." + super().__init__(message) + +class SparseValuesTypeError(ValueError): + def __init__(self): + message = "Found unexpected data in column `sparse_values`. Expected format is `'sparse_values': {'indices': List[int], 'values': List[float]}`." + super().__init__(message) + +class SparseValuesMissingKeysError(ValueError): + def __init__(self, sparse_values_dict): + message = f"Missing required keys in data in column `sparse_values`. Expected format is `'sparse_values': {{'indices': List[int], 'values': List[float]}}`. Found keys {list(sparse_values_dict.keys())}" + super().__init__(message) + +class SparseValuesDictionaryExpectedError(ValueError): + def __init__(self, sparse_values_dict): + message = f"Column `sparse_values` is expected to be a dictionary, found {type(sparse_values_dict)}" + super().__init__(message) + +class MetadataDictionaryExpectedError(ValueError): + def __init__(self, item): + message = f"Column `metadata` is expected to be a dictionary, found {type(item['metadata'])}" + super().__init__(message) + +class VectorFactory: + @staticmethod + def build(item: Union[Vector, Tuple, Dict], check_type: bool = True) -> Vector: + if isinstance(item, Vector): + return item + elif isinstance(item, tuple): + return VectorFactory._tuple_to_vector(item, check_type) + elif isinstance(item, Mapping): + return VectorFactory._dict_to_vector(item, check_type) + else: + raise ValueError(f"Invalid vector value passed: cannot interpret type {type(item)}") + + @staticmethod + def _tuple_to_vector(item, check_type: bool) -> Vector: + if len(item) < 2 or len(item) > 3: + raise VectorTupleLengthError(item) + id, values, metadata = fix_tuple_length(item, 3) + return Vector(id=id, values=convert_to_list(values), metadata=metadata or {}, _check_type=check_type) + + @staticmethod + def _dict_to_vector(item, check_type: bool) -> Vector: + item_keys = set(item.keys()) + if not item_keys.issuperset(REQUIRED_VECTOR_FIELDS): + raise VectorDictionaryMissingKeysError(item) + + excessive_keys = item_keys - (REQUIRED_VECTOR_FIELDS | OPTIONAL_VECTOR_FIELDS) + if len(excessive_keys) > 0: + raise VectorDictionaryExcessKeysError(item) + + values = item.get("values") + if "values" in item: + item["values"] = convert_to_list(values) + + sparse_values = item.get("sparse_values") + if sparse_values and not isinstance(sparse_values, SparseValues): + item["sparse_values"] = VectorFactory._dict_to_sparse_values(sparse_values, check_type) + + metadata = item.get("metadata") + if metadata and not isinstance(metadata, Mapping): + raise MetadataDictionaryExpectedError(item) + + try: + return Vector(**item, _check_type=check_type) + except TypeError as e: + if not isinstance(item["values"], Iterable) or not isinstance(item["values"][0], numbers.Real): + raise TypeError(f"Column `values` is expected to be a list of floats") + raise e + + @staticmethod + def _dict_to_sparse_values(sparse_values_dict: Dict, check_type: bool) -> SparseValues: + if not isinstance(sparse_values_dict, Mapping): + raise SparseValuesDictionaryExpectedError(sparse_values_dict) + if not {"indices", "values"}.issubset(sparse_values_dict): + raise SparseValuesMissingKeysError(sparse_values_dict) + + indices = convert_to_list(sparse_values_dict.get("indices")) + values = convert_to_list(sparse_values_dict.get("values")) + + try: + return SparseValues(indices=indices, values=values, _check_type=check_type) + except TypeError: + raise SparseValuesTypeError() \ No newline at end of file diff --git a/pinecone/exceptions.py b/pinecone/exceptions.py index ce23887f0..98610be39 100644 --- a/pinecone/exceptions.py +++ b/pinecone/exceptions.py @@ -1,4 +1,3 @@ -from .core.exceptions import PineconeException, PineconeProtocolError from .core.client.exceptions import ( OpenApiException, ApiAttributeError, @@ -12,7 +11,17 @@ ServiceException, ) +class PineconeException(Exception): + """The base exception class for all Pinecone client exceptions.""" + +class PineconeProtocolError(PineconeException): + """Raised when something unexpected happens mid-request/response.""" + +class PineconeConfigurationError(PineconeException): + """Raised when a configuration error occurs.""" + __all__ = [ + "PineconeConfigurationError", "PineconeException", "PineconeProtocolError", "OpenApiException", diff --git a/pinecone/grpc/__init__.py b/pinecone/grpc/__init__.py new file mode 100644 index 000000000..77920733d --- /dev/null +++ b/pinecone/grpc/__init__.py @@ -0,0 +1,2 @@ +from .index_grpc import GRPCIndex +from .pinecone import Pinecone \ No newline at end of file diff --git a/pinecone/grpc/base.py b/pinecone/grpc/base.py new file mode 100644 index 000000000..9dad1bbc4 --- /dev/null +++ b/pinecone/grpc/base.py @@ -0,0 +1,161 @@ +import logging +from abc import ABC, abstractmethod +from functools import wraps +from typing import Dict + +import certifi +import grpc +from grpc._channel import _InactiveRpcError +import json + +from .retry import RetryConfig + +from pinecone import Config +from .utils import _generate_request_id +from .config import GRPCClientConfig +from pinecone.utils.constants import MAX_MSG_SIZE, REQUEST_ID, CLIENT_VERSION +from pinecone.exceptions import PineconeException + +_logger = logging.getLogger(__name__) + +class GRPCIndexBase(ABC): + """ + Base class for grpc-based interaction with Pinecone indexes + """ + + _pool = None + + def __init__( + self, + index_name: str, + config: Config, + channel=None, + grpc_config: GRPCClientConfig = None, + _endpoint_override: str = None, + ): + self.name = index_name + + self.grpc_client_config = grpc_config or GRPCClientConfig() + self.retry_config = self.grpc_client_config.retry_config or RetryConfig() + self.fixed_metadata = {"api-key": config.API_KEY, "service-name": index_name, "client-version": CLIENT_VERSION} + self._endpoint_override = _endpoint_override + + self.method_config = json.dumps( + { + "methodConfig": [ + { + "name": [{"service": "VectorService.Upsert"}], + "retryPolicy": { + "maxAttempts": 5, + "initialBackoff": "0.1s", + "maxBackoff": "1s", + "backoffMultiplier": 2, + "retryableStatusCodes": ["UNAVAILABLE"], + }, + }, + { + "name": [{"service": "VectorService"}], + "retryPolicy": { + "maxAttempts": 5, + "initialBackoff": "0.1s", + "maxBackoff": "1s", + "backoffMultiplier": 2, + "retryableStatusCodes": ["UNAVAILABLE"], + }, + }, + ] + } + ) + + self._channel = channel or self._gen_channel() + self.stub = self.stub_class(self._channel) + + @property + @abstractmethod + def stub_class(self): + pass + + def _endpoint(self): + return ( + self._endpoint_override + if self._endpoint_override + else f"{self.name}-{Config.PROJECT_NAME}.svc.{Config.ENVIRONMENT}.pinecone.io:443" + ) + + def _gen_channel(self, options=None): + target = self._endpoint() + default_options = { + "grpc.max_send_message_length": MAX_MSG_SIZE, + "grpc.max_receive_message_length": MAX_MSG_SIZE, + "grpc.service_config": self.method_config, + "grpc.enable_retries": True, + } + if self.grpc_client_config.secure: + default_options["grpc.ssl_target_name_override"] = target.split(":")[0] + user_provided_options = options or {} + _options = tuple((k, v) for k, v in {**default_options, **user_provided_options}.items()) + _logger.debug( + "creating new channel with endpoint %s options %s and config %s", target, _options, self.grpc_client_config + ) + if not self.grpc_client_config.secure: + channel = grpc.insecure_channel(target, options=_options) + else: + root_cas = open(certifi.where(), "rb").read() + tls = grpc.ssl_channel_credentials(root_certificates=root_cas) + channel = grpc.secure_channel(target, tls, options=_options) + + return channel + + @property + def channel(self): + """Creates GRPC channel.""" + if self.grpc_client_config.reuse_channel and self._channel and self.grpc_server_on(): + return self._channel + self._channel = self._gen_channel() + return self._channel + + def grpc_server_on(self) -> bool: + try: + grpc.channel_ready_future(self._channel).result(timeout=self.grpc_client_config.conn_timeout) + return True + except grpc.FutureTimeoutError: + return False + + def close(self): + """Closes the connection to the index.""" + try: + self._channel.close() + except TypeError: + pass + + def _wrap_grpc_call( + self, func, request, timeout=None, metadata=None, credentials=None, wait_for_ready=None, compression=None + ): + @wraps(func) + def wrapped(): + user_provided_metadata = metadata or {} + _metadata = tuple( + (k, v) for k, v in {**self.fixed_metadata, **self._request_metadata(), **user_provided_metadata}.items() + ) + try: + return func( + request, + timeout=timeout, + metadata=_metadata, + credentials=credentials, + wait_for_ready=wait_for_ready, + compression=compression, + ) + except _InactiveRpcError as e: + raise PineconeException(e._state.debug_error_string) from e + + return wrapped() + + def _request_metadata(self) -> Dict[str, str]: + return {REQUEST_ID: _generate_request_id()} + + def __enter__(self): + return self + + def __exit__(self, exc_type, exc_value, traceback): + self.close() diff --git a/pinecone/grpc/config.py b/pinecone/grpc/config.py new file mode 100644 index 000000000..13ab7dae3 --- /dev/null +++ b/pinecone/grpc/config.py @@ -0,0 +1,33 @@ +from .retry import RetryConfig +from typing import NamedTuple, Optional, Dict + + +class GRPCClientConfig(NamedTuple): + """ + GRPC client configuration options. + + :param secure: Whether to use encrypted protocol (SSL). defaults to True. + :type traceroute: bool, optional + :param timeout: defaults to 2 seconds. Fail if gateway doesn't receive response within timeout. + :type timeout: int, optional + :param conn_timeout: defaults to 1. Timeout to retry connection if gRPC is unavailable. 0 is no retry. + :type conn_timeout: int, optional + :param reuse_channel: Whether to reuse the same grpc channel for multiple requests + :type reuse_channel: bool, optional + :param retry_config: RetryConfig indicating how requests should be retried + :type retry_config: RetryConfig, optional + :param grpc_channel_options: A dict of gRPC channel arguments + :type grpc_channel_options: Dict[str, str] + """ + + secure: bool = True + timeout: int = 20 + conn_timeout: int = 1 + reuse_channel: bool = True + retry_config: Optional[RetryConfig] = None + grpc_channel_options: Dict[str, str] = None + + @classmethod + def _from_dict(cls, kwargs: dict): + cls_kwargs = {kk: vv for kk, vv in kwargs.items() if kk in cls._fields} + return cls(**cls_kwargs) diff --git a/pinecone/grpc/future.py b/pinecone/grpc/future.py new file mode 100644 index 000000000..160169d67 --- /dev/null +++ b/pinecone/grpc/future.py @@ -0,0 +1,34 @@ +from grpc._channel import _MultiThreadedRendezvous +from pinecone.exceptions import PineconeException + + +class PineconeGrpcFuture: + def __init__(self, delegate): + self._delegate = delegate + + def cancel(self): + return self._delegate.cancel() + + def cancelled(self): + return self._delegate.cancelled() + + def running(self): + return self._delegate.running() + + def done(self): + return self._delegate.done() + + def add_done_callback(self, fun): + return self._delegate.add_done_callback(fun) + + def result(self, timeout=None): + try: + return self._delegate.result(timeout=timeout) + except _MultiThreadedRendezvous as e: + raise PineconeException(e._state.debug_error_string) from e + + def exception(self, timeout=None): + return self._delegate.exception(timeout=timeout) + + def traceback(self, timeout=None): + return self._delegate.traceback(timeout=timeout) diff --git a/pinecone/core/grpc/index_grpc.py b/pinecone/grpc/index_grpc.py similarity index 70% rename from pinecone/core/grpc/index_grpc.py rename to pinecone/grpc/index_grpc.py index f62e9ec8a..3b4344dec 100644 --- a/pinecone/core/grpc/index_grpc.py +++ b/pinecone/grpc/index_grpc.py @@ -1,22 +1,19 @@ import logging import numbers -from abc import ABC, abstractmethod -from functools import wraps -from importlib.util import find_spec -from typing import NamedTuple, Optional, Dict, Iterable, Union, List, Tuple, Any +from typing import Optional, Dict, Iterable, Union, List, Tuple, Any from collections.abc import Mapping -import certifi -import grpc from google.protobuf import json_format -from grpc._channel import _InactiveRpcError, _MultiThreadedRendezvous + from tqdm.autonotebook import tqdm -import json -from pinecone import FetchResponse, QueryResponse, ScoredVector, SingleQueryResults, DescribeIndexStatsResponse -from pinecone.config import Config -from pinecone.core.client.model.namespace_summary import NamespaceSummary -from pinecone.core.client.model.vector import Vector as _Vector +from .utils import dict_to_proto_struct, parse_fetch_response, parse_query_response, parse_stats_response + +from pinecone.core.client.models import ( + FetchResponse, + QueryResponse, + DescribeIndexStatsResponse, +) from pinecone.core.grpc.protos.vector_service_pb2 import ( Vector as GRPCVector, QueryVector as GRPCQueryVector, @@ -31,311 +28,21 @@ UpdateResponse, SparseValues as GRPCSparseValues, ) -from pinecone.core.client.model.sparse_values import SparseValues from pinecone.core.grpc.protos.vector_service_pb2_grpc import VectorServiceStub -from pinecone.core.grpc.retry import RetryOnRpcErrorClientInterceptor, RetryConfig -from pinecone.core.utils import _generate_request_id, dict_to_proto_struct, fix_tuple_length -from pinecone.core.utils.constants import ( - MAX_MSG_SIZE, - REQUEST_ID, - CLIENT_VERSION, +from pinecone.utils import fix_tuple_length +from pinecone.utils.constants import ( REQUIRED_VECTOR_FIELDS, OPTIONAL_VECTOR_FIELDS, ) -from pinecone.exceptions import PineconeException +from .base import GRPCIndexBase +from .future import PineconeGrpcFuture __all__ = ["GRPCIndex", "GRPCVector", "GRPCQueryVector", "GRPCSparseValues"] _logger = logging.getLogger(__name__) -class GRPCClientConfig(NamedTuple): - """ - GRPC client configuration options. - - :param secure: Whether to use encrypted protocol (SSL). defaults to True. - :type traceroute: bool, optional - :param timeout: defaults to 2 seconds. Fail if gateway doesn't receive response within timeout. - :type timeout: int, optional - :param conn_timeout: defaults to 1. Timeout to retry connection if gRPC is unavailable. 0 is no retry. - :type conn_timeout: int, optional - :param reuse_channel: Whether to reuse the same grpc channel for multiple requests - :type reuse_channel: bool, optional - :param retry_config: RetryConfig indicating how requests should be retried - :type retry_config: RetryConfig, optional - :param grpc_channel_options: A dict of gRPC channel arguments - :type grpc_channel_options: Dict[str, str] - """ - - secure: bool = True - timeout: int = 20 - conn_timeout: int = 1 - reuse_channel: bool = True - retry_config: Optional[RetryConfig] = None - grpc_channel_options: Dict[str, str] = None - - @classmethod - def _from_dict(cls, kwargs: dict): - cls_kwargs = {kk: vv for kk, vv in kwargs.items() if kk in cls._fields} - return cls(**cls_kwargs) - - -class GRPCIndexBase(ABC): - """ - Base class for grpc-based interaction with Pinecone indexes - """ - - _pool = None - - def __init__( - self, index_name: str, channel=None, grpc_config: GRPCClientConfig = None, _endpoint_override: str = None - ): - self.name = index_name - - self.grpc_client_config = grpc_config or GRPCClientConfig() - self.retry_config = self.grpc_client_config.retry_config or RetryConfig() - self.fixed_metadata = {"api-key": Config.API_KEY, "service-name": index_name, "client-version": CLIENT_VERSION} - self._endpoint_override = _endpoint_override - - self.method_config = json.dumps( - { - "methodConfig": [ - { - "name": [{"service": "VectorService.Upsert"}], - "retryPolicy": { - "maxAttempts": 5, - "initialBackoff": "0.1s", - "maxBackoff": "1s", - "backoffMultiplier": 2, - "retryableStatusCodes": ["UNAVAILABLE"], - }, - }, - { - "name": [{"service": "VectorService"}], - "retryPolicy": { - "maxAttempts": 5, - "initialBackoff": "0.1s", - "maxBackoff": "1s", - "backoffMultiplier": 2, - "retryableStatusCodes": ["UNAVAILABLE"], - }, - }, - ] - } - ) - - self._channel = channel or self._gen_channel() - self.stub = self.stub_class(self._channel) - - @property - @abstractmethod - def stub_class(self): - pass - - def _endpoint(self): - return ( - self._endpoint_override - if self._endpoint_override - else f"{self.name}-{Config.PROJECT_NAME}.svc.{Config.ENVIRONMENT}.pinecone.io:443" - ) - - def _gen_channel(self, options=None): - target = self._endpoint() - default_options = { - "grpc.max_send_message_length": MAX_MSG_SIZE, - "grpc.max_receive_message_length": MAX_MSG_SIZE, - "grpc.service_config": self.method_config, - "grpc.enable_retries": True, - } - if self.grpc_client_config.secure: - default_options["grpc.ssl_target_name_override"] = target.split(":")[0] - user_provided_options = options or {} - _options = tuple((k, v) for k, v in {**default_options, **user_provided_options}.items()) - _logger.debug( - "creating new channel with endpoint %s options %s and config %s", target, _options, self.grpc_client_config - ) - if not self.grpc_client_config.secure: - channel = grpc.insecure_channel(target, options=_options) - else: - root_cas = open(certifi.where(), "rb").read() - tls = grpc.ssl_channel_credentials(root_certificates=root_cas) - channel = grpc.secure_channel(target, tls, options=_options) - - return channel - - @property - def channel(self): - """Creates GRPC channel.""" - if self.grpc_client_config.reuse_channel and self._channel and self.grpc_server_on(): - return self._channel - self._channel = self._gen_channel() - return self._channel - - def grpc_server_on(self) -> bool: - try: - grpc.channel_ready_future(self._channel).result(timeout=self.grpc_client_config.conn_timeout) - return True - except grpc.FutureTimeoutError: - return False - - def close(self): - """Closes the connection to the index.""" - try: - self._channel.close() - except TypeError: - pass - - def _wrap_grpc_call( - self, func, request, timeout=None, metadata=None, credentials=None, wait_for_ready=None, compression=None - ): - @wraps(func) - def wrapped(): - user_provided_metadata = metadata or {} - _metadata = tuple( - (k, v) for k, v in {**self.fixed_metadata, **self._request_metadata(), **user_provided_metadata}.items() - ) - try: - return func( - request, - timeout=timeout, - metadata=_metadata, - credentials=credentials, - wait_for_ready=wait_for_ready, - compression=compression, - ) - except _InactiveRpcError as e: - raise PineconeException(e._state.debug_error_string) from e - - return wrapped() - - def _request_metadata(self) -> Dict[str, str]: - return {REQUEST_ID: _generate_request_id()} - - def __enter__(self): - return self - - def __exit__(self, exc_type, exc_value, traceback): - self.close() - - -def parse_sparse_values(sparse_values: dict): - return ( - SparseValues(indices=sparse_values["indices"], values=sparse_values["values"]) - if sparse_values - else SparseValues(indices=[], values=[]) - ) - - -def parse_fetch_response(response: dict): - vd = {} - vectors = response.get("vectors") - if not vectors: - return None - for id, vec in vectors.items(): - v_obj = _Vector( - id=vec["id"], - values=vec["values"], - sparse_values=parse_sparse_values(vec.get("sparseValues")), - metadata=vec.get("metadata", None), - _check_type=False, - ) - vd[id] = v_obj - namespace = response.get("namespace", "") - return FetchResponse(vectors=vd, namespace=namespace, _check_type=False) - - -def parse_query_response(response: dict, unary_query: bool, _check_type: bool = False): - res = [] - - # TODO: consider deleting this deprecated case - for match in response.get("results", []): - namespace = match.get("namespace", "") - m = [] - if "matches" in match: - for item in match["matches"]: - sc = ScoredVector( - id=item["id"], - score=item.get("score", 0.0), - values=item.get("values", []), - sparse_values=parse_sparse_values(item.get("sparseValues")), - metadata=item.get("metadata", {}), - ) - m.append(sc) - res.append(SingleQueryResults(matches=m, namespace=namespace)) - - m = [] - for item in response.get("matches", []): - sc = ScoredVector( - id=item["id"], - score=item.get("score", 0.0), - values=item.get("values", []), - sparse_values=parse_sparse_values(item.get("sparseValues")), - metadata=item.get("metadata", {}), - _check_type=_check_type, - ) - m.append(sc) - - kwargs = {"_check_type": _check_type} - if unary_query: - kwargs["namespace"] = response.get("namespace", "") - kwargs["matches"] = m - else: - kwargs["results"] = res - return QueryResponse(**kwargs) - - -def parse_stats_response(response: dict): - fullness = response.get("indexFullness", 0.0) - total_vector_count = response.get("totalVectorCount", 0) - dimension = response.get("dimension", 0) - summaries = response.get("namespaces", {}) - namespace_summaries = {} - for key in summaries: - vc = summaries[key].get("vectorCount", 0) - namespace_summaries[key] = NamespaceSummary(vector_count=vc) - return DescribeIndexStatsResponse( - namespaces=namespace_summaries, - dimension=dimension, - index_fullness=fullness, - total_vector_count=total_vector_count, - _check_type=False, - ) - - -class PineconeGrpcFuture: - def __init__(self, delegate): - self._delegate = delegate - - def cancel(self): - return self._delegate.cancel() - - def cancelled(self): - return self._delegate.cancelled() - - def running(self): - return self._delegate.running() - - def done(self): - return self._delegate.done() - - def add_done_callback(self, fun): - return self._delegate.add_done_callback(fun) - - def result(self, timeout=None): - try: - return self._delegate.result(timeout=timeout) - except _MultiThreadedRendezvous as e: - raise PineconeException(e._state.debug_error_string) from e - - def exception(self, timeout=None): - return self._delegate.exception(timeout=timeout) - - def traceback(self, timeout=None): - return self._delegate.traceback(timeout=timeout) - - class GRPCIndex(GRPCIndexBase): - """A client for interacting with a Pinecone index via GRPC API.""" @property @@ -349,7 +56,7 @@ def upsert( namespace: Optional[str] = None, batch_size: Optional[int] = None, show_progress: bool = True, - **kwargs + **kwargs, ) -> Union[UpsertResponse, PineconeGrpcFuture]: """ The upsert operation writes vectors into a namespace. @@ -565,7 +272,7 @@ def delete( namespace: Optional[str] = None, filter: Optional[Dict[str, Union[str, float, int, bool, List, dict]]] = None, async_req: bool = False, - **kwargs + **kwargs, ) -> Union[DeleteResponse, PineconeGrpcFuture]: """ The Delete operation deletes vectors from the index, from a single namespace. @@ -650,7 +357,7 @@ def query( include_values: Optional[bool] = None, include_metadata: Optional[bool] = None, sparse_vector: Optional[Union[GRPCSparseValues, Dict[str, Union[List[float], List[int]]]]] = None, - **kwargs + **kwargs, ) -> QueryResponse: """ The Query operation searches a namespace, using a query vector. @@ -740,7 +447,7 @@ def update( set_metadata: Optional[Dict[str, Union[str, float, int, bool, List[int], List[float], List[str]]]] = None, namespace: Optional[str] = None, sparse_values: Optional[Union[GRPCSparseValues, Dict[str, Union[List[float], List[int]]]]] = None, - **kwargs + **kwargs, ) -> Union[UpdateResponse, PineconeGrpcFuture]: """ The Update operation updates vector in a namespace. diff --git a/pinecone/grpc/pinecone.py b/pinecone/grpc/pinecone.py new file mode 100644 index 000000000..be7654259 --- /dev/null +++ b/pinecone/grpc/pinecone.py @@ -0,0 +1,7 @@ +from ..control.pinecone import Pinecone +from .index_grpc import GRPCIndex + +class Pinecone(Pinecone): + def Index(self, name: str): + index_host = self.index_host_store.get_host(self.index_api, self.config, name) + return GRPCIndex(api_key=self.config.API_KEY, host=index_host) diff --git a/pinecone/core/grpc/retry.py b/pinecone/grpc/retry.py similarity index 100% rename from pinecone/core/grpc/retry.py rename to pinecone/grpc/retry.py diff --git a/pinecone/grpc/utils.py b/pinecone/grpc/utils.py new file mode 100644 index 000000000..fc69c83e5 --- /dev/null +++ b/pinecone/grpc/utils.py @@ -0,0 +1,107 @@ +import uuid + +from google.protobuf.struct_pb2 import Struct + +from pinecone.core.client.models import ( + Vector as _Vector, + ScoredVector, + SparseValues, + FetchResponse, + SingleQueryResults, + QueryResponse, + DescribeIndexStatsResponse, + NamespaceSummary, +) + +def _generate_request_id() -> str: + return str(uuid.uuid4()) + +def dict_to_proto_struct(d: dict) -> "Struct": + if not d: + d = {} + s = Struct() + s.update(d) + return s + +def parse_sparse_values(sparse_values: dict): + return ( + SparseValues(indices=sparse_values["indices"], values=sparse_values["values"]) + if sparse_values + else SparseValues(indices=[], values=[]) + ) + + +def parse_fetch_response(response: dict): + vd = {} + vectors = response.get("vectors") + if not vectors: + return None + for id, vec in vectors.items(): + v_obj = _Vector( + id=vec["id"], + values=vec["values"], + sparse_values=parse_sparse_values(vec.get("sparseValues")), + metadata=vec.get("metadata", None), + _check_type=False, + ) + vd[id] = v_obj + namespace = response.get("namespace", "") + return FetchResponse(vectors=vd, namespace=namespace, _check_type=False) + + +def parse_query_response(response: dict, unary_query: bool, _check_type: bool = False): + res = [] + + # TODO: consider deleting this deprecated case + for match in response.get("results", []): + namespace = match.get("namespace", "") + m = [] + if "matches" in match: + for item in match["matches"]: + sc = ScoredVector( + id=item["id"], + score=item.get("score", 0.0), + values=item.get("values", []), + sparse_values=parse_sparse_values(item.get("sparseValues")), + metadata=item.get("metadata", {}), + ) + m.append(sc) + res.append(SingleQueryResults(matches=m, namespace=namespace)) + + m = [] + for item in response.get("matches", []): + sc = ScoredVector( + id=item["id"], + score=item.get("score", 0.0), + values=item.get("values", []), + sparse_values=parse_sparse_values(item.get("sparseValues")), + metadata=item.get("metadata", {}), + _check_type=_check_type, + ) + m.append(sc) + + kwargs = {"_check_type": _check_type} + if unary_query: + kwargs["namespace"] = response.get("namespace", "") + kwargs["matches"] = m + else: + kwargs["results"] = res + return QueryResponse(**kwargs) + + +def parse_stats_response(response: dict): + fullness = response.get("indexFullness", 0.0) + total_vector_count = response.get("totalVectorCount", 0) + dimension = response.get("dimension", 0) + summaries = response.get("namespaces", {}) + namespace_summaries = {} + for key in summaries: + vc = summaries[key].get("vectorCount", 0) + namespace_summaries[key] = NamespaceSummary(vector_count=vc) + return DescribeIndexStatsResponse( + namespaces=namespace_summaries, + dimension=dimension, + index_fullness=fullness, + total_vector_count=total_vector_count, + _check_type=False, + ) diff --git a/pinecone/info.py b/pinecone/info.py deleted file mode 100644 index 36f5ae2ed..000000000 --- a/pinecone/info.py +++ /dev/null @@ -1,35 +0,0 @@ -from pinecone.core.api_action import ActionAPI, VersionResponse, WhoAmIResponse -from pinecone.config import Config - -import time -import requests - -__all__ = ["version", "whoami", "VersionResponse", "WhoAmIResponse"] - - -def _get_action_api(): - return ActionAPI(host=Config.CONTROLLER_HOST, api_key=Config.API_KEY) - - -def version() -> VersionResponse: - """Returns version information (client and server).""" - api = _get_action_api() - return api.version() - - -def whoami() -> WhoAmIResponse: - """Returns the details of the currently authenticated API key.""" - api = _get_action_api() - return api.whoami() - - -def wait_controller_ready(timeout: int = 30): - connection = False - max_time = time.time() + timeout - while (not connection) and time.time() < max_time: - try: - version() - time.sleep(3) - connection = True - except requests.exceptions.ConnectionError: - time.sleep(1) diff --git a/pinecone/manage.py b/pinecone/manage.py deleted file mode 100644 index 76541edf7..000000000 --- a/pinecone/manage.py +++ /dev/null @@ -1,291 +0,0 @@ -import time -from typing import NamedTuple, Optional - -import pinecone -from pinecone.config import Config -from pinecone.core.client.api.index_operations_api import IndexOperationsApi -from pinecone.core.client.api_client import ApiClient -from pinecone.core.client.model.create_request import CreateRequest -from pinecone.core.client.model.patch_request import PatchRequest -from pinecone.core.client.model.create_collection_request import CreateCollectionRequest -from pinecone.core.utils import get_user_agent - -__all__ = [ - "create_index", - "delete_index", - "describe_index", - "list_indexes", - "scale_index", - "create_collection", - "describe_collection", - "list_collections", - "delete_collection", - "configure_index", - "CollectionDescription", - "IndexDescription", -] - - -class IndexDescription(NamedTuple): - name: str - metric: str - replicas: int - dimension: int - shards: int - pods: int - pod_type: str - status: None - metadata_config: None - source_collection: None - - -class CollectionDescription(object): - def __init__(self, keys, values): - for k, v in zip(keys, values): - self.__dict__[k] = v - - def __str__(self): - return str(self.__dict__) - - -def _get_api_instance(): - client_config = Config.OPENAPI_CONFIG - client_config.api_key = client_config.api_key or {} - client_config.api_key["ApiKeyAuth"] = client_config.api_key.get("ApiKeyAuth", Config.API_KEY) - client_config.server_variables = {**{"environment": Config.ENVIRONMENT}, **client_config.server_variables} - - # If a custom host has been passed with initialization pass it to the client_config - if (Config.CONTROLLER_HOST): - client_config.host = Config.CONTROLLER_HOST - - api_client = ApiClient(configuration=client_config) - api_client.user_agent = get_user_agent() - api_instance = IndexOperationsApi(api_client) - return api_instance - - -def _get_status(name: str): - api_instance = _get_api_instance() - response = api_instance.describe_index(name) - return response["status"] - - -def create_index( - name: str, - dimension: int, - timeout: int = None, - index_type: str = "approximated", - metric: str = "cosine", - replicas: int = 1, - shards: int = 1, - pods: int = 1, - pod_type: str = "p1", - index_config: dict = None, - metadata_config: dict = None, - source_collection: str = "", -): - """Creates a Pinecone index. - - :param name: the name of the index. - :type name: str - :param dimension: the dimension of vectors that would be inserted in the index - :param index_type: type of index, one of `{"approximated", "exact"}`, defaults to "approximated". - The "approximated" index uses fast approximate search algorithms developed by Pinecone. - The "exact" index uses accurate exact search algorithms. - It performs exhaustive searches and thus it is usually slower than the "approximated" index. - :type index_type: str, optional - :param metric: type of metric used in the vector index, one of `{"cosine", "dotproduct", "euclidean"}`, defaults to "cosine". - Use "cosine" for cosine similarity, - "dotproduct" for dot-product, - and "euclidean" for euclidean distance. - :type metric: str, optional - :param replicas: the number of replicas, defaults to 1. - Use at least 2 replicas if you need high availability (99.99% uptime) for querying. - For additional throughput (QPS) your index needs to support, provision additional replicas. - :type replicas: int, optional - :param shards: the number of shards per index, defaults to 1. - Use 1 shard per 1GB of vectors - :type shards: int,optional - :param pods: Total number of pods to be used by the index. pods = shard*replicas - :type pods: int,optional - :param pod_type: the pod type to be used for the index. can be one of p1 or s1. - :type pod_type: str,optional - :param index_config: Advanced configuration options for the index - :param metadata_config: Configuration related to the metadata index - :type metadata_config: dict, optional - :param source_collection: Collection name to create the index from - :type metadata_config: str, optional - :type timeout: int, optional - :param timeout: Timeout for wait until index gets ready. If None, wait indefinitely; if >=0, time out after this many seconds; - if -1, return immediately and do not wait. Default: None - """ - api_instance = _get_api_instance() - - api_instance.create_index( - create_request=CreateRequest( - name=name, - dimension=dimension, - index_type=index_type, - metric=metric, - replicas=replicas, - shards=shards, - pods=pods, - pod_type=pod_type, - index_config=index_config or {}, - metadata_config=metadata_config, - source_collection=source_collection, - ) - ) - - def is_ready(): - status = _get_status(name) - ready = status["ready"] - return ready - - if timeout == -1: - return - if timeout is None: - while not is_ready(): - time.sleep(5) - else: - while (not is_ready()) and timeout >= 0: - time.sleep(5) - timeout -= 5 - if timeout and timeout < 0: - raise ( - TimeoutError( - "Please call the describe_index API ({}) to confirm index status.".format( - "https://www.pinecone.io/docs/api/operation/describe_index/" - ) - ) - ) - - -def delete_index(name: str, timeout: int = None): - """Deletes a Pinecone index. - - :param name: the name of the index. - :type name: str - :param timeout: Timeout for wait until index gets ready. If None, wait indefinitely; if >=0, time out after this many seconds; - if -1, return immediately and do not wait. Default: None - :type timeout: int, optional - """ - api_instance = _get_api_instance() - api_instance.delete_index(name) - - def get_remaining(): - return name in api_instance.list_indexes() - - if timeout == -1: - return - - if timeout is None: - while get_remaining(): - time.sleep(5) - else: - while get_remaining() and timeout >= 0: - time.sleep(5) - timeout -= 5 - if timeout and timeout < 0: - raise ( - TimeoutError( - "Please call the list_indexes API ({}) to confirm if index is deleted".format( - "https://www.pinecone.io/docs/api/operation/list_indexes/" - ) - ) - ) - - -def list_indexes(): - """Lists all indexes.""" - api_instance = _get_api_instance() - response = api_instance.list_indexes() - return response - - -def describe_index(name: str): - """Describes a Pinecone index. - - :param name: the name of the index to describe. - :return: Returns an `IndexDescription` object - """ - api_instance = _get_api_instance() - response = api_instance.describe_index(name) - db = response["database"] - ready = response["status"]["ready"] - state = response["status"]["state"] - return IndexDescription( - name=db["name"], - metric=db["metric"], - replicas=db["replicas"], - dimension=db["dimension"], - shards=db["shards"], - pods=db.get("pods", db["shards"] * db["replicas"]), - pod_type=db.get("pod_type", "p1"), - status={"ready": ready, "state": state}, - metadata_config=db.get("metadata_config"), - source_collection=db.get("source_collection", ""), - ) - - -def scale_index(name: str, replicas: int): - """Increases number of replicas for the index. - - :param name: the name of the Index - :type name: str - :param replicas: the number of replicas in the index now, lowest value is 0. - :type replicas: int - """ - api_instance = _get_api_instance() - api_instance.configure_index(name, patch_request=PatchRequest(replicas=replicas, pod_type="")) - - -def create_collection(name: str, source: str): - """Create a collection - :param name: Name of the collection - :param source: Name of the source index - """ - api_instance = _get_api_instance() - api_instance.create_collection(create_collection_request=CreateCollectionRequest(name=name, source=source)) - - -def list_collections(): - """List all collections""" - api_instance = _get_api_instance() - response = api_instance.list_collections() - return response - - -def delete_collection(name: str): - """Deletes a collection. - :param: name: The name of the collection - """ - api_instance = _get_api_instance() - api_instance.delete_collection(name) - - -def describe_collection(name: str): - """Describes a collection. - :param: The name of the collection - :return: Description of the collection - """ - api_instance = _get_api_instance() - response = api_instance.describe_collection(name).to_dict() - response_object = CollectionDescription(response.keys(), response.values()) - return response_object - - -def configure_index(name: str, replicas: Optional[int] = None, pod_type: Optional[str] = ""): - """Changes current configuration of the index. - :param: name: the name of the Index - :param: replicas: the desired number of replicas, lowest value is 0. - :param: pod_type: the new pod_type for the index. - """ - api_instance = _get_api_instance() - config_args = {} - if pod_type != "": - config_args.update(pod_type=pod_type) - if replicas: - config_args.update(replicas=replicas) - patch_request = PatchRequest(**config_args) - api_instance.configure_index(name, patch_request=patch_request) diff --git a/pinecone/utils/__init__.py b/pinecone/utils/__init__.py new file mode 100644 index 000000000..8c2c486a2 --- /dev/null +++ b/pinecone/utils/__init__.py @@ -0,0 +1,6 @@ +from .check_kwargs import check_kwargs +from .environment import get_version, get_environment +from .user_agent import get_user_agent +from .deprecation_notice import warn_deprecated +from .fix_tuple_length import fix_tuple_length +from .convert_to_list import convert_to_list \ No newline at end of file diff --git a/pinecone/utils/check_kwargs.py b/pinecone/utils/check_kwargs.py new file mode 100644 index 000000000..f03bc7b71 --- /dev/null +++ b/pinecone/utils/check_kwargs.py @@ -0,0 +1,8 @@ +import inspect +import logging + +def check_kwargs(caller, given): + argspec = inspect.getfullargspec(caller) + diff = set(given).difference(argspec.args) + if diff: + logging.exception(caller.__name__ + " had unexpected keyword argument(s): " + ", ".join(diff), exc_info=False) diff --git a/pinecone/core/utils/constants.py b/pinecone/utils/constants.py similarity index 78% rename from pinecone/core/utils/constants.py rename to pinecone/utils/constants.py index ca9d96310..4b3090a76 100644 --- a/pinecone/core/utils/constants.py +++ b/pinecone/utils/constants.py @@ -1,10 +1,7 @@ import os import enum -from pinecone.core.utils import get_environment, get_version - -PARENT_LOGGER_NAME = "pinecone" -DEFAULT_PARENT_LOGGER_LEVEL = "ERROR" +from .environment import get_environment, get_version MAX_MSG_SIZE = 128 * 1024 * 1024 @@ -30,9 +27,5 @@ class NodeType(str, enum.Enum): CLIENT_VERSION = get_version() CLIENT_ID = f"python-client-{CLIENT_VERSION}" -TCP_KEEPINTVL = 60 # Sec -TCP_KEEPIDLE = 300 # Sec -TCP_KEEPCNT = 4 - REQUIRED_VECTOR_FIELDS = {"id", "values"} OPTIONAL_VECTOR_FIELDS = {"sparse_values", "metadata"} diff --git a/pinecone/utils/convert_to_list.py b/pinecone/utils/convert_to_list.py new file mode 100644 index 000000000..ecaf45902 --- /dev/null +++ b/pinecone/utils/convert_to_list.py @@ -0,0 +1,9 @@ +def convert_to_list(obj): + class_name = obj.__class__.__name__ + + if class_name == 'list': + return obj + elif hasattr(obj, 'tolist'): + return obj.tolist() + else: + return list(obj) \ No newline at end of file diff --git a/pinecone/utils/deprecation_notice.py b/pinecone/utils/deprecation_notice.py new file mode 100644 index 000000000..bc86a08c0 --- /dev/null +++ b/pinecone/utils/deprecation_notice.py @@ -0,0 +1,6 @@ +from typing import Optional +import warnings + +def warn_deprecated(description: str, deprecated_in: str, removal_in: str): + message = f"DEPRECATED since v{deprecated_in} [Will be removed in v{removal_in}]: {description}" + warnings.warn(message, FutureWarning) \ No newline at end of file diff --git a/pinecone/utils/environment.py b/pinecone/utils/environment.py new file mode 100644 index 000000000..d80e868ed --- /dev/null +++ b/pinecone/utils/environment.py @@ -0,0 +1,8 @@ +from pathlib import Path + +def get_version(): + return Path(__file__).parent.parent.joinpath("__version__").read_text().strip() + + +def get_environment(): + return Path(__file__).parent.parent.joinpath("__environment__").read_text().strip() \ No newline at end of file diff --git a/pinecone/core/utils/error_handling.py b/pinecone/utils/error_handling.py similarity index 57% rename from pinecone/core/utils/error_handling.py rename to pinecone/utils/error_handling.py index 6d3f54054..733e6091f 100644 --- a/pinecone/core/utils/error_handling.py +++ b/pinecone/utils/error_handling.py @@ -3,24 +3,18 @@ from urllib3.exceptions import MaxRetryError, ProtocolError -from pinecone import Config, PineconeProtocolError - - def validate_and_convert_errors(func): @wraps(func) def inner_func(*args, **kwargs): - Config.validate() # raises exceptions in case of invalid config try: return func(*args, **kwargs) except MaxRetryError as e: if isinstance(e.reason, ProtocolError): - raise PineconeProtocolError( - f"Failed to connect to {e.url}; did you specify the correct index name?" - ) from e + raise ProtocolError(f"Failed to connect to {e.url}; did you specify the correct index name?") from e else: raise except ProtocolError as e: - raise PineconeProtocolError(f"Failed to connect; did you specify the correct index name?") from e + raise ProtocolError(f"Failed to connect; did you specify the correct index name?") from e # Override signature sig = inspect.signature(func) diff --git a/pinecone/utils/fix_tuple_length.py b/pinecone/utils/fix_tuple_length.py new file mode 100644 index 000000000..fa4fc5eb6 --- /dev/null +++ b/pinecone/utils/fix_tuple_length.py @@ -0,0 +1,3 @@ +def fix_tuple_length(t, n): + """Extend tuple t to length n by adding None items at the end of the tuple. Return the new tuple.""" + return t + ((None,) * (n - len(t))) if len(t) < n else t \ No newline at end of file diff --git a/pinecone/utils/user_agent.py b/pinecone/utils/user_agent.py new file mode 100644 index 000000000..439a7f5d9 --- /dev/null +++ b/pinecone/utils/user_agent.py @@ -0,0 +1,10 @@ +import requests +import urllib3 + +from pinecone.utils import get_version + +def get_user_agent(): + client_id = f"python-client-{get_version()}" + user_agent_details = {"requests": requests.__version__, "urllib3": urllib3.__version__} + user_agent = "{} ({})".format(client_id, ", ".join([f"{k}:{v}" for k, v in user_agent_details.items()])) + return user_agent \ No newline at end of file diff --git a/poetry.lock b/poetry.lock index 0daffa1cc..4d224c732 100644 --- a/poetry.lock +++ b/poetry.lock @@ -236,7 +236,7 @@ wmi = ["wmi (>=1.5.1,<2.0.0)"] name = "googleapis-common-protos" version = "1.60.0" description = "Common protobufs used in Google APIs" -optional = false +optional = true python-versions = ">=3.7" files = [ {file = "googleapis-common-protos-1.60.0.tar.gz", hash = "sha256:e73ebb404098db405ba95d1e1ae0aa91c3e15a71da031a2eeb6b2e23e7bc3708"}, @@ -253,7 +253,7 @@ grpc = ["grpcio (>=1.44.0,<2.0.0.dev0)"] name = "grpc-gateway-protoc-gen-openapiv2" version = "0.1.0" description = "Provides the missing pieces for gRPC Gateway." -optional = false +optional = true python-versions = ">=3.6" files = [ {file = "grpc-gateway-protoc-gen-openapiv2-0.1.0.tar.gz", hash = "sha256:03b8934080ae81f709af041e4f89694db586a95ff35abba05d033d499811d4f6"}, @@ -267,7 +267,7 @@ googleapis-common-protos = "*" name = "grpcio" version = "1.59.0" description = "HTTP/2-based RPC framework" -optional = false +optional = true python-versions = ">=3.7" files = [ {file = "grpcio-1.59.0-cp310-cp310-linux_armv7l.whl", hash = "sha256:225e5fa61c35eeaebb4e7491cd2d768cd8eb6ed00f2664fa83a58f29418b39fd"}, @@ -390,7 +390,7 @@ dev = ["Sphinx (>=2.2.1)", "black (>=19.10b0)", "codecov (>=2.0.15)", "colorama name = "lz4" version = "4.3.2" description = "LZ4 Bindings for Python" -optional = false +optional = true python-versions = ">=3.7" files = [ {file = "lz4-4.3.2-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:1c4c100d99eed7c08d4e8852dd11e7d1ec47a3340f49e3a96f8dfbba17ffb300"}, @@ -504,6 +504,63 @@ files = [ {file = "MarkupSafe-2.1.3.tar.gz", hash = "sha256:af598ed32d6ae86f1b747b82783958b1a4ab8f617b06fe68795c7f026abbdcad"}, ] +[[package]] +name = "mypy" +version = "1.6.1" +description = "Optional static typing for Python" +optional = false +python-versions = ">=3.8" +files = [ + {file = "mypy-1.6.1-cp310-cp310-macosx_10_9_x86_64.whl", hash = "sha256:e5012e5cc2ac628177eaac0e83d622b2dd499e28253d4107a08ecc59ede3fc2c"}, + {file = "mypy-1.6.1-cp310-cp310-macosx_11_0_arm64.whl", hash = "sha256:d8fbb68711905f8912e5af474ca8b78d077447d8f3918997fecbf26943ff3cbb"}, + {file = "mypy-1.6.1-cp310-cp310-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:21a1ad938fee7d2d96ca666c77b7c494c3c5bd88dff792220e1afbebb2925b5e"}, + {file = "mypy-1.6.1-cp310-cp310-musllinux_1_1_x86_64.whl", hash = "sha256:b96ae2c1279d1065413965c607712006205a9ac541895004a1e0d4f281f2ff9f"}, + {file = "mypy-1.6.1-cp310-cp310-win_amd64.whl", hash = "sha256:40b1844d2e8b232ed92e50a4bd11c48d2daa351f9deee6c194b83bf03e418b0c"}, + {file = "mypy-1.6.1-cp311-cp311-macosx_10_9_x86_64.whl", hash = "sha256:81af8adaa5e3099469e7623436881eff6b3b06db5ef75e6f5b6d4871263547e5"}, + {file = "mypy-1.6.1-cp311-cp311-macosx_11_0_arm64.whl", hash = "sha256:8c223fa57cb154c7eab5156856c231c3f5eace1e0bed9b32a24696b7ba3c3245"}, + {file = "mypy-1.6.1-cp311-cp311-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:a8032e00ce71c3ceb93eeba63963b864bf635a18f6c0c12da6c13c450eedb183"}, + {file = "mypy-1.6.1-cp311-cp311-musllinux_1_1_x86_64.whl", hash = "sha256:4c46b51de523817a0045b150ed11b56f9fff55f12b9edd0f3ed35b15a2809de0"}, + {file = "mypy-1.6.1-cp311-cp311-win_amd64.whl", hash = "sha256:19f905bcfd9e167159b3d63ecd8cb5e696151c3e59a1742e79bc3bcb540c42c7"}, + {file = "mypy-1.6.1-cp312-cp312-macosx_10_9_x86_64.whl", hash = "sha256:82e469518d3e9a321912955cc702d418773a2fd1e91c651280a1bda10622f02f"}, + {file = "mypy-1.6.1-cp312-cp312-macosx_11_0_arm64.whl", hash = "sha256:d4473c22cc296425bbbce7e9429588e76e05bc7342da359d6520b6427bf76660"}, + {file = "mypy-1.6.1-cp312-cp312-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:59a0d7d24dfb26729e0a068639a6ce3500e31d6655df8557156c51c1cb874ce7"}, + {file = "mypy-1.6.1-cp312-cp312-musllinux_1_1_x86_64.whl", hash = "sha256:cfd13d47b29ed3bbaafaff7d8b21e90d827631afda134836962011acb5904b71"}, + {file = "mypy-1.6.1-cp312-cp312-win_amd64.whl", hash = "sha256:eb4f18589d196a4cbe5290b435d135dee96567e07c2b2d43b5c4621b6501531a"}, + {file = "mypy-1.6.1-cp38-cp38-macosx_10_9_x86_64.whl", hash = "sha256:41697773aa0bf53ff917aa077e2cde7aa50254f28750f9b88884acea38a16169"}, + {file = "mypy-1.6.1-cp38-cp38-macosx_11_0_arm64.whl", hash = "sha256:7274b0c57737bd3476d2229c6389b2ec9eefeb090bbaf77777e9d6b1b5a9d143"}, + {file = "mypy-1.6.1-cp38-cp38-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:bbaf4662e498c8c2e352da5f5bca5ab29d378895fa2d980630656178bd607c46"}, + {file = "mypy-1.6.1-cp38-cp38-musllinux_1_1_x86_64.whl", hash = "sha256:bb8ccb4724f7d8601938571bf3f24da0da791fe2db7be3d9e79849cb64e0ae85"}, + {file = "mypy-1.6.1-cp38-cp38-win_amd64.whl", hash = "sha256:68351911e85145f582b5aa6cd9ad666c8958bcae897a1bfda8f4940472463c45"}, + {file = "mypy-1.6.1-cp39-cp39-macosx_10_9_x86_64.whl", hash = "sha256:49ae115da099dcc0922a7a895c1eec82c1518109ea5c162ed50e3b3594c71208"}, + {file = "mypy-1.6.1-cp39-cp39-macosx_11_0_arm64.whl", hash = "sha256:8b27958f8c76bed8edaa63da0739d76e4e9ad4ed325c814f9b3851425582a3cd"}, + {file = "mypy-1.6.1-cp39-cp39-manylinux_2_17_x86_64.manylinux2014_x86_64.whl", hash = "sha256:925cd6a3b7b55dfba252b7c4561892311c5358c6b5a601847015a1ad4eb7d332"}, + {file = "mypy-1.6.1-cp39-cp39-musllinux_1_1_x86_64.whl", hash = "sha256:8f57e6b6927a49550da3d122f0cb983d400f843a8a82e65b3b380d3d7259468f"}, + {file = "mypy-1.6.1-cp39-cp39-win_amd64.whl", hash = "sha256:a43ef1c8ddfdb9575691720b6352761f3f53d85f1b57d7745701041053deff30"}, + {file = "mypy-1.6.1-py3-none-any.whl", hash = "sha256:4cbe68ef919c28ea561165206a2dcb68591c50f3bcf777932323bc208d949cf1"}, + {file = "mypy-1.6.1.tar.gz", hash = "sha256:4d01c00d09a0be62a4ca3f933e315455bde83f37f892ba4b08ce92f3cf44bcc1"}, +] + +[package.dependencies] +mypy-extensions = ">=1.0.0" +tomli = {version = ">=1.1.0", markers = "python_version < \"3.11\""} +typing-extensions = ">=4.1.0" + +[package.extras] +dmypy = ["psutil (>=4.0)"] +install-types = ["pip"] +reports = ["lxml"] + +[[package]] +name = "mypy-extensions" +version = "1.0.0" +description = "Type system extensions for programs checked with the mypy type checker." +optional = false +python-versions = ">=3.5" +files = [ + {file = "mypy_extensions-1.0.0-py3-none-any.whl", hash = "sha256:4392f6c0eb8a5668a69e23d168ffa70f0be9ccfd32b5cc2d26a34ae5b844552d"}, + {file = "mypy_extensions-1.0.0.tar.gz", hash = "sha256:75dbf8955dc00442a438fc4d0666508a9a97b6bd41aa2f0ffe9d2f2725af0782"}, +] + [[package]] name = "numpy" version = "1.24.4" @@ -657,7 +714,7 @@ dev = ["pre-commit", "tox"] name = "protobuf" version = "3.20.3" description = "Protocol Buffers" -optional = false +optional = true python-versions = ">=3.7" files = [ {file = "protobuf-3.20.3-cp310-cp310-manylinux2014_aarch64.whl", hash = "sha256:f4bd856d702e5b0d96a00ec6b307b0f51c1982c2bf9c0052cf9019e9a544ba99"}, @@ -906,23 +963,21 @@ use-chardet-on-py3 = ["chardet (>=3.0.2,<6)"] [[package]] name = "responses" -version = "0.23.3" +version = "0.10.15" description = "A utility library for mocking out the `requests` Python library." optional = false -python-versions = ">=3.7" +python-versions = ">=2.7, !=3.0.*, !=3.1.*, !=3.2.*, !=3.3.*" files = [ - {file = "responses-0.23.3-py3-none-any.whl", hash = "sha256:e6fbcf5d82172fecc0aa1860fd91e58cbfd96cee5e96da5b63fa6eb3caa10dd3"}, - {file = "responses-0.23.3.tar.gz", hash = "sha256:205029e1cb334c21cb4ec64fc7599be48b859a0fd381a42443cdd600bfe8b16a"}, + {file = "responses-0.10.15-py2.py3-none-any.whl", hash = "sha256:af94d28cdfb48ded0ad82a5216616631543650f440334a693479b8991a6594a2"}, + {file = "responses-0.10.15.tar.gz", hash = "sha256:7bb697a5fedeb41d81e8b87f152d453d5cab42dcd1691b6a7d6097e94d33f373"}, ] [package.dependencies] -pyyaml = "*" -requests = ">=2.30.0,<3.0" -types-PyYAML = "*" -urllib3 = ">=1.25.10,<3.0" +requests = ">=2.0" +six = "*" [package.extras] -tests = ["coverage (>=6.0.0)", "flake8", "mypy", "pytest (>=7.0.0)", "pytest-asyncio", "pytest-cov", "pytest-httpserver", "tomli", "tomli-w", "types-requests"] +tests = ["coverage (>=3.7.1,<5.0.0)", "flake8", "pytest", "pytest (>=4.6,<5.0)", "pytest-cov", "pytest-localserver"] [[package]] name = "six" @@ -946,6 +1001,17 @@ files = [ {file = "toml-0.10.2.tar.gz", hash = "sha256:b3bda1d108d5dd99f4a20d24d9c348e91c4db7ab1b749200bded2f839ccbe68f"}, ] +[[package]] +name = "tomli" +version = "2.0.1" +description = "A lil' TOML parser" +optional = false +python-versions = ">=3.7" +files = [ + {file = "tomli-2.0.1-py3-none-any.whl", hash = "sha256:939de3e7a6161af0c887ef91b7d41a53e7c5a1ca976325f429cb46ea9bc30ecc"}, + {file = "tomli-2.0.1.tar.gz", hash = "sha256:de526c12914f0c550d15924c62d72abc48d6fe7364aa87328337a31007fe8a4f"}, +] + [[package]] name = "tqdm" version = "4.66.1" @@ -967,14 +1033,28 @@ slack = ["slack-sdk"] telegram = ["requests"] [[package]] -name = "types-pyyaml" -version = "6.0.12.12" -description = "Typing stubs for PyYAML" +name = "types-requests" +version = "2.31.0.10" +description = "Typing stubs for requests" +optional = false +python-versions = ">=3.7" +files = [ + {file = "types-requests-2.31.0.10.tar.gz", hash = "sha256:dc5852a76f1eaf60eafa81a2e50aefa3d1f015c34cf0cba130930866b1b22a92"}, + {file = "types_requests-2.31.0.10-py3-none-any.whl", hash = "sha256:b32b9a86beffa876c0c3ac99a4cd3b8b51e973fb8e3bd4e0a6bb32c7efad80fc"}, +] + +[package.dependencies] +urllib3 = ">=2" + +[[package]] +name = "types-urllib3" +version = "1.26.25.14" +description = "Typing stubs for urllib3" optional = false python-versions = "*" files = [ - {file = "types-PyYAML-6.0.12.12.tar.gz", hash = "sha256:334373d392fde0fdf95af5c3f1661885fa10c52167b14593eb856289e1855062"}, - {file = "types_PyYAML-6.0.12.12-py3-none-any.whl", hash = "sha256:c05bc6c158facb0676674b7f11fe3960db4f389718e19e62bd2b84d6205cfd24"}, + {file = "types-urllib3-1.26.25.14.tar.gz", hash = "sha256:229b7f577c951b8c1b92c1bc2b2fdb0b49847bd2af6d1cc2a2e3dd340f3bda8f"}, + {file = "types_urllib3-1.26.25.14-py3-none-any.whl", hash = "sha256:9683bbb7fb72e32bfe9d2be6e04875fbe1b3eeec3cbb4ea231435aa7fd6b4f0e"}, ] [[package]] @@ -1001,13 +1081,13 @@ files = [ [[package]] name = "urllib3" -version = "2.0.6" +version = "2.0.7" description = "HTTP library with thread-safe connection pooling, file post, and more." optional = false python-versions = ">=3.7" files = [ - {file = "urllib3-2.0.6-py3-none-any.whl", hash = "sha256:7a7c7003b000adf9e7ca2a377c9688bbc54ed41b985789ed576570342a375cd2"}, - {file = "urllib3-2.0.6.tar.gz", hash = "sha256:b19e1a85d206b56d7df1d5e683df4a7725252a964e3993648dd0fb5a1c157564"}, + {file = "urllib3-2.0.7-py3-none-any.whl", hash = "sha256:fdb6d215c776278489906c2f8916e6e7d4f5a9b602ccbcfdf7f016fc8da0596e"}, + {file = "urllib3-2.0.7.tar.gz", hash = "sha256:c97dfde1f7bd43a71c8d2a58e369e9b2bf692d1334ea9f9cae55add7d0dd0f84"}, ] [package.extras] @@ -1064,4 +1144,4 @@ grpc = ["googleapis-common-protos", "grpc-gateway-protoc-gen-openapiv2", "grpcio [metadata] lock-version = "2.0" python-versions = ">=3.8,<4.0" -content-hash = "81718e41eaf5215419a92230189a60fa2e061f93e550ddc692a65d19c5e75d7f" +content-hash = "17a4369bb5102e9c8c534e0cac215a2382a9fe9e8633ac7b190a9e67863a31df" diff --git a/pyproject.toml b/pyproject.toml index e9b17b5d3..a6a76d672 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -61,16 +61,16 @@ loguru = "0.5.3" typing-extensions = ">=3.7.4" dnspython = ">=2.0.0" python-dateutil = ">=2.5.3" -urllib3 = ">=1.21.1" +urllib3 = "2.0.7" tqdm = ">=4.64.1" -numpy = ">=1.22.0" -grpcio = ">=1.44.0" -grpc-gateway-protoc-gen-openapiv2 = "0.1.0" -googleapis-common-protos = ">=1.53.0" -lz4 = ">=3.1.3" -protobuf = "~=3.20.0" +grpcio = { version = ">=1.44.0", optional = true } +grpc-gateway-protoc-gen-openapiv2 = { version = "0.1.0", optional = true } +googleapis-common-protos = { version = ">=1.53.0", optional = true } +lz4 = { version = ">=3.1.3", optional = true } +protobuf = { version = "~=3.20.0", optional = true } [tool.poetry.group.dev.dependencies] +numpy = ">=1.22" pdoc = "^14.1.0" pytest = "6.2.4" pytest-asyncio = "0.15.1" @@ -88,6 +88,9 @@ pandas = ">=1.3.5" # Note that Poetry expects the dependencies to be defined in either tool.poetry.dependencies # or tool.poetry.group.dev.dependencies, but they're only referenced by name in the grpc entry under # tool.poetry.extras +mypy = "^1.6.1" +types-requests = "^2.31.0.10" +types-urllib3 = "^1.26.25.14" [tool.poetry.extras] grpc = ["grpcio", "grpc-gateway-protoc-gen-openapiv2", "googleapis-common-protos", "lz4", "protobuf"] diff --git a/tests/integ/test_index.py b/tests/integ/test_index.py index 58fc3727c..cb52b6c56 100644 --- a/tests/integ/test_index.py +++ b/tests/integ/test_index.py @@ -8,128 +8,131 @@ from pinecone import ApiTypeError, ApiException responses_req = Responses() -responses = Responses('requests.packages.urllib3') +responses = Responses("requests.packages.urllib3") +@pytest.mark.skip() @req_responses.activate @responses.activate def test_invalid_upsert_request_vector_value_type(): - environment = 'example-environment' - project_name = 'example-project' + environment = "example-environment" + project_name = "example-project" req_responses.add( - 'GET', f'https://controller.{environment}.pinecone.io/actions/whoami', - status=200, content_type='application/json', - body=json.dumps(dict(project_name=project_name, user_label='example-label', user_name='test')) + "GET", + f"https://controller.{environment}.pinecone.io/actions/whoami", + status=200, + content_type="application/json", + body=json.dumps(dict(project_name=project_name, user_label="example-label", user_name="test")), ) responses.add( - 'POST', '/vectors/upsert', - status=400, content_type='text/plain', + "POST", + "/vectors/upsert", + status=400, + content_type="text/plain", adding_headers={ - 'content-length': '62', - 'date': 'Thu, 28 Oct 2021 09:14:51 GMT', - 'server': 'envoy', - 'connection': 'close' + "content-length": "62", + "date": "Thu, 28 Oct 2021 09:14:51 GMT", + "server": "envoy", + "connection": "close", }, - body='vectors[0].values[1]: invalid value "type" for type TYPE_FLOAT' + body='vectors[0].values[1]: invalid value "type" for type TYPE_FLOAT', ) - pinecone.init('example-api-key', environment='example-environment') + pinecone.init("example-api-key", environment="example-environment") with pytest.raises(ApiException) as exc_info: - index = pinecone.Index('example-index') - resp = index.upsert(vectors=[('vec1', [0.1]*8), ('vec2', [0.2]*8)]) + index = pinecone.Index("example-index") + resp = index.upsert(vectors=[("vec1", [0.1] * 8), ("vec2", [0.2] * 8)]) assert len(responses.calls) == 1 - assert responses.calls[0].request.scheme == 'https' - assert responses.calls[0].request.host == 'example-index-example-project.svc.example-environment.pinecone.io' - assert responses.calls[0].request.url == '/vectors/upsert' - + assert responses.calls[0].request.scheme == "https" + assert responses.calls[0].request.host == "example-index-example-project.svc.example-environment.pinecone.io" + assert responses.calls[0].request.url == "/vectors/upsert" +@pytest.mark.skip() @req_responses.activate @responses.activate def test_multiple_indexes(): - environment = 'example-environment' - project_name = 'example-project' - index1_name = 'index-1' - index2_name = 'index-2' + environment = "example-environment" + project_name = "example-project" + index1_name = "index-1" + index2_name = "index-2" req_responses.add( - 'GET', f'https://controller.{environment}.pinecone.io/actions/whoami', - status=200, content_type='application/json', - body=json.dumps(dict(project_name=project_name, user_label='example-label', user_name='test')) + "GET", + f"https://controller.{environment}.pinecone.io/actions/whoami", + status=200, + content_type="application/json", + body=json.dumps(dict(project_name=project_name, user_label="example-label", user_name="test")), ) responses.add( - 'GET', f'/describe_index_stats', - status=200, content_type='application/json', - adding_headers={ - 'date': 'Thu, 28 Oct 2021 09:14:51 GMT', - 'server': 'envoy' - }, - body='{"namespaces":{"":{"vectorCount":50000},"example-namespace-2":{"vectorCount":30000}},"dimension":1024}' + "GET", + f"/describe_index_stats", + status=200, + content_type="application/json", + adding_headers={"date": "Thu, 28 Oct 2021 09:14:51 GMT", "server": "envoy"}, + body='{"namespaces":{"":{"vectorCount":50000},"example-namespace-2":{"vectorCount":30000}},"dimension":1024}', ) - pinecone.init('example-api-key', environment='example-environment') + pinecone.init("example-api-key", environment="example-environment") index1 = pinecone.Index(index1_name) resp1 = index1.describe_index_stats() assert resp1.dimension == 1024 - assert responses.calls[0].request.host == f'{index1_name}-{project_name}.svc.{environment}.pinecone.io' + assert responses.calls[0].request.host == f"{index1_name}-{project_name}.svc.{environment}.pinecone.io" index2 = pinecone.Index(index2_name) resp2 = index2.describe_index_stats() assert resp2.dimension == 1024 - assert responses.calls[1].request.host == f'{index2_name}-{project_name}.svc.{environment}.pinecone.io' - + assert responses.calls[1].request.host == f"{index2_name}-{project_name}.svc.{environment}.pinecone.io" +@pytest.mark.skip() @req_responses.activate @responses.activate def test_invalid_delete_response_unrecognized_field(): # unrecognized response fields are okay, shouldn't raise an exception - environment = 'example-environment' - project_name = 'example-project' + environment = "example-environment" + project_name = "example-project" req_responses.add( - 'GET', f'https://controller.{environment}.pinecone.io/actions/whoami', - status=200, content_type='application/json', - body=json.dumps(dict(project_name=project_name, user_label='example-label', user_name='test')) + "GET", + f"https://controller.{environment}.pinecone.io/actions/whoami", + status=200, + content_type="application/json", + body=json.dumps(dict(project_name=project_name, user_label="example-label", user_name="test")), ) responses.add( - 'DELETE', '/vectors/delete', - body='{"unexpected_key": "xyzzy"}', - status=200, content_type='application/json' + "DELETE", "/vectors/delete", body='{"unexpected_key": "xyzzy"}', status=200, content_type="application/json" ) - pinecone.init('example-api-key', environment=environment) - index = pinecone.Index('example-index') - resp = index.delete(ids=['vec1', 'vec2']) + pinecone.init("example-api-key", environment=environment) + index = pinecone.Index("example-index") + resp = index.delete(ids=["vec1", "vec2"]) assert len(req_responses.calls) == 1 - assert responses.calls[0].request.scheme == 'https' - assert responses.calls[0].request.host == f'example-index-{project_name}.svc.{environment}.pinecone.io' - assert responses.calls[0].request.url == '/vectors/delete?ids=vec1&ids=vec2' - + assert responses.calls[0].request.scheme == "https" + assert responses.calls[0].request.host == f"example-index-{project_name}.svc.{environment}.pinecone.io" + assert responses.calls[0].request.url == "/vectors/delete?ids=vec1&ids=vec2" +@pytest.mark.skip() @responses.activate def test_delete_response_missing_field(): # missing (optional) response fields are okay, shouldn't raise an exception - pinecone.init('example-api-key', environment='example-environment') - responses.add('DELETE', '/vectors/delete', - body='{}', - status=200, content_type='application/json') - index = pinecone.Index('example-index') + pinecone.init("example-api-key", environment="example-environment") + responses.add("DELETE", "/vectors/delete", body="{}", status=200, content_type="application/json") + index = pinecone.Index("example-index") # this should not raise - index.delete(ids=['vec1', 'vec2']) - - + index.delete(ids=["vec1", "vec2"]) +@pytest.mark.skip() @responses.activate def _test_invalid_delete_response_wrong_type(): # FIXME: re-enable this test when accepted_count added back to response # wrong-typed response fields should raise an exception - pinecone.init('example-api-key', environment='example-environment') + pinecone.init("example-api-key", environment="example-environment") - responses.add('DELETE', '/vectors/delete', - body='{"deleted_count": "foobar"}', - status=200, content_type='application/json') + responses.add( + "DELETE", "/vectors/delete", body='{"deleted_count": "foobar"}', status=200, content_type="application/json" + ) - index = pinecone.Index('example-index') + index = pinecone.Index("example-index") with pytest.raises(ApiTypeError) as exc_info: - resp = index.delete(ids=['vec1', 'vec2']) + resp = index.delete(ids=["vec1", "vec2"]) assert resp.deleted_count == 2 diff --git a/tests/unit/data/test_vector_factory.py b/tests/unit/data/test_vector_factory.py new file mode 100644 index 000000000..bf713a660 --- /dev/null +++ b/tests/unit/data/test_vector_factory.py @@ -0,0 +1,139 @@ +import numpy as np +import pandas as pd +import pytest + +from pinecone.data.vector_factory import VectorFactory +from pinecone import Vector, SparseValues + +class TestVectorFactory: + def test_build_when_returns_vector_unmodified(self): + vec = Vector(id='1', values=[0.1, 0.2, 0.3]) + assert VectorFactory.build(vec) == vec + assert VectorFactory.build(vec).__class__ == Vector + + def test_build_when_tuple_with_two_values(self): + tup = ('1', [0.1, 0.2, 0.3]) + actual = VectorFactory.build(tup) + expected = Vector(id='1', values=[0.1, 0.2, 0.3], metadata={}) + assert actual == expected + + def test_build_when_tuple_with_three_values(self): + tup = ('1', [0.1, 0.2, 0.3], {'genre': 'comedy'}) + actual = VectorFactory.build(tup) + expected = Vector(id='1', values=[0.1, 0.2, 0.3], metadata={'genre': 'comedy'}) + assert actual == expected + + def test_build_when_tuple_with_numpy_array(self): + tup = ('1', np.array([0.1, 0.2, 0.3]), {'genre': 'comedy'}) + actual = VectorFactory.build(tup) + expected = Vector(id='1', values=[0.1, 0.2, 0.3], metadata={'genre': 'comedy'}) + assert actual == expected + + def test_build_when_tuple_with_pandas_array(self): + tup = ('1', pd.array([0.1, 0.2, 0.3])) + actual = VectorFactory.build(tup) + expected = Vector(id='1', values=[0.1, 0.2, 0.3], metadata={}) + assert actual == expected + + def test_build_when_tuple_errors_when_additional_fields(self): + with pytest.raises(ValueError, match="Found a tuple of length 4 which is not supported"): + tup = ('1', [0.1, 0.2, 0.3], {'a': 'b'}, 'extra') + VectorFactory.build(tup) + + def test_build_when_tuple_too_short(self): + with pytest.raises(ValueError, match="Found a tuple of length 1 which is not supported"): + tup = ('1',) + VectorFactory.build(tup) + + def test_build_when_dict(self): + d = { 'id': '1', 'values': [0.1, 0.2, 0.3], 'metadata': {'genre': 'comedy'}} + actual = VectorFactory.build(d) + expected = Vector(id='1', values=[0.1, 0.2, 0.3], metadata={'genre': 'comedy'}) + assert actual == expected + + def test_build_when_dict_with_numpy_values(self): + d = { 'id': '1', 'values': np.array([0.1, 0.2, 0.3]), 'metadata': {'genre': 'comedy'}} + actual = VectorFactory.build(d) + expected = Vector(id='1', values=[0.1, 0.2, 0.3], metadata={'genre': 'comedy'}) + assert actual == expected + + def test_build_when_dict_with_pandas_values(self): + d = { 'id': '1', 'values': pd.array([0.1, 0.2, 0.3]), 'metadata': {'genre': 'comedy'}} + actual = VectorFactory.build(d) + expected = Vector(id='1', values=[0.1, 0.2, 0.3], metadata={'genre': 'comedy'}) + assert actual == expected + + def test_build_when_dict_missing_required_fields(self): + with pytest.raises(ValueError, match="Vector dictionary is missing required fields"): + d = {'values': [0.1, 0.2, 0.3]} + VectorFactory.build(d) + + def test_build_when_dict_excess_keys(self): + with pytest.raises(ValueError, match="Found excess keys in the vector dictionary"): + d = {'id': '1', 'values': [0.1, 0.2, 0.3], 'metadata': {'genre': 'comedy'}, 'extra': 'field'} + VectorFactory.build(d) + + def test_build_when_dict_sparse_values(self): + d = {'id': '1', 'values': [0.1, 0.2, 0.3], 'metadata': {'genre': 'comedy'}, 'sparse_values': {'indices': [0, 2], 'values': [0.1, 0.3]}} + actual = VectorFactory.build(d) + expected = Vector(id='1', values=[0.1, 0.2, 0.3], metadata={'genre': 'comedy'}, sparse_values=SparseValues(indices=[0, 2], values=[0.1, 0.3])) + assert actual == expected + + def test_build_when_dict_sparse_values_when_SparseValues(self): + d = {'id': '1', 'values': [0.1, 0.2, 0.3], 'metadata': {'genre': 'comedy'}, 'sparse_values': SparseValues(indices=[0, 2], values=[0.1, 0.3])} + actual = VectorFactory.build(d) + expected = Vector(id='1', values=[0.1, 0.2, 0.3], metadata={'genre': 'comedy'}, sparse_values=SparseValues(indices=[0, 2], values=[0.1, 0.3])) + assert actual == expected + + def test_build_when_dict_sparse_values_errors_when_not_dict(self): + with pytest.raises(ValueError, match="Column `sparse_values` is expected to be a dictionary"): + d = {'id': '1', 'values': [0.1, 0.2, 0.3], 'metadata': {'genre': 'comedy'}, 'sparse_values': 'not a dict'} + VectorFactory.build(d) + + def test_build_when_dict_sparse_values_errors_when_missing_indices(self): + with pytest.raises(ValueError, match="Missing required keys in data in column `sparse_values`"): + d = {'id': '1', 'values': [0.1, 0.2, 0.3], 'metadata': {'genre': 'comedy'}, 'sparse_values': {'values': [0.1, 0.3]}} + VectorFactory.build(d) + + def test_build_when_dict_sparse_values_errors_when_missing_values(self): + with pytest.raises(ValueError, match="Missing required keys in data in column `sparse_values`"): + d = {'id': '1', 'values': [0.1, 0.2, 0.3], 'metadata': {'genre': 'comedy'}, 'sparse_values': {'indices': [0, 2]}} + VectorFactory.build(d) + + def test_build_when_dict_sparse_values_errors_when_indices_not_list(self): + with pytest.raises(ValueError, match="Found unexpected data in column `sparse_values`"): + d = {'id': '1', 'values': [0.1, 0.2, 0.3], 'metadata': {'genre': 'comedy'}, 'sparse_values': {'indices': 'not a list', 'values': [0.1, 0.3]}} + VectorFactory.build(d) + + def test_build_when_dict_sparse_values_errors_when_values_not_list(self): + with pytest.raises(ValueError, match="Found unexpected data in column `sparse_values`"): + d = {'id': '1', 'values': [0.1, 0.2, 0.3], 'metadata': {'genre': 'comedy'}, 'sparse_values': {'indices': [0, 2], 'values': 'not a list'}} + VectorFactory.build(d) + + def test_build_when_dict_sparse_values_when_values_is_ndarray(self): + d = {'id': '1', 'values': [0.1, 0.2, 0.3], 'metadata': {'genre': 'comedy'}, 'sparse_values': {'indices': [0, 2], 'values': np.array([0.1, 0.3])}} + actual = VectorFactory.build(d) + expected = Vector(id='1', values=[0.1, 0.2, 0.3], metadata={'genre': 'comedy'}, sparse_values=SparseValues(indices=[0, 2], values=[0.1, 0.3])) + assert actual == expected + + def test_build_when_dict_sparse_values_when_indices_is_pandas_IntegerArray(self): + d = {'id': '1', 'values': [0.1, 0.2, 0.3], 'metadata': {'genre': 'comedy'}, 'sparse_values': {'indices': pd.array([0, 2]), 'values': [0.1, 0.3]}} + actual = VectorFactory.build(d) + expected = Vector(id='1', values=[0.1, 0.2, 0.3], metadata={'genre': 'comedy'}, sparse_values=SparseValues(indices=[0, 2], values=[0.1, 0.3])) + assert actual == expected + + def test_build_when_dict_sparse_values_when_values_is_pandas_FloatingArray(self): + d = {'id': '1', 'values': [0.1, 0.2, 0.3], 'metadata': {'genre': 'comedy'}, 'sparse_values': {'indices': [0, 2], 'values': pd.array([0.1, 0.3])}} + actual = VectorFactory.build(d) + expected = Vector(id='1', values=[0.1, 0.2, 0.3], metadata={'genre': 'comedy'}, sparse_values=SparseValues(indices=[0, 2], values=[0.1, 0.3])) + assert actual == expected + + def test_build_when_dict_sparse_values_when_indices_is_ndarray(self): + d = {'id': '1', 'values': [0.1, 0.2, 0.3], 'metadata': {'genre': 'comedy'}, 'sparse_values': {'indices': np.array([0, 2]), 'values': [0.1, 0.3]}} + actual = VectorFactory.build(d) + expected = Vector(id='1', values=[0.1, 0.2, 0.3], metadata={'genre': 'comedy'}, sparse_values=SparseValues(indices=[0, 2], values=[0.1, 0.3])) + assert actual == expected + + def test_build_when_errors_when_other_type(self): + with pytest.raises(ValueError, match="Invalid vector value passed: cannot interpret type"): + VectorFactory.build(1) diff --git a/tests/unit/test_config.py b/tests/unit/test_config.py index 5251b67c2..aebd002c6 100644 --- a/tests/unit/test_config.py +++ b/tests/unit/test_config.py @@ -1,215 +1,76 @@ import pinecone -from pinecone.config import Config +from pinecone.exceptions import ApiKeyError, PineconeConfigurationError +from pinecone.config import PineconeConfig from pinecone.core.client.configuration import Configuration as OpenApiConfiguration import pytest -import tempfile import os -@pytest.fixture(autouse=True) -def run_before_and_after_tests(tmpdir): - """Fixture to execute asserts before and after a test is run""" - - # Defend against unexpected env vars. Since we clear these variables below - # after each test execution, these should only be raised if there is - # test pollution in the environment coming from some other test file/setup. - known_env_vars = ['PINECONE_API_KEY', 'PINECONE_ENVIRONMENT', 'PINECONE_PROJECT_NAME', 'PINECONE_CONTROLLER_HOST'] - for var in known_env_vars: - if os.getenv(var): - raise ValueError(f'Unexpected env var {var} found in environment. Check for test pollution.') - - # Unfortunately since config is a singleton, we need to reset it manually between tests - pinecone.init() - - yield # this is where the testing happens - - # Teardown : Unset any env vars created during test execution - for var in known_env_vars: - if os.getenv(var): - del os.environ[var] - -def test_default_config(): - """ - Test that default config is loaded when no config is specified. This not really a valid config that can be used, - but adding this test just to document the legacy behavior. - """ - pinecone.init() - assert Config.API_KEY == '' - assert Config.ENVIRONMENT == 'us-west1-gcp' - assert Config.PROJECT_NAME == 'UNKNOWN' - assert Config.CONTROLLER_HOST == 'https://controller.us-west1-gcp.pinecone.io' - assert Config.LOG_LEVEL == 'ERROR' - -def test_init_with_environment_vars(): - os.environ['PINECONE_ENVIRONMENT'] = 'test-env' - os.environ['PINECONE_API_KEY'] = 'test-api-key' - os.environ['PINECONE_PROJECT_NAME'] = 'test-project-name' - os.environ['PINECONE_CONTROLLER_HOST'] = 'test-controller-host' - - pinecone.init() - - assert Config.API_KEY == 'test-api-key' - assert Config.ENVIRONMENT == 'test-env' - assert Config.PROJECT_NAME == 'test-project-name' - assert Config.CONTROLLER_HOST == 'test-controller-host' - -def test_init_with_positional_args(): - api_key = 'my-api-key' - environment = 'test-env' - host = 'my-controller-host' - project_name = 'my-project-name' - log_level = None # deprecated property but still in positional list - openapi_config = OpenApiConfiguration(api_key='openapi-api-key') - - pinecone.init(api_key, host, environment, project_name, log_level, openapi_config) - - assert Config.API_KEY == api_key - assert Config.ENVIRONMENT == environment - assert Config.PROJECT_NAME == project_name - assert Config.CONTROLLER_HOST == host - assert Config.OPENAPI_CONFIG == openapi_config - -def test_init_with_kwargs(): - env = 'test-env' - api_key = 'my-api-key' - project_name = 'my-project-name' - controller_host = 'my-controller-host' - openapi_config = OpenApiConfiguration(api_key='openapi-api-key') - - pinecone.init(api_key=api_key, environment=env, project_name=project_name, host=controller_host, openapi_config=openapi_config) - - assert Config.API_KEY == api_key - assert Config.ENVIRONMENT == env - assert Config.PROJECT_NAME == project_name - assert Config.CONTROLLER_HOST == controller_host - assert Config.OPENAPI_CONFIG == openapi_config - -def test_init_with_mispelled_kwargs(caplog): - pinecone.init(invalid_kwarg="value") - assert 'init had unexpected keyword argument(s): invalid_kwarg' in caplog.text - -def test_init_with_file_based_configuration(): - """Test that config can be loaded from a file""" - env = 'ini-test-env' - api_key = 'ini-api-key' - project_name = 'ini-project-name' - controller_host = 'ini-controller-host' - - with tempfile.NamedTemporaryFile(mode='w') as f: - f.write(f""" - [default] - environment: {env} - api_key: {api_key} - project_name: {project_name} - controller_host: {controller_host} - """) - f.flush() - - pinecone.init(config=f.name) - - assert Config.API_KEY == api_key - assert Config.ENVIRONMENT == env - assert Config.PROJECT_NAME == project_name - assert Config.CONTROLLER_HOST == controller_host - -def test_resolution_order_kwargs_over_env_vars(): - """ - Test that when config is present from multiple sources, - the order of precedence is kwargs > env vars - """ - os.environ['PINECONE_ENVIRONMENT'] = 'env-var-env' - os.environ['PINECONE_API_KEY'] = 'env-var-api-key' - os.environ['PINECONE_PROJECT_NAME'] = 'env-var-project-name' - os.environ['PINECONE_CONTROLLER_HOST'] = 'env-var-controller-host' - - env = 'kwargs-env' - api_key = 'kwargs-api-key' - project_name = 'kwargs-project-name' - controller_host = 'kwargs-controller-host' - - pinecone.init(environment=env, api_key=api_key, project_name=project_name, host=controller_host) - - assert Config.API_KEY == api_key - assert Config.ENVIRONMENT == env - assert Config.PROJECT_NAME == project_name - assert Config.CONTROLLER_HOST == controller_host - -def test_resolution_order_kwargs_over_config_file(): - """ - Test that when config is present from multiple sources, the order of - precedence is kwargs > config file - """ - env = 'ini-test-env' - api_key = 'ini-api-key' - project_name = 'ini-project-name' - controller_host = 'ini-controller-host' - - kwargs_api_key = 'kwargs-api-key' - kwargs_project_name = 'kwargs-project-name' - - with tempfile.NamedTemporaryFile(mode='w') as f: - f.write(f""" - [default] - environment: {env} - api_key: {api_key} - project_name: {project_name} - controller_host: {controller_host} - """) - f.flush() - - pinecone.init(api_key=kwargs_api_key, project_name=kwargs_project_name, config=f.name) - - # Properties passed as kwargs take precedence over config file - assert Config.API_KEY == kwargs_api_key - assert Config.PROJECT_NAME == kwargs_project_name - - # Properties not passed as kwargs loaded from config file - assert Config.ENVIRONMENT == env - assert Config.CONTROLLER_HOST == controller_host - -def test_resolution_order_env_vars_over_config_file(): - """ - Test that when config is present from multiple sources, the order of precedence is - env vars > config file - """ - - os.environ['PINECONE_ENVIRONMENT'] = 'env-var-env' - os.environ['PINECONE_API_KEY'] = 'env-var-api-key' - os.environ['PINECONE_PROJECT_NAME'] = 'env-var-project-name' - os.environ['PINECONE_CONTROLLER_HOST'] = 'env-var-controller-host' - - with tempfile.NamedTemporaryFile(mode='w') as f: - f.write(f""" - [default] - environment: ini-test-env - api_key: ini-api-key - project_name: ini-project-name - controller_host: ini-controller-host - """) - f.flush() - - pinecone.init(config=f.name) - - assert Config.API_KEY == 'env-var-api-key' - assert Config.ENVIRONMENT == 'env-var-env' - assert Config.PROJECT_NAME == 'env-var-project-name' - assert Config.CONTROLLER_HOST == 'env-var-controller-host' - - -def test_init_from_mixed_sources(): - """ - Test that even when some vars are found in a higher precedence source, the rest - are still loaded from lower precedence sources - """ - - os.environ['PINECONE_ENVIRONMENT'] = 'env-var-env' - os.environ['PINECONE_API_KEY'] = 'env-var-api-key' - project_name = 'kwargs-project-name' - controller_host = 'kwargs-controller-host' - - pinecone.init(project_name=project_name, host=controller_host) - - assert Config.API_KEY == 'env-var-api-key' - assert Config.ENVIRONMENT == 'env-var-env' - assert Config.PROJECT_NAME == project_name - assert Config.CONTROLLER_HOST == controller_host \ No newline at end of file +class TestConfig: + @pytest.fixture(autouse=True) + def run_before_and_after_tests(tmpdir): + """Fixture to execute asserts before and after a test is run""" + + # Defend against unexpected env vars. Since we clear these variables below + # after each test execution, these should only be raised if there is + # test pollution in the environment coming from some other test file/setup. + known_env_vars = ["PINECONE_API_KEY", "PINECONE_ENVIRONMENT", "PINECONE_CONTROLLER_HOST"] + for var in known_env_vars: + if os.getenv(var): + raise ValueError(f"Unexpected env var {var} found in environment. Check for test pollution.") + + yield # this is where the testing happens + + # Teardown : Unset any env vars created during test execution + for var in known_env_vars: + if os.getenv(var): + del os.environ[var] + + def test_init_with_environment_vars(self): + os.environ["PINECONE_API_KEY"] = "test-api-key" + os.environ["PINECONE_CONTROLLER_HOST"] = "test-controller-host" + + config = PineconeConfig.build() + + assert config.api_key == "test-api-key" + assert config.host == "test-controller-host" + + def test_init_with_positional_args(self): + api_key = "my-api-key" + host = "my-controller-host" + + config = PineconeConfig.build(api_key, host) + + assert config.api_key == api_key + assert config.host == host + + def test_init_with_kwargs(self): + api_key = "my-api-key" + controller_host = "my-controller-host" + openapi_config = OpenApiConfiguration(api_key="openapi-api-key") + + config = PineconeConfig.build(api_key=api_key, host=controller_host, openapi_config=openapi_config) + + assert config.api_key == api_key + assert config.host == controller_host + assert config.openapi_config == openapi_config + + def test_resolution_order_kwargs_over_env_vars(self): + """ + Test that when config is present from multiple sources, + the order of precedence is kwargs > env vars + """ + os.environ["PINECONE_API_KEY"] = "env-var-api-key" + os.environ["PINECONE_CONTROLLER_HOST"] = "env-var-controller-host" + + api_key = "kwargs-api-key" + controller_host = "kwargs-controller-host" + + config = PineconeConfig.build(api_key=api_key, host=controller_host) + + assert config.api_key == api_key + assert config.host == controller_host + + def test_errors_when_no_api_key_is_present(self): + with pytest.raises(PineconeConfigurationError): + PineconeConfig.build() \ No newline at end of file diff --git a/tests/unit/test_control.py b/tests/unit/test_control.py new file mode 100644 index 000000000..1d54e736b --- /dev/null +++ b/tests/unit/test_control.py @@ -0,0 +1,46 @@ +import pytest +from pinecone import Pinecone +import time + +class TestControl: + def test_default_host(self): + p = Pinecone(api_key="123-456-789") + assert p.index_api.api_client.configuration.host == "https://api.pinecone.io" + + def test_passing_host(self): + p = Pinecone(api_key="123-456-789", host="my-host") + assert p.index_api.api_client.configuration.host == "my-host" + + + @pytest.mark.parametrize("timeout_value, describe_index_responses, expected_describe_index_calls, expected_sleep_calls", [ + # When timeout=None, describe_index is called until ready + (None, [{ "status": {"ready": False}}, {"status": {"ready": True}}], 2, 1), + + # Timeout of 10 seconds, describe_index called 3 times, sleep twice + (10, [{"status": {"ready": False}}, {"status": {"ready": False}}, {"status": {"ready": True}}], 3, 2), + + # When timeout=-1, create_index returns immediately without calling describe_index or sleep + (-1, [{"status": {"ready": False}}], 0, 0), + ]) + def test_create_index_with_timeout(self, mocker, timeout_value, describe_index_responses, expected_describe_index_calls, expected_sleep_calls): + p = Pinecone(api_key="123-456-789") + mocker.patch.object(p.index_api, 'describe_index', side_effect=describe_index_responses) + mocker.patch.object(p.index_api, 'create_index') + mocker.patch('time.sleep') + + p.create_index("my-index", 10, timeout=timeout_value, cloud="aws", region="us-west1", capacity_mode="pod") + + assert p.index_api.create_index.call_count == 1 + assert p.index_api.describe_index.call_count == expected_describe_index_calls + assert time.sleep.call_count == expected_sleep_calls + + def test_create_index_when_timeout_exceeded(self, mocker): + with pytest.raises(TimeoutError): + p = Pinecone(api_key="123-456-789") + mocker.patch.object(p.index_api, 'create_index') + + describe_index_response = [{"status": {"ready": False}}] * 5 + mocker.patch.object(p.index_api, 'describe_index', side_effect=describe_index_response) + mocker.patch('time.sleep') + + p.create_index("my-index", 10, timeout=10, cloud="aws", region="us-west1", capacity_mode="pod") diff --git a/tests/unit/test_grpc_index.py b/tests/unit/test_grpc_index.py deleted file mode 100644 index 2284d81ff..000000000 --- a/tests/unit/test_grpc_index.py +++ /dev/null @@ -1,602 +0,0 @@ -from copy import deepcopy - -import numpy as np -import pandas as pd -import pytest - -import pinecone -from pinecone import DescribeIndexStatsRequest -from pinecone.core.grpc.protos.vector_service_pb2 import Vector, DescribeIndexStatsRequest, UpdateRequest, \ - UpsertRequest, FetchRequest, QueryRequest, DeleteRequest, QueryVector, UpsertResponse, SparseValues -from pinecone.core.utils import dict_to_proto_struct - - -class TestGrpcIndex: - - def setup_method(self): - self.vector_dim = 8 - self.vals1 = [0.1] * self.vector_dim - self.vals2 = [0.2] * self.vector_dim - self.sparse_indices_1 = [1, 8, 42] - self.sparse_values_1 = [0.8, 0.9, 0.42] - self.sparse_indices_2 = [1, 3, 5] - self.sparse_values_2 = [0.7, 0.3, 0.31415] - self.md1 = {'genre': 'action', 'year': 2021} - self.md2 = {'genre': 'documentary', 'year': 2020} - self.filter1 = {'genre': {'$in': ['action']}} - self.filter2 = {'year': {'$eq': 2020}} - - pinecone.init(api_key='example-key') - self.index = pinecone.GRPCIndex('example-name') - - self.expected_vec1 = Vector(id='vec1', values=self.vals1, metadata={}) - self.expected_vec2 = Vector(id='vec2', values=self.vals2, metadata={}) - self.expected_vec_md1 = Vector(id='vec1', values=self.vals1, metadata=dict_to_proto_struct(self.md1)) - self.expected_vec_md2 = Vector(id='vec2', values=self.vals2, metadata=dict_to_proto_struct(self.md2)) - self.expected_vec_md_sparse1 = Vector(id='vec1', values=self.vals1, metadata=dict_to_proto_struct(self.md1), - sparse_values=SparseValues(indices=self.sparse_indices_1, values=self.sparse_values_1)) - self.expected_vec_md_sparse2 = Vector(id='vec2', values=self.vals2, metadata=dict_to_proto_struct(self.md2), - sparse_values=SparseValues(indices=self.sparse_indices_2, values=self.sparse_values_2)) - - - # region: upsert tests - - def _assert_called_once(self, vectors, async_call=False): - self.index._wrap_grpc_call.assert_called_once_with( - self.index.stub.Upsert.future if async_call else self.index.stub.Upsert, - UpsertRequest( - vectors=vectors, - namespace='ns'), - timeout=None - ) - - def test_upsert_tuplesOfIdVec_UpserWithoutMD(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - self.index.upsert([('vec1', self.vals1), ('vec2', self.vals2)], namespace='ns') - self._assert_called_once([ - self.expected_vec1, - self.expected_vec2 - ]) - - - def test_upsert_tuplesOfIdVecMD_UpsertVectorsWithMD(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - self.index.upsert([('vec1', self.vals1, self.md1), ('vec2', self.vals2, self.md2)], namespace='ns') - self._assert_called_once([ - self.expected_vec_md1, - self.expected_vec_md2], - ) - - def test_upsert_vectors_upsertInputVectors(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - self.index.upsert([self.expected_vec_md1, - self.expected_vec_md2], - namespace='ns') - self._assert_called_once([ - self.expected_vec_md1, - self.expected_vec_md2], - ) - - - def test_upsert_vectors_upsertInputVectorsSparse(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - self.index.upsert([Vector(id='vec1', values=self.vals1, metadata=dict_to_proto_struct(self.md1), - sparse_values=SparseValues(indices=self.sparse_indices_1, values=self.sparse_values_1)), - Vector(id='vec2', values=self.vals2, metadata=dict_to_proto_struct(self.md2), - sparse_values=SparseValues(indices=self.sparse_indices_2, values=self.sparse_values_2))], - namespace='ns') - self._assert_called_once([self.expected_vec_md_sparse1, self.expected_vec_md_sparse2]) - - def test_upsert_dict(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - dict1 = {'id': 'vec1', 'values': self.vals1} - dict2 = {'id': 'vec2', 'values': self.vals2} - self.index.upsert([dict1, dict2], namespace='ns') - self._assert_called_once([ - self.expected_vec1, - self.expected_vec2] - ) - - def test_upsert_dict_md(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - dict1 = {'id': 'vec1', 'values': self.vals1, 'metadata': self.md1} - dict2 = {'id': 'vec2', 'values': self.vals2, 'metadata': self.md2} - self.index.upsert([dict1, dict2], namespace='ns') - self._assert_called_once([ - self.expected_vec_md1, - self.expected_vec_md2] - ) - - def test_upsert_dict_sparse(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - dict1 = {'id': 'vec1', 'values': self.vals1, - 'sparse_values': {'indices': self.sparse_indices_1, 'values': self.sparse_values_1}} - dict2 = {'id': 'vec2', 'values': self.vals2, - 'sparse_values': {'indices': self.sparse_indices_2, 'values': self.sparse_values_2}} - self.index.upsert([dict1, dict2], namespace='ns') - self._assert_called_once([ - Vector(id='vec1', values=self.vals1, metadata={}, - sparse_values=SparseValues(indices=self.sparse_indices_1, values=self.sparse_values_1)), - Vector(id='vec2', values=self.vals2, metadata={}, - sparse_values=SparseValues(indices=self.sparse_indices_2, values=self.sparse_values_2))] - ) - - def test_upsert_dict_sparse_md(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - dict1 = {'id': 'vec1', 'values': self.vals1, - 'sparse_values': {'indices': self.sparse_indices_1, 'values': self.sparse_values_1}, - 'metadata': self.md1} - dict2 = {'id': 'vec2', 'values': self.vals2, - 'sparse_values': {'indices': self.sparse_indices_2, 'values': self.sparse_values_2}, - 'metadata': self.md2} - self.index.upsert([dict1, dict2], namespace='ns') - self._assert_called_once([ - Vector(id='vec1', values=self.vals1, metadata=dict_to_proto_struct(self.md1), - sparse_values=SparseValues(indices=self.sparse_indices_1, values=self.sparse_values_1)), - Vector(id='vec2', values=self.vals2, metadata=dict_to_proto_struct(self.md2), - sparse_values=SparseValues(indices=self.sparse_indices_2, values=self.sparse_values_2))] - ) - - def test_upsert_dict_negative(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - - # Missing required keys - dict1 = {'values': self.vals1} - dict2 = {'id': 'vec2'} - with pytest.raises(ValueError): - self.index.upsert([dict1, dict2]) - with pytest.raises(ValueError): - self.index.upsert([dict1]) - with pytest.raises(ValueError): - self.index.upsert([dict2]) - - # Excess keys - dict1 = {'id': 'vec1', 'values': self.vals1} - dict2 = {'id': 'vec2', 'values': self.vals2, 'animal': 'dog'} - with pytest.raises(ValueError) as e: - self.index.upsert([dict1, dict2]) - assert 'animal' in str(e.value) - - dict1 = {'id': 'vec1', 'values': self.vals1, 'metadatta': self.md2} - dict2 = {'id': 'vec2', 'values': self.vals2} - with pytest.raises(ValueError) as e: - self.index.upsert([dict1, dict2]) - assert 'metadatta' in str(e.value) - - @pytest.mark.parametrize("key,new_val", [ - ("values", ['the', 'lazy', 'fox']), - ("values", 'the lazy fox'), - ("values", 0.5), - ("metadata", np.nan), - ("metadata", ['key1', 'key2']), - ("sparse_values", 'cat'), - ("sparse_values", []), - ]) - def test_upsert_dict_with_invalid_values(self, mocker, key, new_val): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - - full_dict1 = {'id': 'vec1', 'values': self.vals1, - 'sparse_values': {'indices': self.sparse_indices_1, 'values': self.sparse_values_1}, - 'metadata': self.md1} - - dict1 = deepcopy(full_dict1) - dict1[key] = new_val - with pytest.raises(TypeError) as e: - self.index.upsert([dict1]) - assert key in str(e.value) - - @pytest.mark.parametrize("key,new_val", [ - ("id", 4.2), - ("id", ['vec1']), - ]) - def test_upsert_dict_with_invalid_ids(self, mocker, key, new_val): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - - full_dict1 = {'id': 'vec1', 'values': self.vals1, - 'sparse_values': {'indices': self.sparse_indices_1, 'values': self.sparse_values_1}, - 'metadata': self.md1} - - dict1 = deepcopy(full_dict1) - dict1[key] = new_val - with pytest.raises(TypeError) as e: - self.index.upsert([dict1]) - assert str(new_val) in str(e.value) - - @pytest.mark.parametrize("key,new_val", [ - ("indices", 3), - ("indices", [1.2, 0.5]), - ("values", ['1', '4.4']), - ("values", 0.5), - ]) - def test_upsert_dict_with_invalid_sparse_values(self, mocker, key, new_val): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - - full_dict1 = {'id': 'vec1', 'values': self.vals1, - 'sparse_values': {'indices': self.sparse_indices_1, 'values': self.sparse_values_1}, - 'metadata': self.md1} - - dict1 = deepcopy(full_dict1) - dict1['sparse_values'][key] = new_val - with pytest.raises(TypeError) as e: - self.index.upsert([dict1]) - assert 'sparse' in str(e.value) - assert key in str(e.value) - - def test_upsert_dataframe(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True, - side_effect=lambda stub, upsert_request, timeout: MockUpsertDelegate(UpsertResponse( - upserted_count=len(upsert_request.vectors)))) - df = pd.DataFrame([ - {'id': 'vec1', 'values': self.vals1, - 'sparse_values': {'indices': self.sparse_indices_1, 'values': self.sparse_values_1}, - 'metadata': self.md1}, - {'id': 'vec2', 'values': self.vals2, - 'sparse_values': {'indices': self.sparse_indices_2, 'values': self.sparse_values_2}, - 'metadata': self.md2} - ]) - self.index.upsert_from_dataframe(df, namespace='ns') - self._assert_called_once([self.expected_vec_md_sparse1, self.expected_vec_md_sparse2], - async_call=True - ) - - - def test_upsert_dataframe_sync(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True, - side_effect=lambda stub, upsert_request, timeout: UpsertResponse( - upserted_count=len(upsert_request.vectors))) - df = pd.DataFrame([ - {'id': 'vec1', 'values': self.vals1, - 'sparse_values': {'indices': self.sparse_indices_1, 'values': self.sparse_values_1}, - 'metadata': self.md1}, - {'id': 'vec2', 'values': self.vals2, - 'sparse_values': {'indices': self.sparse_indices_2, 'values': self.sparse_values_2}, - 'metadata': self.md2} - ]) - self.index.upsert_from_dataframe(df, namespace='ns', use_async_requests=False) - self._assert_called_once([self.expected_vec_md_sparse1, self.expected_vec_md_sparse2], - async_call=False - ) - - def test_upsert_dataframe_negative(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - full_dict1 = {'id': 'vec1', 'values': self.vals1, - 'sparse_values': {'indices': self.sparse_indices_1, 'values': self.sparse_values_1}, - 'metadata': self.md1} - full_df = pd.DataFrame([full_dict1]) - - # Not a DF - with pytest.raises(ValueError): - self.index.upsert_from_dataframe([full_dict1]) - with pytest.raises(ValueError): - self.index.upsert_from_dataframe(full_dict1) - - # Missing Cols - df = full_df.copy() - df.drop(columns=['id'], inplace=True) - with pytest.raises(ValueError): - self.index.upsert_from_dataframe(df) - - # Excess cols - df = full_df.copy() - df['animals'] = ['dog'] - with pytest.raises(ValueError): - self.index.upsert_from_dataframe(df) - - df = full_df.copy() - df['metadat'] = df['metadata'] - with pytest.raises(ValueError): - self.index.upsert_from_dataframe(df) - - def test_upsert_async_upsertInputVectorsAsync(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - self.index.upsert([self.expected_vec_md1, - self.expected_vec_md2], - namespace='ns', - async_req=True) - self._assert_called_once([ - self.expected_vec_md1, - self.expected_vec_md2], - async_call=True - ) - - def test_upsert_vectorListIsMultiplyOfBatchSize_vectorsUpsertedInBatches(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True, - side_effect=lambda stub, upsert_request, timeout: UpsertResponse( - upserted_count=len(upsert_request.vectors))) - - result = self.index.upsert([self.expected_vec_md1, - self.expected_vec_md2], - namespace='ns', - batch_size=1, - show_progress=False) - self.index._wrap_grpc_call.assert_any_call( - self.index.stub.Upsert, - UpsertRequest( - vectors=[ - Vector(id='vec1', values=self.vals1, metadata=dict_to_proto_struct(self.md1))], - namespace='ns'), - timeout=None) - - self.index._wrap_grpc_call.assert_any_call( - self.index.stub.Upsert, - UpsertRequest( - vectors=[self.expected_vec_md2], - namespace='ns'), - timeout=None) - - assert result.upserted_count == 2 - - def test_upsert_vectorListNotMultiplyOfBatchSize_vectorsUpsertedInBatches(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True, - side_effect=lambda stub, upsert_request, timeout: UpsertResponse( - upserted_count=len(upsert_request.vectors))) - - result = self.index.upsert([self.expected_vec_md1, - Vector(id='vec2', values=self.vals2, metadata=dict_to_proto_struct(self.md2)), - Vector(id='vec3', values=self.vals1, metadata=dict_to_proto_struct(self.md1))], - namespace='ns', - batch_size=2) - self.index._wrap_grpc_call.assert_any_call( - self.index.stub.Upsert, - UpsertRequest( - vectors=[ - self.expected_vec_md1, - self.expected_vec_md2], - namespace='ns'), - timeout=None) - - self.index._wrap_grpc_call.assert_any_call( - self.index.stub.Upsert, - UpsertRequest( - vectors=[Vector(id='vec3', values=self.vals1, metadata=dict_to_proto_struct(self.md1))], - namespace='ns'), - timeout=None) - - assert result.upserted_count == 3 - - def test_upsert_vectorListSmallerThanBatchSize_vectorsUpsertedInBatches(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True, - side_effect=lambda stub, upsert_request, timeout: UpsertResponse( - upserted_count=len(upsert_request.vectors))) - - result = self.index.upsert([self.expected_vec_md1, - self.expected_vec_md2], - namespace='ns', - batch_size=5) - self._assert_called_once([ - self.expected_vec_md1, - self.expected_vec_md2], - ) - - assert result.upserted_count == 2 - - def test_upsert_tuplesList_vectorsUpsertedInBatches(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True, - side_effect=lambda stub, upsert_request, timeout: UpsertResponse( - upserted_count=len(upsert_request.vectors))) - - result = self.index.upsert([('vec1', self.vals1, self.md1), - ('vec2', self.vals2, self.md2), - ('vec3', self.vals1, self.md1)], - namespace='ns', - batch_size=2) - self.index._wrap_grpc_call.assert_any_call( - self.index.stub.Upsert, - UpsertRequest( - vectors=[ - self.expected_vec_md1, - self.expected_vec_md2], - namespace='ns'), - timeout=None) - - self.index._wrap_grpc_call.assert_any_call( - self.index.stub.Upsert, - UpsertRequest( - vectors=[Vector(id='vec3', values=self.vals1, metadata=dict_to_proto_struct(self.md1))], - namespace='ns'), - timeout=None) - - assert result.upserted_count == 3 - - def test_upsert_batchSizeIsNotPositive_errorIsRaised(self): - with pytest.raises(ValueError, match='batch_size must be a positive integer'): - self.index.upsert([Vector(id='vec1', values=self.vals1, metadata=dict_to_proto_struct(self.md1))], - namespace='ns', - batch_size=0) - - with pytest.raises(ValueError, match='batch_size must be a positive integer'): - self.index.upsert([Vector(id='vec1', values=self.vals1, metadata=dict_to_proto_struct(self.md1))], - namespace='ns', - batch_size=-1) - - def test_upsert_useBatchSizeAndAsyncReq_valueErrorRaised(self): - with pytest.raises(ValueError, match='async_req is not supported when batch_size is provided.'): - self.index.upsert([Vector(id='vec1', values=self.vals1, metadata=dict_to_proto_struct(self.md1))], - namespace='ns', - batch_size=2, - async_req=True) - - # endregion - - # region: query tests - - def test_query_byVectorNoFilter_queryVectorNoFilter(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - self.index.query(top_k=10, vector=self.vals1) - self.index._wrap_grpc_call.assert_called_once_with( - self.index.stub.Query, - QueryRequest(top_k=10, vector=self.vals1), - timeout=None, - ) - - def test_query_byVectorWithFilter_queryVectorWithFilter(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - self.index.query(top_k=10, vector=self.vals1, filter=self.filter1, namespace='ns', timeout=10) - self.index._wrap_grpc_call.assert_called_once_with( - self.index.stub.Query, - QueryRequest(top_k=10, vector=self.vals1, filter=dict_to_proto_struct(self.filter1), namespace='ns'), - timeout=10, - ) - - def test_query_byTuplesNoFilter_queryVectorsNoFilter(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - self.index.query(top_k=10, queries=[ - (self.vals1,), - (self.vals2,) - ]) - self.index._wrap_grpc_call.assert_called_once_with( - self.index.stub.Query, - QueryRequest(queries=[ - QueryVector(values=self.vals1, filter={}), - QueryVector(values=self.vals2, filter={}) - ], top_k=10), - timeout=None, - ) - - def test_query_byTuplesWithFilter_queryVectorsWithFilter(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - self.index.query(top_k=10, queries=[ - (self.vals1, self.filter1), - (self.vals2, self.filter2) - ]) - self.index._wrap_grpc_call.assert_called_once_with( - self.index.stub.Query, - QueryRequest(queries=[ - QueryVector(values=self.vals1, filter=dict_to_proto_struct(self.filter1)), - QueryVector(values=self.vals2, filter=dict_to_proto_struct(self.filter2)) - ], top_k=10), - timeout=None, - ) - - def test_query_byVecId_queryByVecId(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - self.index.query(top_k=10, id='vec1', include_metadata=True, include_values=False) - self.index._wrap_grpc_call.assert_called_once_with( - self.index.stub.Query, - QueryRequest(top_k=10, id='vec1', include_metadata=True, include_values=False), - timeout=None, - ) - - # endregion - - # region: delete tests - - def test_delete_byIds_deleteByIds(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - self.index.delete(ids=['vec1', 'vec2']) - self.index._wrap_grpc_call.assert_called_once_with( - self.index.stub.Delete, - DeleteRequest(ids=['vec1', 'vec2']), - timeout=None, - ) - - def test_delete_byIdsAsync_deleteByIdsAsync(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - self.index.delete(ids=['vec1', 'vec2'], async_req=True) - self.index._wrap_grpc_call.assert_called_once_with( - self.index.stub.Delete.future, - DeleteRequest(ids=['vec1', 'vec2']), - timeout=None, - ) - - def test_delete_deleteAllByFilter_deleteAllByFilter(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - self.index.delete(delete_all=True, filter=self.filter1, namespace='ns', timeout=30) - self.index._wrap_grpc_call.assert_called_once_with( - self.index.stub.Delete, - DeleteRequest(delete_all=True, filter=dict_to_proto_struct(self.filter1), namespace='ns'), - timeout=30, - ) - - def test_delete_deleteAllNoFilter_deleteNoFilter(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - self.index.delete(delete_all=True) - self.index._wrap_grpc_call.assert_called_once_with( - self.index.stub.Delete, - DeleteRequest(delete_all=True), - timeout=None, - ) - - # endregion - - # region: fetch tests - - def test_fetch_byIds_fetchByIds(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - self.index.fetch(['vec1', 'vec2']) - self.index._wrap_grpc_call.assert_called_once_with( - self.index.stub.Fetch, - FetchRequest(ids=['vec1', 'vec2']), - timeout=None, - ) - - def test_fetch_byIdsAndNS_fetchByIdsAndNS(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - self.index.fetch(['vec1', 'vec2'], namespace='ns', timeout=30) - self.index._wrap_grpc_call.assert_called_once_with( - self.index.stub.Fetch, - FetchRequest(ids=['vec1', 'vec2'], namespace='ns'), - timeout=30, - ) - - # endregion - - # region: update tests - - def test_update_byIdAnValues_updateByIdAndValues(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - self.index.update(id='vec1', values=self.vals1, namespace='ns', timeout=30) - self.index._wrap_grpc_call.assert_called_once_with( - self.index.stub.Update, - UpdateRequest(id='vec1', values=self.vals1, namespace='ns'), - timeout=30, - ) - - def test_update_byIdAnValuesAsync_updateByIdAndValuesAsync(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - self.index.update(id='vec1', values=self.vals1, namespace='ns', timeout=30, async_req=True) - self.index._wrap_grpc_call.assert_called_once_with( - self.index.stub.Update.future, - UpdateRequest(id='vec1', values=self.vals1, namespace='ns'), - timeout=30, - ) - - def test_update_byIdAnValuesAndMetadata_updateByIdAndValuesAndMetadata(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - self.index.update('vec1', values=self.vals1, set_metadata=self.md1) - self.index._wrap_grpc_call.assert_called_once_with( - self.index.stub.Update, - UpdateRequest(id='vec1', values=self.vals1, set_metadata=dict_to_proto_struct(self.md1)), - timeout=None, - ) - - # endregion - - # region: describe index tests - - def test_describeIndexStats_callWithoutFilter_CalledWithoutFilter(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - self.index.describe_index_stats() - self.index._wrap_grpc_call.assert_called_once_with( - self.index.stub.DescribeIndexStats, - DescribeIndexStatsRequest(), - timeout=None, - ) - - def test_describeIndexStats_callWithFilter_CalledWithFilter(self, mocker): - mocker.patch.object(self.index, '_wrap_grpc_call', autospec=True) - self.index.describe_index_stats(filter=self.filter1) - self.index._wrap_grpc_call.assert_called_once_with( - self.index.stub.DescribeIndexStats, - DescribeIndexStatsRequest(filter=dict_to_proto_struct(self.filter1)), - timeout=None, - ) - - # endregion - -class MockUpsertDelegate: - def __init__(self, upsert_response: UpsertResponse): - self.response = upsert_response - - def result(self, timeout): - return self.response \ No newline at end of file diff --git a/tests/unit/test_index.py b/tests/unit/test_index.py index 7092d71cf..468222b44 100644 --- a/tests/unit/test_index.py +++ b/tests/unit/test_index.py @@ -1,362 +1,395 @@ import pandas as pd import numpy as np import pytest -import warnings - -from pinecone.core.client.api_client import Endpoint import pinecone +from pinecone import Index +from pinecone import UpsertRequest, Vector from pinecone import DescribeIndexStatsRequest, ScoredVector, QueryResponse, UpsertResponse, SparseValues - class TestRestIndex: - def setup_method(self): self.vector_dim = 8 - self.id1 = 'vec1' - self.id2 = 'vec2' + self.id1 = "vec1" + self.id2 = "vec2" self.vals1 = [0.1] * self.vector_dim self.vals2 = [0.2] * self.vector_dim - self.md1 = {'genre': 'action', 'year': 2021} - self.md2 = {'genre': 'documentary', 'year': 2020} - self.filter1 = {'genre': {'$in': ['action']}} - self.filter2 = {'year': {'$eq': 2020}} + self.md1 = {"genre": "action", "year": 2021} + self.md2 = {"genre": "documentary", "year": 2020} + self.filter1 = {"genre": {"$in": ["action"]}} + self.filter2 = {"year": {"$eq": 2020}} self.svi1 = [1, 3, 5] self.svv1 = [0.1, 0.2, 0.3] self.sv1 = { - 'indices': self.svi1, - 'values': self.svv1, + "indices": self.svi1, + "values": self.svv1, } self.svi2 = [2, 4, 6] self.svv2 = [0.1, 0.2, 0.3] - self.sv2 = { - 'indices': self.svi2, - 'values': self.svv2 - } + self.sv2 = {"indices": self.svi2, "values": self.svv2} - pinecone.init(api_key='example-key') - self.index = pinecone.Index('example-name') + self.index = Index(api_key='asdf', host='https://test.pinecone.io') # region: upsert tests - def test_upsert_numpy_deprecation_warning(self, mocker): - mocker.patch.object(self.index._vector_api, 'upsert', autospec=True) - with pytest.warns(FutureWarning): - # numpy used in dictionary values - self.index.upsert([{'id': '2', 'values': np.array([3.0, 3.2, 4.2])}]) - with pytest.warns(FutureWarning): - # numpy used in dictionary sparse_values - self.index.upsert([{'id': '3', 'values': [0.5,0.5,0.5], 'sparse_values': { 'indices': np.array([0, 1]), 'values': np.array([3.0, 3.2])}}]) - def test_upsert_tuplesOfIdVec_UpserWithoutMD(self, mocker): - mocker.patch.object(self.index._vector_api, 'upsert', autospec=True) - self.index.upsert([('vec1', self.vals1), ('vec2', self.vals2)], namespace='ns') + mocker.patch.object(self.index._vector_api, "upsert", autospec=True) + self.index.upsert([("vec1", self.vals1), ("vec2", self.vals2)], namespace="ns") self.index._vector_api.upsert.assert_called_once_with( - pinecone.UpsertRequest(vectors=[ - pinecone.Vector(id='vec1', values=self.vals1, metadata={}), - pinecone.Vector(id='vec2', values=self.vals2, metadata={}) - ], namespace='ns') + UpsertRequest( + vectors=[ + Vector(id="vec1", values=self.vals1, metadata={}), + Vector(id="vec2", values=self.vals2, metadata={}), + ], + namespace="ns", + ) ) def test_upsert_tuplesOfIdVecMD_UpsertVectorsWithMD(self, mocker): - mocker.patch.object(self.index._vector_api, 'upsert', autospec=True) - self.index.upsert([('vec1', self.vals1, self.md1), - ('vec2', self.vals2, self.md2)]) + mocker.patch.object(self.index._vector_api, "upsert", autospec=True) + self.index.upsert([("vec1", self.vals1, self.md1), ("vec2", self.vals2, self.md2)]) self.index._vector_api.upsert.assert_called_once_with( - pinecone.UpsertRequest(vectors=[ - pinecone.Vector(id='vec1', values=self.vals1, metadata=self.md1), - pinecone.Vector(id='vec2', values=self.vals2, metadata=self.md2) - ]) + UpsertRequest( + vectors=[ + Vector(id="vec1", values=self.vals1, metadata=self.md1), + Vector(id="vec2", values=self.vals2, metadata=self.md2), + ] + ) ) def test_upsert_dictOfIdVecMD_UpsertVectorsWithMD(self, mocker): - mocker.patch.object(self.index._vector_api, 'upsert', autospec=True) - self.index.upsert([{'id': self.id1, 'values': self.vals1, 'metadata': self.md1}, - {'id': self.id2, 'values': self.vals2, 'metadata': self.md2}]) + mocker.patch.object(self.index._vector_api, "upsert", autospec=True) + self.index.upsert( + [ + {"id": self.id1, "values": self.vals1, "metadata": self.md1}, + {"id": self.id2, "values": self.vals2, "metadata": self.md2}, + ] + ) self.index._vector_api.upsert.assert_called_once_with( - pinecone.UpsertRequest(vectors=[ - pinecone.Vector(id='vec1', values=self.vals1, metadata=self.md1), - pinecone.Vector(id='vec2', values=self.vals2, metadata=self.md2) - ]) + UpsertRequest( + vectors=[ + Vector(id="vec1", values=self.vals1, metadata=self.md1), + Vector(id="vec2", values=self.vals2, metadata=self.md2), + ] + ) ) def test_upsert_dictOfIdVecMD_UpsertVectorsWithoutMD(self, mocker): - mocker.patch.object(self.index._vector_api, 'upsert', autospec=True) - self.index.upsert([{'id': self.id1, 'values': self.vals1}, - {'id': self.id2, 'values': self.vals2}]) + mocker.patch.object(self.index._vector_api, "upsert", autospec=True) + self.index.upsert([{"id": self.id1, "values": self.vals1}, {"id": self.id2, "values": self.vals2}]) self.index._vector_api.upsert.assert_called_once_with( - pinecone.UpsertRequest(vectors=[ - pinecone.Vector(id='vec1', values=self.vals1), - pinecone.Vector(id='vec2', values=self.vals2) - ]) + UpsertRequest(vectors=[Vector(id="vec1", values=self.vals1), Vector(id="vec2", values=self.vals2)]) ) def test_upsert_dictOfIdVecMD_UpsertVectorsWithSparseValues(self, mocker): - mocker.patch.object(self.index._vector_api, 'upsert', autospec=True) - self.index.upsert([{'id': self.id1, 'values': self.vals1, 'sparse_values': self.sv1}, - {'id': self.id2, 'values': self.vals2, 'sparse_values': self.sv2}]) + mocker.patch.object(self.index._vector_api, "upsert", autospec=True) + self.index.upsert( + [ + {"id": self.id1, "values": self.vals1, "sparse_values": self.sv1}, + {"id": self.id2, "values": self.vals2, "sparse_values": self.sv2}, + ] + ) self.index._vector_api.upsert.assert_called_once_with( - pinecone.UpsertRequest(vectors=[ - pinecone.Vector(id='vec1', values=self.vals1, sparse_values=SparseValues(**self.sv1)), - pinecone.Vector(id='vec2', values=self.vals2, sparse_values=SparseValues(**self.sv2)) - ]) + UpsertRequest( + vectors=[ + Vector(id="vec1", values=self.vals1, sparse_values=SparseValues(**self.sv1)), + Vector(id="vec2", values=self.vals2, sparse_values=SparseValues(**self.sv2)), + ] + ) ) def test_upsert_vectors_upsertInputVectors(self, mocker): - mocker.patch.object(self.index._vector_api, 'upsert', autospec=True) - self.index.upsert(vectors=[ - pinecone.Vector(id='vec1', values=self.vals1, metadata=self.md1), - pinecone.Vector(id='vec2', values=self.vals2, metadata=self.md2)], - namespace='ns') + mocker.patch.object(self.index._vector_api, "upsert", autospec=True) + self.index.upsert( + vectors=[ + Vector(id="vec1", values=self.vals1, metadata=self.md1), + Vector(id="vec2", values=self.vals2, metadata=self.md2), + ], + namespace="ns", + ) self.index._vector_api.upsert.assert_called_once_with( - pinecone.UpsertRequest(vectors=[ - pinecone.Vector(id='vec1', values=self.vals1, metadata=self.md1), - pinecone.Vector(id='vec2', values=self.vals2, metadata=self.md2) - ], namespace='ns') + UpsertRequest( + vectors=[ + Vector(id="vec1", values=self.vals1, metadata=self.md1), + Vector(id="vec2", values=self.vals2, metadata=self.md2), + ], + namespace="ns", + ) ) def test_upsert_parallelUpsert_callUpsertParallel(self, mocker): - mocker.patch.object(Endpoint, '__call__', autospec=True) - chunks = [[pinecone.Vector(id='vec1', values=self.vals1, metadata=self.md1)], - [pinecone.Vector(id='vec2', values=self.vals2, metadata=self.md2)]] - with pinecone.Index('example-index', pool_threads=30) as index: + chunks = [ + [Vector(id="vec1", values=self.vals1, metadata=self.md1)], + [Vector(id="vec2", values=self.vals2, metadata=self.md2)], + ] + with Index(api_key="asdf", host="https://test.pinecone.io", pool_threads=30) as index: + mocker.patch.object(index._vector_api, "upsert", autospec=True) + # Send requests in parallel async_results = [ - index.upsert(vectors=ids_vectors_chunk, namespace="ns", async_req=True) - for ids_vectors_chunk in chunks + index.upsert(vectors=ids_vectors_chunk, namespace="ns", async_req=True) for ids_vectors_chunk in chunks ] # Wait for and retrieve responses (this raises in case of error) [async_result.get() for async_result in async_results] - Endpoint.__call__.assert_any_call( - index._vector_api.upsert, - pinecone.UpsertRequest(vectors=[ - pinecone.Vector(id='vec1', values=self.vals1, metadata=self.md1), - ], - namespace='ns'), - async_req=True + index._vector_api.upsert.assert_any_call( + UpsertRequest( + vectors=[ + Vector(id="vec1", values=self.vals1, metadata=self.md1), + ], + namespace="ns", + ), + async_req=True, ) - Endpoint.__call__.assert_any_call( - index._vector_api.upsert, - pinecone.UpsertRequest(vectors=[ - pinecone.Vector(id='vec2', values=self.vals2, metadata=self.md2), - ], - namespace='ns'), - async_req=True + index._vector_api.upsert.assert_any_call( + UpsertRequest( + vectors=[ + Vector(id="vec2", values=self.vals2, metadata=self.md2), + ], + namespace="ns", + ), + async_req=True, ) def test_upsert_vectorListIsMultiplyOfBatchSize_vectorsUpsertedInBatches(self, mocker): - mocker.patch.object(self.index._vector_api, - 'upsert', - autospec=True, - side_effect=lambda upsert_request: UpsertResponse( - upserted_count=len(upsert_request.vectors))) - - result = self.index.upsert(vectors=[ - pinecone.Vector(id='vec1', values=self.vals1, metadata=self.md1), - pinecone.Vector(id='vec2', values=self.vals2, metadata=self.md2)], - namespace='ns', + mocker.patch.object( + self.index._vector_api, + "upsert", + autospec=True, + side_effect=lambda upsert_request: UpsertResponse(upserted_count=len(upsert_request.vectors)), + ) + + result = self.index.upsert( + vectors=[ + Vector(id="vec1", values=self.vals1, metadata=self.md1), + Vector(id="vec2", values=self.vals2, metadata=self.md2), + ], + namespace="ns", batch_size=1, - show_progress=False) + show_progress=False, + ) self.index._vector_api.upsert.assert_any_call( - pinecone.UpsertRequest(vectors=[ - pinecone.Vector(id='vec1', values=self.vals1, metadata=self.md1), - ], namespace='ns') + UpsertRequest( + vectors=[ + Vector(id="vec1", values=self.vals1, metadata=self.md1), + ], + namespace="ns", + ) ) self.index._vector_api.upsert.assert_any_call( - pinecone.UpsertRequest(vectors=[ - pinecone.Vector(id='vec2', values=self.vals2, metadata=self.md2), - ], namespace='ns') + UpsertRequest( + vectors=[ + Vector(id="vec2", values=self.vals2, metadata=self.md2), + ], + namespace="ns", + ) ) assert result.upserted_count == 2 def test_upsert_vectorListNotMultiplyOfBatchSize_vectorsUpsertedInBatches(self, mocker): - mocker.patch.object(self.index._vector_api, - 'upsert', - autospec=True, - side_effect=lambda upsert_request: UpsertResponse( - upserted_count=len(upsert_request.vectors))) - - result = self.index.upsert(vectors=[ - pinecone.Vector(id='vec1', values=self.vals1, metadata=self.md1), - pinecone.Vector(id='vec2', values=self.vals2, metadata=self.md2), - pinecone.Vector(id='vec3', values=self.vals1, metadata=self.md1)], - namespace='ns', - batch_size=2) + mocker.patch.object( + self.index._vector_api, + "upsert", + autospec=True, + side_effect=lambda upsert_request: UpsertResponse(upserted_count=len(upsert_request.vectors)), + ) + + result = self.index.upsert( + vectors=[ + Vector(id="vec1", values=self.vals1, metadata=self.md1), + Vector(id="vec2", values=self.vals2, metadata=self.md2), + Vector(id="vec3", values=self.vals1, metadata=self.md1), + ], + namespace="ns", + batch_size=2, + ) self.index._vector_api.upsert.assert_any_call( - pinecone.UpsertRequest(vectors=[ - pinecone.Vector(id='vec1', values=self.vals1, metadata=self.md1), - pinecone.Vector(id='vec2', values=self.vals2, metadata=self.md2), - ], namespace='ns') + UpsertRequest( + vectors=[ + Vector(id="vec1", values=self.vals1, metadata=self.md1), + Vector(id="vec2", values=self.vals2, metadata=self.md2), + ], + namespace="ns", + ) ) self.index._vector_api.upsert.assert_any_call( - pinecone.UpsertRequest(vectors=[ - pinecone.Vector(id='vec3', values=self.vals1, metadata=self.md1), - ], namespace='ns') + UpsertRequest( + vectors=[ + Vector(id="vec3", values=self.vals1, metadata=self.md1), + ], + namespace="ns", + ) ) assert result.upserted_count == 3 def test_upsert_vectorListSmallerThanBatchSize_vectorsUpsertedInBatches(self, mocker): - mocker.patch.object(self.index._vector_api, - 'upsert', - autospec=True, - side_effect=lambda upsert_request: UpsertResponse( - upserted_count=len(upsert_request.vectors))) - - result = self.index.upsert(vectors=[ - pinecone.Vector(id='vec1', values=self.vals1, metadata=self.md1), - pinecone.Vector(id='vec2', values=self.vals2, metadata=self.md2), - pinecone.Vector(id='vec3', values=self.vals1, metadata=self.md1)], - namespace='ns', - batch_size=5) + mocker.patch.object( + self.index._vector_api, + "upsert", + autospec=True, + side_effect=lambda upsert_request: UpsertResponse(upserted_count=len(upsert_request.vectors)), + ) + + result = self.index.upsert( + vectors=[ + Vector(id="vec1", values=self.vals1, metadata=self.md1), + Vector(id="vec2", values=self.vals2, metadata=self.md2), + Vector(id="vec3", values=self.vals1, metadata=self.md1), + ], + namespace="ns", + batch_size=5, + ) self.index._vector_api.upsert.assert_called_once_with( - pinecone.UpsertRequest(vectors=[ - pinecone.Vector(id='vec1', values=self.vals1, metadata=self.md1), - pinecone.Vector(id='vec2', values=self.vals2, metadata=self.md2), - pinecone.Vector(id='vec3', values=self.vals1, metadata=self.md1), - ], namespace='ns') + UpsertRequest( + vectors=[ + Vector(id="vec1", values=self.vals1, metadata=self.md1), + Vector(id="vec2", values=self.vals2, metadata=self.md2), + Vector(id="vec3", values=self.vals1, metadata=self.md1), + ], + namespace="ns", + ) ) assert result.upserted_count == 3 def test_upsert_tuplesList_vectorsUpsertedInBatches(self, mocker): - mocker.patch.object(self.index._vector_api, - 'upsert', - autospec=True, - side_effect=lambda upsert_request: UpsertResponse( - upserted_count=len(upsert_request.vectors))) - - result = self.index.upsert(vectors= - [('vec1', self.vals1, self.md1), - ('vec2', self.vals2, self.md2), - ('vec3', self.vals1, self.md1)], - namespace='ns', - batch_size=2) + mocker.patch.object( + self.index._vector_api, + "upsert", + autospec=True, + side_effect=lambda upsert_request: UpsertResponse(upserted_count=len(upsert_request.vectors)), + ) + + result = self.index.upsert( + vectors=[("vec1", self.vals1, self.md1), ("vec2", self.vals2, self.md2), ("vec3", self.vals1, self.md1)], + namespace="ns", + batch_size=2, + ) self.index._vector_api.upsert.assert_any_call( - pinecone.UpsertRequest(vectors=[ - pinecone.Vector(id='vec1', values=self.vals1, metadata=self.md1), - pinecone.Vector(id='vec2', values=self.vals2, metadata=self.md2), - ], namespace='ns') + UpsertRequest( + vectors=[ + Vector(id="vec1", values=self.vals1, metadata=self.md1), + Vector(id="vec2", values=self.vals2, metadata=self.md2), + ], + namespace="ns", + ) ) self.index._vector_api.upsert.assert_any_call( - pinecone.UpsertRequest(vectors=[ - pinecone.Vector(id='vec3', values=self.vals1, metadata=self.md1), - ], namespace='ns') + UpsertRequest( + vectors=[ + Vector(id="vec3", values=self.vals1, metadata=self.md1), + ], + namespace="ns", + ) ) assert result.upserted_count == 3 def test_upsert_dataframe(self, mocker): - mocker.patch.object(self.index._vector_api, 'upsert', autospec=True, return_value=UpsertResponse(upserted_count=2)) - df = pd.DataFrame([ - {'id': self.id1, 'values': self.vals1, 'metadata': self.md1}, - {'id': self.id2, 'values': self.vals2, 'metadata': self.md2} - ]) + mocker.patch.object( + self.index._vector_api, "upsert", autospec=True, return_value=UpsertResponse(upserted_count=2) + ) + df = pd.DataFrame( + [ + {"id": self.id1, "values": self.vals1, "metadata": self.md1}, + {"id": self.id2, "values": self.vals2, "metadata": self.md2}, + ] + ) self.index.upsert_from_dataframe(df) self.index._vector_api.upsert.assert_called_once_with( - pinecone.UpsertRequest(vectors=[ - pinecone.Vector(id='vec1', values=self.vals1, metadata=self.md1), - pinecone.Vector(id='vec2', values=self.vals2, metadata=self.md2) - ]) + UpsertRequest( + vectors=[ + Vector(id="vec1", values=self.vals1, metadata=self.md1), + Vector(id="vec2", values=self.vals2, metadata=self.md2), + ] + ) ) def test_upsert_batchSizeIsNotPositive_errorIsRaised(self): - with pytest.raises(ValueError, match='batch_size must be a positive integer'): - self.index.upsert(vectors=[ - pinecone.Vector(id='vec1', values=self.vals1, metadata=self.md1)], - namespace='ns', - batch_size=0) - - with pytest.raises(ValueError, match='batch_size must be a positive integer'): - self.index.upsert(vectors=[ - pinecone.Vector(id='vec1', values=self.vals1, metadata=self.md1)], - namespace='ns', - batch_size=-1) + with pytest.raises(ValueError, match="batch_size must be a positive integer"): + self.index.upsert( + vectors=[Vector(id="vec1", values=self.vals1, metadata=self.md1)], namespace="ns", batch_size=0 + ) + + with pytest.raises(ValueError, match="batch_size must be a positive integer"): + self.index.upsert( + vectors=[Vector(id="vec1", values=self.vals1, metadata=self.md1)], + namespace="ns", + batch_size=-1, + ) def test_upsert_useBatchSizeAndAsyncReq_valueErrorRaised(self): - with pytest.raises(ValueError, match='async_req is not supported when batch_size is provided.'): - self.index.upsert(vectors=[ - pinecone.Vector(id='vec1', values=self.vals1, metadata=self.md1)], - namespace='ns', + with pytest.raises(ValueError, match="async_req is not supported when batch_size is provided."): + self.index.upsert( + vectors=[Vector(id="vec1", values=self.vals1, metadata=self.md1)], + namespace="ns", batch_size=1, - async_req=True) + async_req=True, + ) # endregion # region: query tests def test_query_byVectorNoFilter_queryVectorNoFilter(self, mocker): - response = QueryResponse(results=[], - matches=[ScoredVector(id="1", - score=0.9, - values=[0.0], - metadata={"a": 2})], - namespace="test") - - mocker.patch.object(self.index._vector_api, 'query', autospec=True, return_value=response) + response = QueryResponse( + results=[], matches=[ScoredVector(id="1", score=0.9, values=[0.0], metadata={"a": 2})], namespace="test" + ) + mocker.patch.object(self.index._vector_api, "query", autospec=True, return_value=response) actual = self.index.query(top_k=10, vector=self.vals1) - self.index._vector_api.query.assert_called_once_with( - pinecone.QueryRequest(top_k=10, vector=self.vals1) + self.index._vector_api.query.assert_called_once_with(pinecone.QueryRequest(top_k=10, vector=self.vals1)) + expected = QueryResponse( + matches=[ScoredVector(id="1", score=0.9, values=[0.0], metadata={"a": 2})], namespace="test" ) - expected = QueryResponse(matches=[ScoredVector(id="1", - score=0.9, - values=[0.0], - metadata={"a": 2})], - namespace="test") - expected._data_store.pop('results', None) - assert actual == expected + assert expected.to_dict() == actual.to_dict() def test_query_byVectorWithFilter_queryVectorWithFilter(self, mocker): - mocker.patch.object(self.index._vector_api, 'query', autospec=True) - self.index.query(top_k=10, vector=self.vals1, filter=self.filter1, namespace='ns') + mocker.patch.object(self.index._vector_api, "query", autospec=True) + self.index.query(top_k=10, vector=self.vals1, filter=self.filter1, namespace="ns") self.index._vector_api.query.assert_called_once_with( - pinecone.QueryRequest(top_k=10, vector=self.vals1, filter=self.filter1, namespace='ns') + pinecone.QueryRequest(top_k=10, vector=self.vals1, filter=self.filter1, namespace="ns") ) def test_query_byTuplesNoFilter_queryVectorsNoFilter(self, mocker): - mocker.patch.object(self.index._vector_api, 'query', autospec=True) - self.index.query(top_k=10, queries=[ - (self.vals1,), - (self.vals2,) - ]) + mocker.patch.object(self.index._vector_api, "query", autospec=True) + self.index.query(top_k=10, queries=[(self.vals1,), (self.vals2,)]) self.index._vector_api.query.assert_called_once_with( - pinecone.QueryRequest(top_k=10, queries=[ - pinecone.QueryVector(values=self.vals1), - pinecone.QueryVector(values=self.vals2) - ]) + pinecone.QueryRequest( + top_k=10, queries=[pinecone.QueryVector(values=self.vals1), pinecone.QueryVector(values=self.vals2)] + ) ) def test_query_byTuplesWithFilter_queryVectorsWithFilter(self, mocker): - mocker.patch.object(self.index._vector_api, 'query', autospec=True) - self.index.query(top_k=10, queries=[ - (self.vals1, self.filter1), - (self.vals2, self.filter2) - ]) + mocker.patch.object(self.index._vector_api, "query", autospec=True) + self.index.query(top_k=10, queries=[(self.vals1, self.filter1), (self.vals2, self.filter2)]) self.index._vector_api.query.assert_called_once_with( - pinecone.QueryRequest(top_k=10, queries=[ - pinecone.QueryVector(values=self.vals1, filter=self.filter1), - pinecone.QueryVector(values=self.vals2, filter=self.filter2) - ]) + pinecone.QueryRequest( + top_k=10, + queries=[ + pinecone.QueryVector(values=self.vals1, filter=self.filter1), + pinecone.QueryVector(values=self.vals2, filter=self.filter2), + ], + ) ) def test_query_byVecId_queryByVecId(self, mocker): - mocker.patch.object(self.index._vector_api, 'query', autospec=True) - self.index.query(top_k=10, id='vec1', include_metadata=True, include_values=False) + mocker.patch.object(self.index._vector_api, "query", autospec=True) + self.index.query(top_k=10, id="vec1", include_metadata=True, include_values=False) self.index._vector_api.query.assert_called_once_with( - pinecone.QueryRequest(top_k=10, id='vec1', include_metadata=True, include_values=False) + pinecone.QueryRequest(top_k=10, id="vec1", include_metadata=True, include_values=False) ) # endregion @@ -364,60 +397,52 @@ def test_query_byVecId_queryByVecId(self, mocker): # region: delete tests def test_delete_byIds_deleteByIds(self, mocker): - mocker.patch.object(self.index._vector_api, 'delete', autospec=True) - self.index.delete(ids=['vec1', 'vec2']) - self.index._vector_api.delete.assert_called_once_with( - pinecone.DeleteRequest(ids=['vec1', 'vec2']) - ) + mocker.patch.object(self.index._vector_api, "delete", autospec=True) + self.index.delete(ids=["vec1", "vec2"]) + self.index._vector_api.delete.assert_called_once_with(pinecone.DeleteRequest(ids=["vec1", "vec2"])) def test_delete_deleteAllByFilter_deleteAllByFilter(self, mocker): - mocker.patch.object(self.index._vector_api, 'delete', autospec=True) - self.index.delete(delete_all=True, filter=self.filter1, namespace='ns') + mocker.patch.object(self.index._vector_api, "delete", autospec=True) + self.index.delete(delete_all=True, filter=self.filter1, namespace="ns") self.index._vector_api.delete.assert_called_once_with( - pinecone.DeleteRequest(delete_all=True, filter=self.filter1, namespace='ns') + pinecone.DeleteRequest(delete_all=True, filter=self.filter1, namespace="ns") ) def test_delete_deleteAllNoFilter_deleteNoFilter(self, mocker): - mocker.patch.object(self.index._vector_api, 'delete', autospec=True) + mocker.patch.object(self.index._vector_api, "delete", autospec=True) self.index.delete(delete_all=True) - self.index._vector_api.delete.assert_called_once_with( - pinecone.DeleteRequest(delete_all=True) - ) + self.index._vector_api.delete.assert_called_once_with(pinecone.DeleteRequest(delete_all=True)) # endregion # region: fetch tests def test_fetch_byIds_fetchByIds(self, mocker): - mocker.patch.object(self.index._vector_api, 'fetch', autospec=True) - self.index.fetch(ids=['vec1', 'vec2']) - self.index._vector_api.fetch.assert_called_once_with( - ids=['vec1', 'vec2'] - ) + mocker.patch.object(self.index._vector_api, "fetch", autospec=True) + self.index.fetch(ids=["vec1", "vec2"]) + self.index._vector_api.fetch.assert_called_once_with(ids=["vec1", "vec2"]) def test_fetch_byIdsAndNS_fetchByIdsAndNS(self, mocker): - mocker.patch.object(self.index._vector_api, 'fetch', autospec=True) - self.index.fetch(ids=['vec1', 'vec2'], namespace='ns') - self.index._vector_api.fetch.assert_called_once_with( - ids=['vec1', 'vec2'], namespace='ns' - ) + mocker.patch.object(self.index._vector_api, "fetch", autospec=True) + self.index.fetch(ids=["vec1", "vec2"], namespace="ns") + self.index._vector_api.fetch.assert_called_once_with(ids=["vec1", "vec2"], namespace="ns") # endregion # region: update tests def test_update_byIdAnValues_updateByIdAndValues(self, mocker): - mocker.patch.object(self.index._vector_api, 'update', autospec=True) - self.index.update(id='vec1', values=self.vals1, namespace='ns') + mocker.patch.object(self.index._vector_api, "update", autospec=True) + self.index.update(id="vec1", values=self.vals1, namespace="ns") self.index._vector_api.update.assert_called_once_with( - pinecone.UpdateRequest(id='vec1', values=self.vals1, namespace='ns') + pinecone.UpdateRequest(id="vec1", values=self.vals1, namespace="ns") ) def test_update_byIdAnValuesAndMetadata_updateByIdAndValuesAndMetadata(self, mocker): - mocker.patch.object(self.index._vector_api, 'update', autospec=True) - self.index.update('vec1', values=self.vals1, metadata=self.md1) + mocker.patch.object(self.index._vector_api, "update", autospec=True) + self.index.update("vec1", values=self.vals1, metadata=self.md1) self.index._vector_api.update.assert_called_once_with( - pinecone.UpdateRequest(id='vec1', values=self.vals1, metadata=self.md1) + pinecone.UpdateRequest(id="vec1", values=self.vals1, metadata=self.md1) ) # endregion @@ -425,15 +450,15 @@ def test_update_byIdAnValuesAndMetadata_updateByIdAndValuesAndMetadata(self, moc # region: describe index tests def test_describeIndexStats_callWithoutFilter_CalledWithoutFilter(self, mocker): - mocker.patch.object(self.index._vector_api, 'describe_index_stats', autospec=True) + mocker.patch.object(self.index._vector_api, "describe_index_stats", autospec=True) self.index.describe_index_stats() - self.index._vector_api.describe_index_stats.assert_called_once_with( - DescribeIndexStatsRequest()) + self.index._vector_api.describe_index_stats.assert_called_once_with(DescribeIndexStatsRequest()) def test_describeIndexStats_callWithFilter_CalledWithFilter(self, mocker): - mocker.patch.object(self.index._vector_api, 'describe_index_stats', autospec=True) + mocker.patch.object(self.index._vector_api, "describe_index_stats", autospec=True) self.index.describe_index_stats(filter=self.filter1) self.index._vector_api.describe_index_stats.assert_called_once_with( - DescribeIndexStatsRequest(filter=self.filter1)) + DescribeIndexStatsRequest(filter=self.filter1) + ) # endregion diff --git a/tests/unit/test_manage.py b/tests/unit/test_manage.py deleted file mode 100644 index 70c7dedb2..000000000 --- a/tests/unit/test_manage.py +++ /dev/null @@ -1,54 +0,0 @@ -import pytest -import pinecone -import time - -class TestManage: - - def test_get_api_instance_without_host(self): - pinecone.init(api_key="123-456-789", environment="my-environment") - api_instance = pinecone.manage._get_api_instance() - assert api_instance.api_client.configuration.host == "https://controller.my-environment.pinecone.io" - - def test_get_api_instance_with_host(self): - pinecone.init(api_key="123-456-789", environment="my-environment", host="my-host") - api_instance = pinecone.manage._get_api_instance() - assert api_instance.api_client.configuration.host == "my-host" - - @pytest.mark.parametrize("timeout_value, get_status_calls, time_sleep_calls, get_status_responses", [ - # No timeout, _get_status called twice, sleep called once - (None, 2, 1, [{"ready": False}, {"ready": True}]), - # Timeout of 10 seconds, _get_status called 3 times, sleep twice - (10, 3, 2, [{"ready": False}, {"ready": False}, {"ready": True}]), - # Timeout of -1 seconds, _get_status not called, no sleep - (-1, 0, 0, [{"ready": False}]), - ]) - def test_create_index_with_timeout(self, mocker, timeout_value, get_status_calls, time_sleep_calls, get_status_responses): - mocker.patch('pinecone.manage._get_api_instance', return_value=mocker.Mock()) - mocker.patch('pinecone.manage._get_status', side_effect=get_status_responses) - mocker.patch('time.sleep') - - pinecone.manage.create_index("my-index", 10, timeout=timeout_value) - - pinecone.manage._get_api_instance.assert_called_once() - assert pinecone.manage._get_status.call_count == get_status_calls - assert time.sleep.call_count == time_sleep_calls - - @pytest.mark.parametrize("timeout_value, list_indexes_calls, time_sleep_calls, list_indexes_responses", [ - # No timeout, list_indexes called twice, sleep called once - (None, 2, 1, [["my-index", "index-1"], ["index-1"]]), - # Timeout of 10 seconds, list_indexes called 3 times, sleep twice - (10, 3, 2, [["my-index", "index-1"], ["my-index", "index-1"], ["index-1"]]), - # Timeout of -1 seconds, list_indexes not called, no sleep - (-1, 0, 0, [["my-index", "index-1"]]), - ]) - def test_delete_index_with_timeout(self, mocker, timeout_value, list_indexes_calls, time_sleep_calls, list_indexes_responses): - api_instance_mock = mocker.Mock() - api_instance_mock.list_indexes = mocker.Mock(side_effect=list_indexes_responses) - mocker.patch('pinecone.manage._get_api_instance', return_value=api_instance_mock) - mocker.patch('time.sleep') - - pinecone.manage.delete_index("my-index", timeout=timeout_value) - - pinecone.manage._get_api_instance.assert_called_once() - assert api_instance_mock.list_indexes.call_count == list_indexes_calls - assert time.sleep.call_count == time_sleep_calls \ No newline at end of file diff --git a/tests/unit/utils/test_convert_to_list.py b/tests/unit/utils/test_convert_to_list.py new file mode 100644 index 000000000..88efc0e3b --- /dev/null +++ b/tests/unit/utils/test_convert_to_list.py @@ -0,0 +1,38 @@ +import pytest +from pinecone.utils import convert_to_list +import numpy as np +import pandas as pd + +def test_convert_to_list_when_numpy_array(): + obj = np.array([1, 2, 3]) + actual = convert_to_list(obj) + expected = [1, 2, 3] + assert actual == expected + assert actual[0].__class__ == expected[0].__class__ + +def test_convert_to_list_when_pandas_array(): + obj = pd.array([1, 2, 3]) + actual = convert_to_list(obj) + expected = [1, 2, 3] + assert actual == expected + assert actual[0].__class__ == expected[0].__class__ + +def test_convert_to_list_when_pandas_float_array(): + obj = pd.array([0.1, 0.2, 0.3]) + actual = convert_to_list(obj) + expected = [0.1, 0.2, 0.3] + assert actual == expected + assert actual[0].__class__ == expected[0].__class__ + +def test_convert_to_list_when_pandas_series(): + obj = pd.Series([1, 2, 3]) + actual = convert_to_list(obj) + expected = [1, 2, 3] + assert actual == expected + assert actual[0].__class__ == expected[0].__class__ + +def test_convert_to_list_when_already_list(): + obj = [1, 2, 3] + actual = convert_to_list(obj) + expected = [1, 2, 3] + assert actual == expected diff --git a/tests/unit_grpc/test_grpc_index.py b/tests/unit_grpc/test_grpc_index.py new file mode 100644 index 000000000..b797fd26b --- /dev/null +++ b/tests/unit_grpc/test_grpc_index.py @@ -0,0 +1,694 @@ +from copy import deepcopy + +import numpy as np +import pandas as pd +import pytest + +from pinecone import Config +from pinecone.grpc import GRPCIndex +from pinecone import DescribeIndexStatsRequest +from pinecone.core.grpc.protos.vector_service_pb2 import ( + Vector, + DescribeIndexStatsRequest, + UpdateRequest, + UpsertRequest, + FetchRequest, + QueryRequest, + DeleteRequest, + QueryVector, + UpsertResponse, + SparseValues, +) +from pinecone.grpc.utils import dict_to_proto_struct + +class TestGrpcIndex: + def setup_method(self): + self.vector_dim = 8 + self.vals1 = [0.1] * self.vector_dim + self.vals2 = [0.2] * self.vector_dim + self.sparse_indices_1 = [1, 8, 42] + self.sparse_values_1 = [0.8, 0.9, 0.42] + self.sparse_indices_2 = [1, 3, 5] + self.sparse_values_2 = [0.7, 0.3, 0.31415] + self.md1 = {"genre": "action", "year": 2021} + self.md2 = {"genre": "documentary", "year": 2020} + self.filter1 = {"genre": {"$in": ["action"]}} + self.filter2 = {"year": {"$eq": 2020}} + + self.config = Config(api_key='test-api-key', host='foo') + self.index = GRPCIndex(config=self.config, index_name="example-name", _endpoint_override="test-endpoint") + + self.expected_vec1 = Vector(id="vec1", values=self.vals1, metadata={}) + self.expected_vec2 = Vector(id="vec2", values=self.vals2, metadata={}) + self.expected_vec_md1 = Vector(id="vec1", values=self.vals1, metadata=dict_to_proto_struct(self.md1)) + self.expected_vec_md2 = Vector(id="vec2", values=self.vals2, metadata=dict_to_proto_struct(self.md2)) + self.expected_vec_md_sparse1 = Vector( + id="vec1", + values=self.vals1, + metadata=dict_to_proto_struct(self.md1), + sparse_values=SparseValues(indices=self.sparse_indices_1, values=self.sparse_values_1), + ) + self.expected_vec_md_sparse2 = Vector( + id="vec2", + values=self.vals2, + metadata=dict_to_proto_struct(self.md2), + sparse_values=SparseValues(indices=self.sparse_indices_2, values=self.sparse_values_2), + ) + + # region: upsert tests + + def _assert_called_once(self, vectors, async_call=False): + self.index._wrap_grpc_call.assert_called_once_with( + self.index.stub.Upsert.future if async_call else self.index.stub.Upsert, + UpsertRequest(vectors=vectors, namespace="ns"), + timeout=None, + ) + + def test_upsert_tuplesOfIdVec_UpserWithoutMD(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + self.index.upsert([("vec1", self.vals1), ("vec2", self.vals2)], namespace="ns") + self._assert_called_once([self.expected_vec1, self.expected_vec2]) + + def test_upsert_tuplesOfIdVecMD_UpsertVectorsWithMD(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + self.index.upsert([("vec1", self.vals1, self.md1), ("vec2", self.vals2, self.md2)], namespace="ns") + self._assert_called_once( + [self.expected_vec_md1, self.expected_vec_md2], + ) + + def test_upsert_vectors_upsertInputVectors(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + self.index.upsert([self.expected_vec_md1, self.expected_vec_md2], namespace="ns") + self._assert_called_once( + [self.expected_vec_md1, self.expected_vec_md2], + ) + + def test_upsert_vectors_upsertInputVectorsSparse(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + self.index.upsert( + [ + Vector( + id="vec1", + values=self.vals1, + metadata=dict_to_proto_struct(self.md1), + sparse_values=SparseValues(indices=self.sparse_indices_1, values=self.sparse_values_1), + ), + Vector( + id="vec2", + values=self.vals2, + metadata=dict_to_proto_struct(self.md2), + sparse_values=SparseValues(indices=self.sparse_indices_2, values=self.sparse_values_2), + ), + ], + namespace="ns", + ) + self._assert_called_once([self.expected_vec_md_sparse1, self.expected_vec_md_sparse2]) + + def test_upsert_dict(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + dict1 = {"id": "vec1", "values": self.vals1} + dict2 = {"id": "vec2", "values": self.vals2} + self.index.upsert([dict1, dict2], namespace="ns") + self._assert_called_once([self.expected_vec1, self.expected_vec2]) + + def test_upsert_dict_md(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + dict1 = {"id": "vec1", "values": self.vals1, "metadata": self.md1} + dict2 = {"id": "vec2", "values": self.vals2, "metadata": self.md2} + self.index.upsert([dict1, dict2], namespace="ns") + self._assert_called_once([self.expected_vec_md1, self.expected_vec_md2]) + + def test_upsert_dict_sparse(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + dict1 = { + "id": "vec1", + "values": self.vals1, + "sparse_values": {"indices": self.sparse_indices_1, "values": self.sparse_values_1}, + } + dict2 = { + "id": "vec2", + "values": self.vals2, + "sparse_values": {"indices": self.sparse_indices_2, "values": self.sparse_values_2}, + } + self.index.upsert([dict1, dict2], namespace="ns") + self._assert_called_once( + [ + Vector( + id="vec1", + values=self.vals1, + metadata={}, + sparse_values=SparseValues(indices=self.sparse_indices_1, values=self.sparse_values_1), + ), + Vector( + id="vec2", + values=self.vals2, + metadata={}, + sparse_values=SparseValues(indices=self.sparse_indices_2, values=self.sparse_values_2), + ), + ] + ) + + def test_upsert_dict_sparse_md(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + dict1 = { + "id": "vec1", + "values": self.vals1, + "sparse_values": {"indices": self.sparse_indices_1, "values": self.sparse_values_1}, + "metadata": self.md1, + } + dict2 = { + "id": "vec2", + "values": self.vals2, + "sparse_values": {"indices": self.sparse_indices_2, "values": self.sparse_values_2}, + "metadata": self.md2, + } + self.index.upsert([dict1, dict2], namespace="ns") + self._assert_called_once( + [ + Vector( + id="vec1", + values=self.vals1, + metadata=dict_to_proto_struct(self.md1), + sparse_values=SparseValues(indices=self.sparse_indices_1, values=self.sparse_values_1), + ), + Vector( + id="vec2", + values=self.vals2, + metadata=dict_to_proto_struct(self.md2), + sparse_values=SparseValues(indices=self.sparse_indices_2, values=self.sparse_values_2), + ), + ] + ) + + def test_upsert_dict_negative(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + + # Missing required keys + dict1 = {"values": self.vals1} + dict2 = {"id": "vec2"} + with pytest.raises(ValueError): + self.index.upsert([dict1, dict2]) + with pytest.raises(ValueError): + self.index.upsert([dict1]) + with pytest.raises(ValueError): + self.index.upsert([dict2]) + + # Excess keys + dict1 = {"id": "vec1", "values": self.vals1} + dict2 = {"id": "vec2", "values": self.vals2, "animal": "dog"} + with pytest.raises(ValueError) as e: + self.index.upsert([dict1, dict2]) + assert "animal" in str(e.value) + + dict1 = {"id": "vec1", "values": self.vals1, "metadatta": self.md2} + dict2 = {"id": "vec2", "values": self.vals2} + with pytest.raises(ValueError) as e: + self.index.upsert([dict1, dict2]) + assert "metadatta" in str(e.value) + + @pytest.mark.parametrize( + "key,new_val", + [ + ("values", ["the", "lazy", "fox"]), + ("values", "the lazy fox"), + ("values", 0.5), + ("metadata", np.nan), + ("metadata", ["key1", "key2"]), + ("sparse_values", "cat"), + ("sparse_values", []), + ], + ) + def test_upsert_dict_with_invalid_values(self, mocker, key, new_val): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + + full_dict1 = { + "id": "vec1", + "values": self.vals1, + "sparse_values": {"indices": self.sparse_indices_1, "values": self.sparse_values_1}, + "metadata": self.md1, + } + + dict1 = deepcopy(full_dict1) + dict1[key] = new_val + with pytest.raises(TypeError) as e: + self.index.upsert([dict1]) + assert key in str(e.value) + + @pytest.mark.parametrize( + "key,new_val", + [ + ("id", 4.2), + ("id", ["vec1"]), + ], + ) + def test_upsert_dict_with_invalid_ids(self, mocker, key, new_val): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + + full_dict1 = { + "id": "vec1", + "values": self.vals1, + "sparse_values": {"indices": self.sparse_indices_1, "values": self.sparse_values_1}, + "metadata": self.md1, + } + + dict1 = deepcopy(full_dict1) + dict1[key] = new_val + with pytest.raises(TypeError) as e: + self.index.upsert([dict1]) + assert str(new_val) in str(e.value) + + @pytest.mark.parametrize( + "key,new_val", + [ + ("indices", 3), + ("indices", [1.2, 0.5]), + ("values", ["1", "4.4"]), + ("values", 0.5), + ], + ) + def test_upsert_dict_with_invalid_sparse_values(self, mocker, key, new_val): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + + full_dict1 = { + "id": "vec1", + "values": self.vals1, + "sparse_values": {"indices": self.sparse_indices_1, "values": self.sparse_values_1}, + "metadata": self.md1, + } + + dict1 = deepcopy(full_dict1) + dict1["sparse_values"][key] = new_val + with pytest.raises(TypeError) as e: + self.index.upsert([dict1]) + assert "sparse" in str(e.value) + assert key in str(e.value) + + def test_upsert_dataframe(self, mocker): + mocker.patch.object( + self.index, + "_wrap_grpc_call", + autospec=True, + side_effect=lambda stub, upsert_request, timeout: MockUpsertDelegate( + UpsertResponse(upserted_count=len(upsert_request.vectors)) + ), + ) + df = pd.DataFrame( + [ + { + "id": "vec1", + "values": self.vals1, + "sparse_values": {"indices": self.sparse_indices_1, "values": self.sparse_values_1}, + "metadata": self.md1, + }, + { + "id": "vec2", + "values": self.vals2, + "sparse_values": {"indices": self.sparse_indices_2, "values": self.sparse_values_2}, + "metadata": self.md2, + }, + ] + ) + self.index.upsert_from_dataframe(df, namespace="ns") + self._assert_called_once([self.expected_vec_md_sparse1, self.expected_vec_md_sparse2], async_call=True) + + def test_upsert_dataframe_sync(self, mocker): + mocker.patch.object( + self.index, + "_wrap_grpc_call", + autospec=True, + side_effect=lambda stub, upsert_request, timeout: UpsertResponse( + upserted_count=len(upsert_request.vectors) + ), + ) + df = pd.DataFrame( + [ + { + "id": "vec1", + "values": self.vals1, + "sparse_values": {"indices": self.sparse_indices_1, "values": self.sparse_values_1}, + "metadata": self.md1, + }, + { + "id": "vec2", + "values": self.vals2, + "sparse_values": {"indices": self.sparse_indices_2, "values": self.sparse_values_2}, + "metadata": self.md2, + }, + ] + ) + self.index.upsert_from_dataframe(df, namespace="ns", use_async_requests=False) + self._assert_called_once([self.expected_vec_md_sparse1, self.expected_vec_md_sparse2], async_call=False) + + def test_upsert_dataframe_negative(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + full_dict1 = { + "id": "vec1", + "values": self.vals1, + "sparse_values": {"indices": self.sparse_indices_1, "values": self.sparse_values_1}, + "metadata": self.md1, + } + full_df = pd.DataFrame([full_dict1]) + + # Not a DF + with pytest.raises(ValueError): + self.index.upsert_from_dataframe([full_dict1]) + with pytest.raises(ValueError): + self.index.upsert_from_dataframe(full_dict1) + + # Missing Cols + df = full_df.copy() + df.drop(columns=["id"], inplace=True) + with pytest.raises(ValueError): + self.index.upsert_from_dataframe(df) + + # Excess cols + df = full_df.copy() + df["animals"] = ["dog"] + with pytest.raises(ValueError): + self.index.upsert_from_dataframe(df) + + df = full_df.copy() + df["metadat"] = df["metadata"] + with pytest.raises(ValueError): + self.index.upsert_from_dataframe(df) + + def test_upsert_async_upsertInputVectorsAsync(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + self.index.upsert([self.expected_vec_md1, self.expected_vec_md2], namespace="ns", async_req=True) + self._assert_called_once([self.expected_vec_md1, self.expected_vec_md2], async_call=True) + + def test_upsert_vectorListIsMultiplyOfBatchSize_vectorsUpsertedInBatches(self, mocker): + mocker.patch.object( + self.index, + "_wrap_grpc_call", + autospec=True, + side_effect=lambda stub, upsert_request, timeout: UpsertResponse( + upserted_count=len(upsert_request.vectors) + ), + ) + + result = self.index.upsert( + [self.expected_vec_md1, self.expected_vec_md2], namespace="ns", batch_size=1, show_progress=False + ) + self.index._wrap_grpc_call.assert_any_call( + self.index.stub.Upsert, + UpsertRequest( + vectors=[Vector(id="vec1", values=self.vals1, metadata=dict_to_proto_struct(self.md1))], namespace="ns" + ), + timeout=None, + ) + + self.index._wrap_grpc_call.assert_any_call( + self.index.stub.Upsert, UpsertRequest(vectors=[self.expected_vec_md2], namespace="ns"), timeout=None + ) + + assert result.upserted_count == 2 + + def test_upsert_vectorListNotMultiplyOfBatchSize_vectorsUpsertedInBatches(self, mocker): + mocker.patch.object( + self.index, + "_wrap_grpc_call", + autospec=True, + side_effect=lambda stub, upsert_request, timeout: UpsertResponse( + upserted_count=len(upsert_request.vectors) + ), + ) + + result = self.index.upsert( + [ + self.expected_vec_md1, + Vector(id="vec2", values=self.vals2, metadata=dict_to_proto_struct(self.md2)), + Vector(id="vec3", values=self.vals1, metadata=dict_to_proto_struct(self.md1)), + ], + namespace="ns", + batch_size=2, + ) + self.index._wrap_grpc_call.assert_any_call( + self.index.stub.Upsert, + UpsertRequest(vectors=[self.expected_vec_md1, self.expected_vec_md2], namespace="ns"), + timeout=None, + ) + + self.index._wrap_grpc_call.assert_any_call( + self.index.stub.Upsert, + UpsertRequest( + vectors=[Vector(id="vec3", values=self.vals1, metadata=dict_to_proto_struct(self.md1))], namespace="ns" + ), + timeout=None, + ) + + assert result.upserted_count == 3 + + def test_upsert_vectorListSmallerThanBatchSize_vectorsUpsertedInBatches(self, mocker): + mocker.patch.object( + self.index, + "_wrap_grpc_call", + autospec=True, + side_effect=lambda stub, upsert_request, timeout: UpsertResponse( + upserted_count=len(upsert_request.vectors) + ), + ) + + result = self.index.upsert([self.expected_vec_md1, self.expected_vec_md2], namespace="ns", batch_size=5) + self._assert_called_once( + [self.expected_vec_md1, self.expected_vec_md2], + ) + + assert result.upserted_count == 2 + + def test_upsert_tuplesList_vectorsUpsertedInBatches(self, mocker): + mocker.patch.object( + self.index, + "_wrap_grpc_call", + autospec=True, + side_effect=lambda stub, upsert_request, timeout: UpsertResponse( + upserted_count=len(upsert_request.vectors) + ), + ) + + result = self.index.upsert( + [("vec1", self.vals1, self.md1), ("vec2", self.vals2, self.md2), ("vec3", self.vals1, self.md1)], + namespace="ns", + batch_size=2, + ) + self.index._wrap_grpc_call.assert_any_call( + self.index.stub.Upsert, + UpsertRequest(vectors=[self.expected_vec_md1, self.expected_vec_md2], namespace="ns"), + timeout=None, + ) + + self.index._wrap_grpc_call.assert_any_call( + self.index.stub.Upsert, + UpsertRequest( + vectors=[Vector(id="vec3", values=self.vals1, metadata=dict_to_proto_struct(self.md1))], namespace="ns" + ), + timeout=None, + ) + + assert result.upserted_count == 3 + + def test_upsert_batchSizeIsNotPositive_errorIsRaised(self): + with pytest.raises(ValueError, match="batch_size must be a positive integer"): + self.index.upsert( + [Vector(id="vec1", values=self.vals1, metadata=dict_to_proto_struct(self.md1))], + namespace="ns", + batch_size=0, + ) + + with pytest.raises(ValueError, match="batch_size must be a positive integer"): + self.index.upsert( + [Vector(id="vec1", values=self.vals1, metadata=dict_to_proto_struct(self.md1))], + namespace="ns", + batch_size=-1, + ) + + def test_upsert_useBatchSizeAndAsyncReq_valueErrorRaised(self): + with pytest.raises(ValueError, match="async_req is not supported when batch_size is provided."): + self.index.upsert( + [Vector(id="vec1", values=self.vals1, metadata=dict_to_proto_struct(self.md1))], + namespace="ns", + batch_size=2, + async_req=True, + ) + + # endregion + + # region: query tests + + def test_query_byVectorNoFilter_queryVectorNoFilter(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + self.index.query(top_k=10, vector=self.vals1) + self.index._wrap_grpc_call.assert_called_once_with( + self.index.stub.Query, + QueryRequest(top_k=10, vector=self.vals1), + timeout=None, + ) + + def test_query_byVectorWithFilter_queryVectorWithFilter(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + self.index.query(top_k=10, vector=self.vals1, filter=self.filter1, namespace="ns", timeout=10) + self.index._wrap_grpc_call.assert_called_once_with( + self.index.stub.Query, + QueryRequest(top_k=10, vector=self.vals1, filter=dict_to_proto_struct(self.filter1), namespace="ns"), + timeout=10, + ) + + def test_query_byTuplesNoFilter_queryVectorsNoFilter(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + self.index.query(top_k=10, queries=[(self.vals1,), (self.vals2,)]) + self.index._wrap_grpc_call.assert_called_once_with( + self.index.stub.Query, + QueryRequest( + queries=[QueryVector(values=self.vals1, filter={}), QueryVector(values=self.vals2, filter={})], top_k=10 + ), + timeout=None, + ) + + def test_query_byTuplesWithFilter_queryVectorsWithFilter(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + self.index.query(top_k=10, queries=[(self.vals1, self.filter1), (self.vals2, self.filter2)]) + self.index._wrap_grpc_call.assert_called_once_with( + self.index.stub.Query, + QueryRequest( + queries=[ + QueryVector(values=self.vals1, filter=dict_to_proto_struct(self.filter1)), + QueryVector(values=self.vals2, filter=dict_to_proto_struct(self.filter2)), + ], + top_k=10, + ), + timeout=None, + ) + + def test_query_byVecId_queryByVecId(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + self.index.query(top_k=10, id="vec1", include_metadata=True, include_values=False) + self.index._wrap_grpc_call.assert_called_once_with( + self.index.stub.Query, + QueryRequest(top_k=10, id="vec1", include_metadata=True, include_values=False), + timeout=None, + ) + + # endregion + + # region: delete tests + + def test_delete_byIds_deleteByIds(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + self.index.delete(ids=["vec1", "vec2"]) + self.index._wrap_grpc_call.assert_called_once_with( + self.index.stub.Delete, + DeleteRequest(ids=["vec1", "vec2"]), + timeout=None, + ) + + def test_delete_byIdsAsync_deleteByIdsAsync(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + self.index.delete(ids=["vec1", "vec2"], async_req=True) + self.index._wrap_grpc_call.assert_called_once_with( + self.index.stub.Delete.future, + DeleteRequest(ids=["vec1", "vec2"]), + timeout=None, + ) + + def test_delete_deleteAllByFilter_deleteAllByFilter(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + self.index.delete(delete_all=True, filter=self.filter1, namespace="ns", timeout=30) + self.index._wrap_grpc_call.assert_called_once_with( + self.index.stub.Delete, + DeleteRequest(delete_all=True, filter=dict_to_proto_struct(self.filter1), namespace="ns"), + timeout=30, + ) + + def test_delete_deleteAllNoFilter_deleteNoFilter(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + self.index.delete(delete_all=True) + self.index._wrap_grpc_call.assert_called_once_with( + self.index.stub.Delete, + DeleteRequest(delete_all=True), + timeout=None, + ) + + # endregion + + # region: fetch tests + + def test_fetch_byIds_fetchByIds(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + self.index.fetch(["vec1", "vec2"]) + self.index._wrap_grpc_call.assert_called_once_with( + self.index.stub.Fetch, + FetchRequest(ids=["vec1", "vec2"]), + timeout=None, + ) + + def test_fetch_byIdsAndNS_fetchByIdsAndNS(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + self.index.fetch(["vec1", "vec2"], namespace="ns", timeout=30) + self.index._wrap_grpc_call.assert_called_once_with( + self.index.stub.Fetch, + FetchRequest(ids=["vec1", "vec2"], namespace="ns"), + timeout=30, + ) + + # endregion + + # region: update tests + + def test_update_byIdAnValues_updateByIdAndValues(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + self.index.update(id="vec1", values=self.vals1, namespace="ns", timeout=30) + self.index._wrap_grpc_call.assert_called_once_with( + self.index.stub.Update, + UpdateRequest(id="vec1", values=self.vals1, namespace="ns"), + timeout=30, + ) + + def test_update_byIdAnValuesAsync_updateByIdAndValuesAsync(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + self.index.update(id="vec1", values=self.vals1, namespace="ns", timeout=30, async_req=True) + self.index._wrap_grpc_call.assert_called_once_with( + self.index.stub.Update.future, + UpdateRequest(id="vec1", values=self.vals1, namespace="ns"), + timeout=30, + ) + + def test_update_byIdAnValuesAndMetadata_updateByIdAndValuesAndMetadata(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + self.index.update("vec1", values=self.vals1, set_metadata=self.md1) + self.index._wrap_grpc_call.assert_called_once_with( + self.index.stub.Update, + UpdateRequest(id="vec1", values=self.vals1, set_metadata=dict_to_proto_struct(self.md1)), + timeout=None, + ) + + # endregion + + # region: describe index tests + + def test_describeIndexStats_callWithoutFilter_CalledWithoutFilter(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + self.index.describe_index_stats() + self.index._wrap_grpc_call.assert_called_once_with( + self.index.stub.DescribeIndexStats, + DescribeIndexStatsRequest(), + timeout=None, + ) + + def test_describeIndexStats_callWithFilter_CalledWithFilter(self, mocker): + mocker.patch.object(self.index, "_wrap_grpc_call", autospec=True) + self.index.describe_index_stats(filter=self.filter1) + self.index._wrap_grpc_call.assert_called_once_with( + self.index.stub.DescribeIndexStats, + DescribeIndexStatsRequest(filter=dict_to_proto_struct(self.filter1)), + timeout=None, + ) + + # endregion + + +class MockUpsertDelegate: + def __init__(self, upsert_response: UpsertResponse): + self.response = upsert_response + + def result(self, timeout): + return self.response