Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 0 additions & 1 deletion pinecone/config/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
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

Expand Down
3 changes: 2 additions & 1 deletion pinecone/control/index_host_store.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from typing import Dict
from pinecone.config import Config
from pinecone.core.client.api.manage_pod_indexes_api import ManagePodIndexesApi as IndexOperationsApi
from pinecone.core.client.exceptions import PineconeException

class SingletonMeta(type):
_instances: Dict[str, str] = {}
Expand Down Expand Up @@ -40,5 +41,5 @@ def get_host(self, api: IndexOperationsApi, config: Config, index_name: str) ->
description = api.describe_index(index_name)
self.set_host(config, index_name, description.host)
if not self.key_exists(key):
raise Exception(f"Could not get host for index: {index_name}. Call describe_index('{index_name}') to check the current status.")
raise PineconeException(f"Could not get host for index: {index_name}. Call describe_index('{index_name}') to check the current status.")
return self._indexHosts[key]
12 changes: 6 additions & 6 deletions pinecone/core/client/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,9 @@
from pinecone.core.client.configuration import Configuration

# import exceptions
from pinecone.core.client.exceptions import OpenApiException
from pinecone.core.client.exceptions import ApiAttributeError
from pinecone.core.client.exceptions import ApiTypeError
from pinecone.core.client.exceptions import ApiValueError
from pinecone.core.client.exceptions import ApiKeyError
from pinecone.core.client.exceptions import ApiException
from pinecone.core.client.exceptions import PineconeException
from pinecone.core.client.exceptions import PineconeApiAttributeError
from pinecone.core.client.exceptions import PineconeApiTypeError
from pinecone.core.client.exceptions import PineconeApiValueError
from pinecone.core.client.exceptions import PineconeApiKeyError
from pinecone.core.client.exceptions import PineconeApiException
22 changes: 11 additions & 11 deletions pinecone/core/client/api_client.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@

from pinecone.core.client import rest
from pinecone.core.client.configuration import Configuration
from pinecone.core.client.exceptions import ApiTypeError, ApiValueError, ApiException
from pinecone.core.client.exceptions import PineconeApiTypeError, PineconeApiValueError, PineconeApiException
from pinecone.core.client.model_utils import (
ModelNormal,
ModelSimple,
Expand Down Expand Up @@ -197,7 +197,7 @@ def __call_api(
post_params=post_params, body=body,
_preload_content=_preload_content,
_request_timeout=_request_timeout)
except ApiException as e:
except PineconeApiException as e:
e.body = e.body.decode('utf-8')
raise e

Expand Down Expand Up @@ -284,7 +284,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 PineconeApiValueError('Unable to prepare type {} for serialization'.format(obj.__class__.__name__))

def deserialize(self, response, response_type, _check_type):
"""Deserializes response into an object.
Expand Down Expand Up @@ -482,7 +482,7 @@ def request(self, method, url, query_params=None, headers=None,
_request_timeout=_request_timeout,
body=body)
else:
raise ApiValueError(
raise PineconeApiValueError(
"http method must be `GET`, `HEAD`, `OPTIONS`,"
" `POST`, `PATCH`, `PUT` or `DELETE`."
)
Expand Down Expand Up @@ -543,7 +543,7 @@ def files_parameters(self, files: typing.Optional[typing.Dict[str, typing.List[i
# if the file field is nullable, skip None values
continue
if file_instance.closed is True:
raise ApiValueError(
raise PineconeApiValueError(
"Cannot read a closed file. The passed in file_type "
"for %s must be open." % param_name
)
Expand Down Expand Up @@ -614,7 +614,7 @@ def update_params_for_auth(self, headers, querys, auth_settings,
elif auth_setting['in'] == 'query':
querys.append((auth_setting['key'], auth_setting['value']))
else:
raise ApiValueError(
raise PineconeApiValueError(
'Authentication token must be in `query` or `header`'
)

Expand Down Expand Up @@ -784,33 +784,33 @@ def call_with_http_info(self, **kwargs):
)
except IndexError:
if self.settings['servers']:
raise ApiValueError(
raise PineconeApiValueError(
"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']:
raise ApiTypeError(
raise PineconeApiTypeError(
"Got an unexpected parameter '%s'"
" to method `%s`" %
(key, self.settings['operation_id'])
)
# only throw this nullable ApiValueError if _check_input_type
# only throw this nullable PineconeApiValueError 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):
raise ApiValueError(
raise PineconeApiValueError(
"Value may not be None for non-nullable parameter `%s`"
" when calling `%s`" %
(key, self.settings['operation_id'])
)

for key in self.params_map['required']:
if key not in kwargs.keys():
raise ApiValueError(
raise PineconeApiValueError(
"Missing the required parameter `%s` when calling "
"`%s`" % (key, self.settings['operation_id'])
)
Expand Down
4 changes: 2 additions & 2 deletions pinecone/core/client/configuration.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
import urllib3

from http import client as http_client
from pinecone.core.client.exceptions import ApiValueError
from pinecone.core.client.exceptions import PineconeApiValueError


JSON_SCHEMA_VALIDATION_KEYWORDS = {
Expand Down Expand Up @@ -234,7 +234,7 @@ def __setattr__(self, name, value):
s = set(filter(None, value.split(',')))
for v in s:
if v not in JSON_SCHEMA_VALIDATION_KEYWORDS:
raise ApiValueError(
raise PineconeApiValueError(
"Invalid keyword: '{0}''".format(v))
self._disabled_client_side_validations = s

Expand Down
30 changes: 15 additions & 15 deletions pinecone/core/client/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,11 @@



class OpenApiException(Exception):
"""The base exception class for all OpenAPIExceptions"""
class PineconeException(Exception):
"""The base exception class for all exceptions in the Pinecone Python SDK"""


class ApiTypeError(OpenApiException, TypeError):
class PineconeApiTypeError(PineconeException, TypeError):
def __init__(self, msg, path_to_item=None, valid_classes=None,
key_type=None):
""" Raises an exception for TypeErrors
Expand All @@ -39,10 +39,10 @@ def __init__(self, msg, path_to_item=None, valid_classes=None,
full_msg = msg
if path_to_item:
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
super(ApiTypeError, self).__init__(full_msg)
super(PineconeApiTypeError, self).__init__(full_msg)


class ApiValueError(OpenApiException, ValueError):
class PineconeApiValueError(PineconeException, ValueError):
def __init__(self, msg, path_to_item=None):
"""
Args:
Expand All @@ -57,10 +57,10 @@ def __init__(self, msg, path_to_item=None):
full_msg = msg
if path_to_item:
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
super(ApiValueError, self).__init__(full_msg)
super(PineconeApiValueError, self).__init__(full_msg)


class ApiAttributeError(OpenApiException, AttributeError):
class PineconeApiAttributeError(PineconeException, AttributeError):
def __init__(self, msg, path_to_item=None):
"""
Raised when an attribute reference or assignment fails.
Expand All @@ -76,10 +76,10 @@ def __init__(self, msg, path_to_item=None):
full_msg = msg
if path_to_item:
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
super(ApiAttributeError, self).__init__(full_msg)
super(PineconeApiAttributeError, self).__init__(full_msg)


class ApiKeyError(OpenApiException, KeyError):
class PineconeApiKeyError(PineconeException, KeyError):
def __init__(self, msg, path_to_item=None):
"""
Args:
Expand All @@ -93,10 +93,10 @@ def __init__(self, msg, path_to_item=None):
full_msg = msg
if path_to_item:
full_msg = "{0} at {1}".format(msg, render_path(path_to_item))
super(ApiKeyError, self).__init__(full_msg)
super(PineconeApiKeyError, self).__init__(full_msg)


class ApiException(OpenApiException):
class PineconeApiException(PineconeException):

def __init__(self, status=None, reason=None, http_resp=None):
if http_resp:
Expand Down Expand Up @@ -124,25 +124,25 @@ def __str__(self):
return error_message


class NotFoundException(ApiException):
class NotFoundException(PineconeApiException):

def __init__(self, status=None, reason=None, http_resp=None):
super(NotFoundException, self).__init__(status, reason, http_resp)


class UnauthorizedException(ApiException):
class UnauthorizedException(PineconeApiException):

def __init__(self, status=None, reason=None, http_resp=None):
super(UnauthorizedException, self).__init__(status, reason, http_resp)


class ForbiddenException(ApiException):
class ForbiddenException(PineconeApiException):

def __init__(self, status=None, reason=None, http_resp=None):
super(ForbiddenException, self).__init__(status, reason, http_resp)


class ServiceException(ApiException):
class ServiceException(PineconeApiException):

def __init__(self, status=None, reason=None, http_resp=None):
super(ServiceException, self).__init__(status, reason, http_resp)
Expand Down
16 changes: 8 additions & 8 deletions pinecone/core/client/model/aws_regions.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import sys # noqa: F401

from pinecone.core.client.model_utils import ( # noqa: F401
ApiTypeError,
PineconeApiTypeError,
ModelComposed,
ModelNormal,
ModelSimple,
Expand All @@ -26,7 +26,7 @@
validate_get_composed_info,
)
from ..model_utils import OpenApiModel
from pinecone.core.client.exceptions import ApiAttributeError
from pinecone.core.client.exceptions import PineconeApiAttributeError



Expand Down Expand Up @@ -156,7 +156,7 @@ def __init__(self, *args, **kwargs):
args = list(args)
value = args.pop(0)
else:
raise ApiTypeError(
raise PineconeApiTypeError(
"value is required, but not passed in args or kwargs and doesn't have default",
path_to_item=_path_to_item,
valid_classes=(self.__class__,),
Expand All @@ -168,7 +168,7 @@ def __init__(self, *args, **kwargs):
_visited_composed_classes = kwargs.pop('_visited_composed_classes', ())

if args:
raise ApiTypeError(
raise PineconeApiTypeError(
"Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % (
args,
self.__class__.__name__,
Expand All @@ -185,7 +185,7 @@ def __init__(self, *args, **kwargs):
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)
self.value = value
if kwargs:
raise ApiTypeError(
raise PineconeApiTypeError(
"Invalid named arguments=%s passed to %s. Remove those invalid named arguments." % (
kwargs,
self.__class__.__name__,
Expand Down Expand Up @@ -248,7 +248,7 @@ def _from_openapi_data(cls, *args, **kwargs):
args = list(args)
value = args.pop(0)
else:
raise ApiTypeError(
raise PineconeApiTypeError(
"value is required, but not passed in args or kwargs and doesn't have default",
path_to_item=_path_to_item,
valid_classes=(self.__class__,),
Expand All @@ -260,7 +260,7 @@ def _from_openapi_data(cls, *args, **kwargs):
_visited_composed_classes = kwargs.pop('_visited_composed_classes', ())

if args:
raise ApiTypeError(
raise PineconeApiTypeError(
"Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % (
args,
self.__class__.__name__,
Expand All @@ -277,7 +277,7 @@ def _from_openapi_data(cls, *args, **kwargs):
self._visited_composed_classes = _visited_composed_classes + (self.__class__,)
self.value = value
if kwargs:
raise ApiTypeError(
raise PineconeApiTypeError(
"Invalid named arguments=%s passed to %s. Remove those invalid named arguments." % (
kwargs,
self.__class__.__name__,
Expand Down
10 changes: 5 additions & 5 deletions pinecone/core/client/model/collection_list.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import sys # noqa: F401

from pinecone.core.client.model_utils import ( # noqa: F401
ApiTypeError,
PineconeApiTypeError,
ModelComposed,
ModelNormal,
ModelSimple,
Expand All @@ -26,7 +26,7 @@
validate_get_composed_info,
)
from ..model_utils import OpenApiModel
from pinecone.core.client.exceptions import ApiAttributeError
from pinecone.core.client.exceptions import PineconeApiAttributeError


def lazy_import():
Expand Down Expand Up @@ -152,7 +152,7 @@ def _from_openapi_data(cls, *args, **kwargs): # noqa: E501
self = super(OpenApiModel, cls).__new__(cls)

if args:
raise ApiTypeError(
raise PineconeApiTypeError(
"Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % (
args,
self.__class__.__name__,
Expand Down Expand Up @@ -232,7 +232,7 @@ def __init__(self, *args, **kwargs): # noqa: E501
_visited_composed_classes = kwargs.pop('_visited_composed_classes', ())

if args:
raise ApiTypeError(
raise PineconeApiTypeError(
"Invalid positional arguments=%s passed to %s. Remove those invalid positional arguments." % (
args,
self.__class__.__name__,
Expand All @@ -257,5 +257,5 @@ def __init__(self, *args, **kwargs): # noqa: E501
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 "
raise PineconeApiAttributeError(f"`{var_name}` is a read-only attribute. Use `from_openapi_data` to instantiate "
f"class with read only attributes.")
Loading