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
3 changes: 2 additions & 1 deletion pinecone/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@

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 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
Expand Down Expand Up @@ -245,6 +245,7 @@ def init(api_key: str = None, host: str = None, environment: str = None, project
: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:
Expand Down
8 changes: 8 additions & 0 deletions pinecone/core/utils/__init__.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,8 @@
#
# Copyright (c) 2020-2021 Pinecone Systems Inc. All right reserved.
#
import inspect
import logging
import re
import uuid
import warnings
Expand Down Expand Up @@ -109,3 +111,9 @@ def load_strings_public(proto_arr: 'vector_column_service_pb2.NdArray') -> List[
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)
4 changes: 4 additions & 0 deletions tests/unit/test_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,10 @@ def test_init_with_kwargs():
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'
Expand Down