Skip to content

Commit

Permalink
Merge pull request #41 from pinecone-io/sc-9584
Browse files Browse the repository at this point in the history
Remove sentry from python client
  • Loading branch information
rajat08 authored Mar 8, 2022
2 parents cef6034 + 89d9109 commit 169657e
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 93 deletions.
13 changes: 0 additions & 13 deletions pinecone/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,12 @@

import certifi
import requests
import sentry_sdk
import configparser

from pinecone.core.client.exceptions import ApiKeyError
from pinecone.core.api_action import ActionAPI, WhoAmIResponse
from pinecone.core.utils import warn_deprecated
from pinecone.core.utils.constants import CLIENT_VERSION, PARENT_LOGGER_NAME, DEFAULT_PARENT_LOGGER_LEVEL
from pinecone.core.utils.sentry import sentry_decorator as sentry
from pinecone.core.client.configuration import Configuration as OpenApiConfiguration

__all__ = [
Expand All @@ -26,14 +24,6 @@
_parent_logger.setLevel(DEFAULT_PARENT_LOGGER_LEVEL)


def _set_sentry_tags(config: dict):
sentry_sdk.set_tag("package_version", CLIENT_VERSION)
sentry_tag_names = ('environment', 'project_name', 'controller_host', 'username', 'user_label')
for key, val in config.items():
if key in sentry_tag_names:
sentry_sdk.set_tag(key, val)


class ConfigBase(NamedTuple):
environment: str = ""
api_key: str = ""
Expand Down Expand Up @@ -122,8 +112,6 @@ def reset(self, config_file=None, **kwargs):
config = config._replace(openapi_config=openapi_config)
self._config = config

# Sentry
_set_sentry_tags({**whoami_response._asdict(), **self._config._asdict()})

def _preprocess_and_validate_config(self, config: dict) -> dict:
"""Normalize, filter, and validate config keys/values.
Expand Down Expand Up @@ -189,7 +177,6 @@ def LOG_LEVEL(self):
return logging.getLevelName(logging.getLogger('pinecone').level)


@sentry
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):
Expand Down
8 changes: 0 additions & 8 deletions pinecone/core/grpc/index_grpc.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
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.core.utils.sentry import sentry_decorator as sentry
from pinecone.exceptions import PineconeException

__all__ = ["GRPCIndex", "GRPCVector", "GRPCQueryVector"]
Expand Down Expand Up @@ -127,7 +126,6 @@ def grpc_server_on(self) -> bool:
except grpc.FutureTimeoutError:
return False

@sentry
def close(self):
"""Closes the connection to the index."""
try:
Expand All @@ -137,7 +135,6 @@ def close(self):

def _wrap_grpc_call(self, func, request, timeout=None, metadata=None, credentials=None, wait_for_ready=None,
compression=None):
@sentry
@wraps(func)
def wrapped():
user_provided_metadata = metadata or {}
Expand Down Expand Up @@ -244,7 +241,6 @@ class GRPCIndex(GRPCIndexBase):
def stub_class(self):
return VectorServiceStub

@sentry
def upsert(self, vectors, async_req=False, **kwargs):
def _vector_transform(item):
if isinstance(item, GRPCVector):
Expand All @@ -262,7 +258,6 @@ def _vector_transform(item):
else:
return self._wrap_grpc_call(self.stub.Upsert, request, timeout=timeout)

@sentry
def delete(self, *args, async_req=False, **kwargs):
request = DeleteRequest(*args, **kwargs)
timeout = kwargs.pop('timeout', None)
Expand All @@ -272,15 +267,13 @@ def delete(self, *args, async_req=False, **kwargs):
else:
return self._wrap_grpc_call(self.stub.Delete, request, timeout=timeout)

@sentry
def fetch(self, *args, **kwargs):
timeout = kwargs.pop('timeout', None)
request = FetchRequest(*args, **kwargs)
response = self._wrap_grpc_call(self.stub.Fetch, request, timeout=timeout)
json_response = json_format.MessageToDict(response)
return parse_fetch_response(json_response)

@sentry
def query(self, queries, **kwargs):
timeout = kwargs.pop('timeout', None)

Expand All @@ -304,7 +297,6 @@ def _query_transform(item):
json_response = json_format.MessageToDict(response)
return parse_query_response(json_response)

@sentry
def describe_index_stats(self, **kwargs):
timeout = kwargs.pop('timeout', None)
request = DescribeIndexStatsRequest()
Expand Down
1 change: 0 additions & 1 deletion pinecone/core/utils/constants.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,5 @@ class NodeType(str, enum.Enum):


PACKAGE_ENVIRONMENT = get_environment() or "development"
SENTRY_DSN_TXT_RECORD = "pinecone-client.sentry.pinecone.io"
CLIENT_VERSION = get_version()
CLIENT_ID = f'python-client-{CLIENT_VERSION}'
54 changes: 0 additions & 54 deletions pinecone/core/utils/sentry.py

This file was deleted.

6 changes: 0 additions & 6 deletions pinecone/index.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

from pinecone import Config
from pinecone.core.client import ApiClient, Configuration
from pinecone.core.utils.sentry import sentry_decorator as sentry
from .core.client.models import FetchResponse, ProtobufAny, QueryRequest, QueryResponse, QueryVector, RpcStatus, \
ScoredVector, SingleQueryResults, DescribeIndexStatsResponse, UpsertRequest, UpsertResponse, Vector
from pinecone.core.client.api.vector_operations_api import VectorOperationsApi
Expand Down Expand Up @@ -45,7 +44,6 @@ def __init__(self, index_name: str, pool_threads=1):
self.user_agent = get_user_agent()
self._vector_api = VectorOperationsApi(self)

@sentry
@validate_and_convert_errors
def upsert(self, vectors, **kwargs):
_check_type = kwargs.pop('_check_type', False)
Expand All @@ -67,17 +65,14 @@ def _vector_transform(item):
**{k: v for k, v in kwargs.items() if k in _OPENAPI_ENDPOINT_PARAMS}
)

@sentry
@validate_and_convert_errors
def delete(self, *args, **kwargs):
return self._vector_api.delete(*args, **kwargs)

@sentry
@validate_and_convert_errors
def fetch(self, *args, **kwargs):
return self._vector_api.fetch(*args, **kwargs)

@sentry
@validate_and_convert_errors
def query(self, queries, **kwargs):
_check_type = kwargs.pop('_check_type', False)
Expand All @@ -101,7 +96,6 @@ def _query_transform(item):
**{k: v for k, v in kwargs.items() if k in _OPENAPI_ENDPOINT_PARAMS}
)

@sentry
@validate_and_convert_errors
def describe_index_stats(self, *args, **kwargs):
return self._vector_api.describe_index_stats(*args, **kwargs)
4 changes: 0 additions & 4 deletions pinecone/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
# Copyright (c) 2020-2021 Pinecone Systems Inc. All right reserved.
#

from pinecone.core.utils.sentry import sentry_decorator as sentry
from pinecone.core.api_action import ActionAPI, VersionResponse, WhoAmIResponse
from pinecone.config import Config

Expand All @@ -16,21 +15,18 @@ def _get_action_api():
return ActionAPI(host=Config.CONTROLLER_HOST, api_key=Config.API_KEY)


@sentry
def version() -> VersionResponse:
"""Returns version information (client and server)."""
api = _get_action_api()
return api.version()


@sentry
def whoami() -> WhoAmIResponse:
"""Returns the details of the currently authenticated API key."""
api = _get_action_api()
return api.whoami()


@sentry
def wait_controller_ready(timeout: int = 30):
connection = False
max_time = time.time() + timeout
Expand Down
6 changes: 0 additions & 6 deletions pinecone/manage.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
from pinecone.core.client.configuration import Configuration
from pinecone.core.client.model.create_request import CreateRequest
from pinecone.core.client.model.patch_request import PatchRequest
from pinecone.core.utils.sentry import sentry_decorator as sentry
from pinecone.core.utils import get_user_agent

__all__ = [
Expand Down Expand Up @@ -55,7 +54,6 @@ def _get_status(name: str):
return response['status']


@sentry
def create_index(
name: str,
dimension: int,
Expand Down Expand Up @@ -132,7 +130,6 @@ def is_ready():
'https://www.pinecone.io/docs/api/operation/describe_index/')))


@sentry
def delete_index(name: str, timeout: int = None):
"""Deletes a Pinecone index.
Expand Down Expand Up @@ -163,15 +160,13 @@ def get_remaining():
'https://www.pinecone.io/docs/api/operation/list_indexes/')))


@sentry
def list_indexes():
"""Lists all indexes."""
api_instance = _get_api_instance()
response = api_instance.list_indexes()
return response


@sentry
def describe_index(name: str):
"""Describes a Pinecone index.
Expand All @@ -188,7 +183,6 @@ def describe_index(name: str):
index_config=db['index_config'], status={'ready': ready})


@sentry
def scale_index(name: str, replicas: int):
"""Increases number of replicas for the index.
Expand Down
1 change: 0 additions & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ requests>=2.19.0
pyyaml>=5.4
loguru>=0.5.0
typing-extensions>=3.7.4
sentry-sdk>=1.0.0
dnspython>=2.0.0
# openapi generated client:
python_dateutil >= 2.5.3
Expand Down

0 comments on commit 169657e

Please sign in to comment.