Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
0cc5208
[config] Added TCP Keep Alive mechanism
igiloh-pinecone Dec 21, 2022
53ec474
[config] Use default KeepAlive params on windows
igiloh-pinecone Dec 22, 2022
f94ec4a
add args for rest index
acatav Dec 22, 2022
21b8fdd
add args to grpc index
acatav Dec 22, 2022
6a16e1f
add docstring to index
acatav Dec 22, 2022
9712502
add docstring to grpc index
acatav Dec 22, 2022
87a1e56
Merge branch 'main' of github.com:pinecone-io/pinecone-python-client …
acatav Dec 22, 2022
48f8a58
Merge remote-tracking branch 'origin/main' into fix_connection_reset
igiloh-pinecone Dec 22, 2022
f033db5
move unit tests to a class
acatav Dec 25, 2022
b1ef695
Merge pull request #117 from pinecone-io/main
acatav Dec 25, 2022
dfd52ae
add unit tests to all rest methods
acatav Dec 25, 2022
8e28b71
add unit test for grpc index
acatav Dec 25, 2022
6010051
add grpc to test env
acatav Dec 25, 2022
10fb42c
temp try
acatav Dec 25, 2022
1cad605
Merge branch 'dev' of github.com:pinecone-io/pinecone-python-client i…
acatav Dec 27, 2022
8227b17
PR review changes for docstring
acatav Dec 27, 2022
5398ecf
Merge pull request #114 from pinecone-io/fix_connection_reset
igiloh-pinecone Dec 28, 2022
1238209
detalied md types
acatav Dec 28, 2022
bc9a115
Merge branch 'refactor-dense-api-args' of github.com:pinecone-io/pine…
acatav Dec 28, 2022
cd326b5
[grpc] Use _check_type=False in GRPCIndex.query()
igiloh-pinecone Dec 28, 2022
e3cc60b
[grpc] Make _check_type=Flase hardcoded
igiloh-pinecone Dec 28, 2022
1978204
implement batching
acatav Dec 28, 2022
1949322
use dict instead of Dict
acatav Dec 28, 2022
ea057f7
rename
acatav Dec 28, 2022
6811fa1
cover parse query in tests
acatav Dec 29, 2022
0d019e0
test and doc parallel upserts
acatav Dec 29, 2022
648a547
rename parse args
acatav Dec 29, 2022
83b1df4
Merge pull request #116 from pinecone-io/refactor-dense-api-args
acatav Dec 29, 2022
1ba6dc0
Merge branch 'dev' of github.com:pinecone-io/pinecone-python-client i…
acatav Dec 29, 2022
534812d
add tests and impel for grpc index
acatav Dec 29, 2022
0451234
Merge remote-tracking branch 'origin/dev' into fix_parse_query
igiloh-pinecone Jan 1, 2023
2588016
Merge pull request #118 from pinecone-io/fix_parse_query
igiloh-pinecone Jan 1, 2023
f82f5e8
remove redundant code
acatav Jan 1, 2023
fc51ba2
Merge pull request #119 from pinecone-io/batch-upsert
miararoy Jan 1, 2023
b85cdfc
v2.1.0 change version and changlog
acatav Jan 1, 2023
b627cc3
typo
acatav Jan 2, 2023
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
13 changes: 10 additions & 3 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,22 +2,29 @@

## Unreleased Changes
None
## [2.1.0](https://github.com/pinecone-io/pinecone-python-client/compare/v2.0.13...v2.1.0)
- Fix "Connection Reset by peer" error after long idle periods
- Add typing and explicit names for arguments in all client operations
- Add docstrings to all client operations
- Support batch upsert by passing `batch_size` to `upsert` method
- Improve gRPC query results parsing performance

## [2.0.13](https://github.com/pinecone-io/pinecone-python-client/compare/v2.0.13...v2.0.12)

## [2.0.13](https://github.com/pinecone-io/pinecone-python-client/compare/v2.0.12...v2.0.13)
- Added support for collections
- Users can manage collections using ``create_collection`` , ``describe_collection`` and ``delete_collection`` calls.
- Users can specify additional ``source_collection`` parameter during index creation to create index from a collection
- The ```scale_index``` call is now deprecated in favor of ```configure_index``` , users can now modify both ``pod_type`` and ```replicas``` on existing indexes.
- Added support for vertical scaling. This can be done by changing ```pod_type ``` via the ```configure_index``` call or during index creation.
- Updated dependency requirements for grpc client.

## [2.0.12](https://github.com/pinecone-io/pinecone-python-client/compare/v2.0.12...v2.0.11)
## [2.0.12](https://github.com/pinecone-io/pinecone-python-client/compare/v2.0.11...v2.0.12)

- Changed grpcio verison to be > 1.44.1
- Sanitized repo by removing leftover files from old versions.
- Added more info to ```describe_index_stats``` call. The call now gives a namespace wise vector count breakdown.

## [2.0.11](https://github.com/pinecone-io/pinecone-python-client/compare/v2.0.11...v2.0.10)
## [2.0.11](https://github.com/pinecone-io/pinecone-python-client/compare/v2.0.10...v2.0.11)
### Changed
- Added support of querying by a single vector.
- This is a step in deprecating batch queries.
Expand Down
2 changes: 1 addition & 1 deletion pinecone/__version__
Original file line number Diff line number Diff line change
@@ -1 +1 @@
2.0.13
2.1.0
61 changes: 58 additions & 3 deletions pinecone/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,22 @@
# Copyright (c) 2020-2021 Pinecone Systems Inc. All right reserved.
#
import logging
from typing import NamedTuple
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
from pinecone.core.utils.constants import CLIENT_VERSION, PARENT_LOGGER_NAME, DEFAULT_PARENT_LOGGER_LEVEL
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__ = [
Expand All @@ -37,7 +42,7 @@ class _CONFIG:

Order of configs to load:

- configs specified explictly in reset
- configs specified explicitly in reset
- environment variables
- configs specified in the INI file
- default configs
Expand Down Expand Up @@ -109,6 +114,8 @@ def reset(self, config_file=None, **kwargs):
or default_openapi_config
)

openapi_config.socket_options = self._get_socket_options()

config = config._replace(openapi_config=openapi_config)
self._config = config

Expand Down Expand Up @@ -144,6 +151,54 @@ def _load_config_file(self, config_file: str) -> dict:
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
Expand Down
2 changes: 1 addition & 1 deletion pinecone/core/client/model/query_request.py
Original file line number Diff line number Diff line change
Expand Up @@ -308,4 +308,4 @@ def __init__(self, top_k, *args, **kwargs): # noqa: E501
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.")
f"class with read only attributes.")
Loading