From c7a8a456f877238692b7410608bf4724d523d881 Mon Sep 17 00:00:00 2001 From: gdj0nes Date: Fri, 14 Jun 2024 09:57:38 -0400 Subject: [PATCH] fmt remaining files --- pinecone/__init__.py | 1 + pinecone/core/client/api/data_plane_api.py | 1 - .../core/client/api/manage_indexes_api.py | 1 - pinecone/core/client/api_client.py | 1 - pinecone/core/client/configuration.py | 1 - pinecone/core/client/model/collection_list.py | 1 - .../core/client/model/collection_model.py | 1 - .../client/model/configure_index_request.py | 1 - .../model/configure_index_request_spec.py | 1 - .../model/configure_index_request_spec_pod.py | 1 - .../client/model/create_collection_request.py | 1 - .../core/client/model/create_index_request.py | 1 - pinecone/core/client/model/delete_request.py | 1 - .../model/describe_index_stats_request.py | 1 - .../model/describe_index_stats_response.py | 1 - pinecone/core/client/model/error_response.py | 1 - .../core/client/model/error_response_error.py | 1 - pinecone/core/client/model/fetch_response.py | 1 - pinecone/core/client/model/index_list.py | 1 - pinecone/core/client/model/index_model.py | 1 - .../core/client/model/index_model_spec.py | 1 - .../core/client/model/index_model_status.py | 1 - pinecone/core/client/model/list_item.py | 1 - pinecone/core/client/model/list_response.py | 1 - .../core/client/model/namespace_summary.py | 1 - pinecone/core/client/model/pagination.py | 1 - pinecone/core/client/model/pod_spec.py | 1 - .../client/model/pod_spec_metadata_config.py | 1 - pinecone/core/client/model/protobuf_any.py | 1 - .../core/client/model/protobuf_null_value.py | 1 - pinecone/core/client/model/query_request.py | 1 - pinecone/core/client/model/query_response.py | 1 - pinecone/core/client/model/query_vector.py | 1 - pinecone/core/client/model/rpc_status.py | 1 - pinecone/core/client/model/scored_vector.py | 1 - pinecone/core/client/model/serverless_spec.py | 1 - .../core/client/model/single_query_results.py | 1 - pinecone/core/client/model/sparse_values.py | 1 - pinecone/core/client/model/update_request.py | 1 - pinecone/core/client/model/upsert_request.py | 1 - pinecone/core/client/model/upsert_response.py | 1 - pinecone/core/client/model/usage.py | 1 - pinecone/core/client/model/vector.py | 1 - pinecone/core/client/model_utils.py | 9 +-- pinecone/core/client/rest.py | 1 - .../core/grpc/protos/vector_service_pb2.py | 12 ++-- .../core/grpc/protos/vector_service_pb2.pyi | 29 ++++++++ pinecone/data/index.py | 1 - scripts/cleanup-all.py | 15 ++-- scripts/create-index-legacy.py | 58 ++++++++-------- scripts/create.py | 34 +++++---- scripts/delete-all-collections.py | 10 +-- scripts/delete.py | 15 ++-- scripts/generate_usage.py | 69 +++++++++++-------- 54 files changed, 150 insertions(+), 146 deletions(-) diff --git a/pinecone/__init__.py b/pinecone/__init__.py index e326cde9..499e5307 100644 --- a/pinecone/__init__.py +++ b/pinecone/__init__.py @@ -1,6 +1,7 @@ """ .. include:: ../README.md """ + import warnings from tqdm import TqdmExperimentalWarning diff --git a/pinecone/core/client/api/data_plane_api.py b/pinecone/core/client/api/data_plane_api.py index c9252d46..d8c86326 100644 --- a/pinecone/core/client/api/data_plane_api.py +++ b/pinecone/core/client/api/data_plane_api.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/api/manage_indexes_api.py b/pinecone/core/client/api/manage_indexes_api.py index 93fedf9f..64f35d46 100644 --- a/pinecone/core/client/api/manage_indexes_api.py +++ b/pinecone/core/client/api/manage_indexes_api.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/api_client.py b/pinecone/core/client/api_client.py index 24034830..5d7999e4 100644 --- a/pinecone/core/client/api_client.py +++ b/pinecone/core/client/api_client.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import json import atexit import mimetypes diff --git a/pinecone/core/client/configuration.py b/pinecone/core/client/configuration.py index e3a7605f..9ecbec75 100644 --- a/pinecone/core/client/configuration.py +++ b/pinecone/core/client/configuration.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import copy import logging import multiprocessing diff --git a/pinecone/core/client/model/collection_list.py b/pinecone/core/client/model/collection_list.py index ea09e5d6..58078999 100644 --- a/pinecone/core/client/model/collection_list.py +++ b/pinecone/core/client/model/collection_list.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/collection_model.py b/pinecone/core/client/model/collection_model.py index ae875820..b461d832 100644 --- a/pinecone/core/client/model/collection_model.py +++ b/pinecone/core/client/model/collection_model.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/configure_index_request.py b/pinecone/core/client/model/configure_index_request.py index 43885cc8..cf3eea58 100644 --- a/pinecone/core/client/model/configure_index_request.py +++ b/pinecone/core/client/model/configure_index_request.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/configure_index_request_spec.py b/pinecone/core/client/model/configure_index_request_spec.py index d70c45c8..e9285a60 100644 --- a/pinecone/core/client/model/configure_index_request_spec.py +++ b/pinecone/core/client/model/configure_index_request_spec.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/configure_index_request_spec_pod.py b/pinecone/core/client/model/configure_index_request_spec_pod.py index 860eb567..c0774a18 100644 --- a/pinecone/core/client/model/configure_index_request_spec_pod.py +++ b/pinecone/core/client/model/configure_index_request_spec_pod.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/create_collection_request.py b/pinecone/core/client/model/create_collection_request.py index 4503a39a..93dd4b05 100644 --- a/pinecone/core/client/model/create_collection_request.py +++ b/pinecone/core/client/model/create_collection_request.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/create_index_request.py b/pinecone/core/client/model/create_index_request.py index 1759deab..6ce5c4d2 100644 --- a/pinecone/core/client/model/create_index_request.py +++ b/pinecone/core/client/model/create_index_request.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/delete_request.py b/pinecone/core/client/model/delete_request.py index 28896f44..c1eb3d7a 100644 --- a/pinecone/core/client/model/delete_request.py +++ b/pinecone/core/client/model/delete_request.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/describe_index_stats_request.py b/pinecone/core/client/model/describe_index_stats_request.py index 37605c9c..dffc9965 100644 --- a/pinecone/core/client/model/describe_index_stats_request.py +++ b/pinecone/core/client/model/describe_index_stats_request.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/describe_index_stats_response.py b/pinecone/core/client/model/describe_index_stats_response.py index 23b110a6..38657628 100644 --- a/pinecone/core/client/model/describe_index_stats_response.py +++ b/pinecone/core/client/model/describe_index_stats_response.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/error_response.py b/pinecone/core/client/model/error_response.py index b1271ea8..96b8bab0 100644 --- a/pinecone/core/client/model/error_response.py +++ b/pinecone/core/client/model/error_response.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/error_response_error.py b/pinecone/core/client/model/error_response_error.py index 860251fb..f6830199 100644 --- a/pinecone/core/client/model/error_response_error.py +++ b/pinecone/core/client/model/error_response_error.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/fetch_response.py b/pinecone/core/client/model/fetch_response.py index f58d9906..00cf0d6a 100644 --- a/pinecone/core/client/model/fetch_response.py +++ b/pinecone/core/client/model/fetch_response.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/index_list.py b/pinecone/core/client/model/index_list.py index 729de70f..250a1aa8 100644 --- a/pinecone/core/client/model/index_list.py +++ b/pinecone/core/client/model/index_list.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/index_model.py b/pinecone/core/client/model/index_model.py index d1059810..1a6fdf73 100644 --- a/pinecone/core/client/model/index_model.py +++ b/pinecone/core/client/model/index_model.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/index_model_spec.py b/pinecone/core/client/model/index_model_spec.py index 0c0e6205..9c8e63f1 100644 --- a/pinecone/core/client/model/index_model_spec.py +++ b/pinecone/core/client/model/index_model_spec.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/index_model_status.py b/pinecone/core/client/model/index_model_status.py index 434afc46..ffc25f11 100644 --- a/pinecone/core/client/model/index_model_status.py +++ b/pinecone/core/client/model/index_model_status.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/list_item.py b/pinecone/core/client/model/list_item.py index 26fb1a9c..687c061b 100644 --- a/pinecone/core/client/model/list_item.py +++ b/pinecone/core/client/model/list_item.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/list_response.py b/pinecone/core/client/model/list_response.py index 98ba79d1..9a2b3065 100644 --- a/pinecone/core/client/model/list_response.py +++ b/pinecone/core/client/model/list_response.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/namespace_summary.py b/pinecone/core/client/model/namespace_summary.py index 53f8394a..9105515e 100644 --- a/pinecone/core/client/model/namespace_summary.py +++ b/pinecone/core/client/model/namespace_summary.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/pagination.py b/pinecone/core/client/model/pagination.py index 804be644..5f0836dd 100644 --- a/pinecone/core/client/model/pagination.py +++ b/pinecone/core/client/model/pagination.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/pod_spec.py b/pinecone/core/client/model/pod_spec.py index 94944927..1f408af9 100644 --- a/pinecone/core/client/model/pod_spec.py +++ b/pinecone/core/client/model/pod_spec.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/pod_spec_metadata_config.py b/pinecone/core/client/model/pod_spec_metadata_config.py index 2457ab50..1b3f3574 100644 --- a/pinecone/core/client/model/pod_spec_metadata_config.py +++ b/pinecone/core/client/model/pod_spec_metadata_config.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/protobuf_any.py b/pinecone/core/client/model/protobuf_any.py index b841d51d..3a0c4042 100644 --- a/pinecone/core/client/model/protobuf_any.py +++ b/pinecone/core/client/model/protobuf_any.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/protobuf_null_value.py b/pinecone/core/client/model/protobuf_null_value.py index 87364d51..8edc2ac4 100644 --- a/pinecone/core/client/model/protobuf_null_value.py +++ b/pinecone/core/client/model/protobuf_null_value.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/query_request.py b/pinecone/core/client/model/query_request.py index 01449f40..8f410dbc 100644 --- a/pinecone/core/client/model/query_request.py +++ b/pinecone/core/client/model/query_request.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/query_response.py b/pinecone/core/client/model/query_response.py index 37495daf..06c9d0c1 100644 --- a/pinecone/core/client/model/query_response.py +++ b/pinecone/core/client/model/query_response.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/query_vector.py b/pinecone/core/client/model/query_vector.py index 1682a9d0..f7ca7337 100644 --- a/pinecone/core/client/model/query_vector.py +++ b/pinecone/core/client/model/query_vector.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/rpc_status.py b/pinecone/core/client/model/rpc_status.py index e8bb95c8..a2f422bf 100644 --- a/pinecone/core/client/model/rpc_status.py +++ b/pinecone/core/client/model/rpc_status.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/scored_vector.py b/pinecone/core/client/model/scored_vector.py index 7fe2b180..60cad1ce 100644 --- a/pinecone/core/client/model/scored_vector.py +++ b/pinecone/core/client/model/scored_vector.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/serverless_spec.py b/pinecone/core/client/model/serverless_spec.py index f859eefb..1415c018 100644 --- a/pinecone/core/client/model/serverless_spec.py +++ b/pinecone/core/client/model/serverless_spec.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/single_query_results.py b/pinecone/core/client/model/single_query_results.py index 2f3cbe2f..88776062 100644 --- a/pinecone/core/client/model/single_query_results.py +++ b/pinecone/core/client/model/single_query_results.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/sparse_values.py b/pinecone/core/client/model/sparse_values.py index 3e615580..b9650352 100644 --- a/pinecone/core/client/model/sparse_values.py +++ b/pinecone/core/client/model/sparse_values.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/update_request.py b/pinecone/core/client/model/update_request.py index 5f38be20..da569e57 100644 --- a/pinecone/core/client/model/update_request.py +++ b/pinecone/core/client/model/update_request.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/upsert_request.py b/pinecone/core/client/model/upsert_request.py index 27d5eedd..72ae3cbd 100644 --- a/pinecone/core/client/model/upsert_request.py +++ b/pinecone/core/client/model/upsert_request.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/upsert_response.py b/pinecone/core/client/model/upsert_response.py index a9b4c543..5e300828 100644 --- a/pinecone/core/client/model/upsert_response.py +++ b/pinecone/core/client/model/upsert_response.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/usage.py b/pinecone/core/client/model/usage.py index 190d3ff3..45b4eca2 100644 --- a/pinecone/core/client/model/usage.py +++ b/pinecone/core/client/model/usage.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model/vector.py b/pinecone/core/client/model/vector.py index 87ee6278..f7f79919 100644 --- a/pinecone/core/client/model/vector.py +++ b/pinecone/core/client/model/vector.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import re # noqa: F401 import sys # noqa: F401 diff --git a/pinecone/core/client/model_utils.py b/pinecone/core/client/model_utils.py index fd4c38b4..6874920a 100644 --- a/pinecone/core/client/model_utils.py +++ b/pinecone/core/client/model_utils.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - from datetime import date, datetime # noqa: F401 import inspect import io @@ -1572,9 +1571,11 @@ def model_to_dict(model_instance, serialize=True): 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, + lambda item: ( + (item[0], model_to_dict(item[1], serialize=serialize)) + if hasattr(item[1], "_data_store") + else item + ), value.items(), ) ) diff --git a/pinecone/core/client/rest.py b/pinecone/core/client/rest.py index 17a4b18e..28fd1ff9 100644 --- a/pinecone/core/client/rest.py +++ b/pinecone/core/client/rest.py @@ -8,7 +8,6 @@ Generated by: https://openapi-generator.tech """ - import io import json import logging diff --git a/pinecone/core/grpc/protos/vector_service_pb2.py b/pinecone/core/grpc/protos/vector_service_pb2.py index 8491633b..378065d6 100644 --- a/pinecone/core/grpc/protos/vector_service_pb2.py +++ b/pinecone/core/grpc/protos/vector_service_pb2.py @@ -28,9 +28,9 @@ _builder.BuildTopDescriptorsAndMessages(DESCRIPTOR, "vector_service_pb2", _globals) if _descriptor._USE_C_DESCRIPTORS == False: _globals["DESCRIPTOR"]._options = None - _globals[ - "DESCRIPTOR" - ]._serialized_options = b'\n\021io.pinecone.protoP\001Z+github.com/pinecone-io/go-pinecone/pinecone\222A\311\002\022K\n\014Pinecone API";\n\017Pinecone.io Ops\022\023https://pinecone.io\032\023support@pinecone.io\032\014{index_host}*\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' + _globals["DESCRIPTOR"]._serialized_options = ( + b'\n\021io.pinecone.protoP\001Z+github.com/pinecone-io/go-pinecone/pinecone\222A\311\002\022K\n\014Pinecone API";\n\017Pinecone.io Ops\022\023https://pinecone.io\032\023support@pinecone.io\032\014{index_host}*\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' + ) _globals["_SPARSEVALUES"].fields_by_name["indices"]._options = None _globals["_SPARSEVALUES"].fields_by_name[ "indices" @@ -190,9 +190,9 @@ "total_vector_count" ]._serialized_options = b"\222A\007J\00580000" _globals["_DESCRIBEINDEXSTATSRESPONSE"]._options = None - _globals[ - "_DESCRIBEINDEXSTATSRESPONSE" - ]._serialized_options = b'\222A\210\0012\205\001{"namespaces": {"": {"vectorCount": 50000}, "example-namespace-2": {"vectorCount": 30000}}, "dimension": 1024, "index_fullness": 0.4}' + _globals["_DESCRIBEINDEXSTATSRESPONSE"]._serialized_options = ( + b'\222A\210\0012\205\001{"namespaces": {"": {"vectorCount": 50000}, "example-namespace-2": {"vectorCount": 30000}}, "dimension": 1024, "index_fullness": 0.4}' + ) _globals["_VECTORSERVICE"].methods_by_name["Upsert"]._options = None _globals["_VECTORSERVICE"].methods_by_name[ "Upsert" diff --git a/pinecone/core/grpc/protos/vector_service_pb2.pyi b/pinecone/core/grpc/protos/vector_service_pb2.pyi index 7a85a984..ca6e70d3 100644 --- a/pinecone/core/grpc/protos/vector_service_pb2.pyi +++ b/pinecone/core/grpc/protos/vector_service_pb2.pyi @@ -49,11 +49,13 @@ class Vector(google.protobuf.message.Message): @property def values(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.float]: """This is the vector data included in the request.""" + @property def sparse_values(self) -> global___SparseValues: ... @property def metadata(self) -> google.protobuf.struct_pb2.Struct: """This is the metadata included in the request.""" + def __init__( self, *, @@ -90,12 +92,15 @@ class ScoredVector(google.protobuf.message.Message): @property def values(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.float]: """This is the vector data, if it is requested.""" + @property def sparse_values(self) -> global___SparseValues: """This is the sparse data, if it is requested.""" + @property def metadata(self) -> google.protobuf.struct_pb2.Struct: """This is the metadata, if it is requested.""" + def __init__( self, *, @@ -181,6 +186,7 @@ class UpsertRequest(google.protobuf.message.Message): @property def vectors(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___Vector]: """An array containing the vectors to upsert. Recommended batch limit is 100 vectors.""" + def __init__( self, *, @@ -226,12 +232,14 @@ class DeleteRequest(google.protobuf.message.Message): @property def ids(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: """Vectors to delete.""" + @property def filter(self) -> google.protobuf.struct_pb2.Struct: """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/. """ + def __init__( self, *, @@ -274,6 +282,7 @@ class FetchRequest(google.protobuf.message.Message): @property def ids(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.str]: """The vector IDs to fetch. Does not accept values containing spaces.""" + def __init__( self, *, @@ -316,9 +325,11 @@ class FetchResponse(google.protobuf.message.Message): @property def vectors(self) -> google.protobuf.internal.containers.MessageMap[builtins.str, global___Vector]: """The fetched vectors, in the form of a map between the fetched ids and the fetched vectors""" + @property def usage(self) -> global___Usage: """The usage for this operation.""" + def __init__( self, *, @@ -454,12 +465,15 @@ class ListResponse(google.protobuf.message.Message): @property def vectors(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___ListItem]: """A list of ids""" + @property def pagination(self) -> global___Pagination: """Pagination token to continue past this listing""" + @property def usage(self) -> global___Usage: """The usage for this operation.""" + def __init__( self, *, @@ -518,12 +532,15 @@ class QueryVector(google.protobuf.message.Message): @property def values(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.float]: """The query vector values. This should be the same length as the dimension of the index being queried.""" + @property def sparse_values(self) -> global___SparseValues: """The query sparse values.""" + @property def filter(self) -> google.protobuf.struct_pb2.Struct: """An override for the metadata filter to apply. This replaces the request-level filter.""" + def __init__( self, *, @@ -582,15 +599,19 @@ class QueryRequest(google.protobuf.message.Message): @property def filter(self) -> google.protobuf.struct_pb2.Struct: """The filter to apply. You can use vector metadata to limit your search. See https://www.pinecone.io/docs/metadata-filtering/.""" + @property def queries(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___QueryVector]: """DEPRECATED. The query vectors. Each `query()` request can contain only one of the parameters `queries`, `vector`, or `id`.""" + @property def vector(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.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`.""" + @property def sparse_vector(self) -> global___SparseValues: """The query sparse values.""" + def __init__( self, *, @@ -646,6 +667,7 @@ class SingleQueryResults(google.protobuf.message.Message): @property def matches(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___ScoredVector]: """The matches for the vectors.""" + def __init__( self, *, @@ -673,12 +695,15 @@ class QueryResponse(google.protobuf.message.Message): self, ) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___SingleQueryResults]: """DEPRECATED. The results of each query. The order is the same as `QueryRequest.queries`.""" + @property def matches(self) -> google.protobuf.internal.containers.RepeatedCompositeFieldContainer[global___ScoredVector]: """The matches for the vectors.""" + @property def usage(self) -> global___Usage: """The usage for this operation.""" + def __init__( self, *, @@ -749,11 +774,13 @@ class UpdateRequest(google.protobuf.message.Message): @property def values(self) -> google.protobuf.internal.containers.RepeatedScalarFieldContainer[builtins.float]: """Vector data.""" + @property def sparse_values(self) -> global___SparseValues: ... @property def set_metadata(self) -> google.protobuf.struct_pb2.Struct: """Metadata to *set* for the vector.""" + def __init__( self, *, @@ -809,6 +836,7 @@ class DescribeIndexStatsRequest(google.protobuf.message.Message): for vectors that satisfy the filter. See https://www.pinecone.io/docs/metadata-filtering/. """ + def __init__( self, *, @@ -879,6 +907,7 @@ class DescribeIndexStatsResponse(google.protobuf.message.Message): summary of its contents. If a metadata filter expression is present, the summary will reflect only vectors matching that expression. """ + def __init__( self, *, diff --git a/pinecone/data/index.py b/pinecone/data/index.py index 6be21947..44379ad3 100644 --- a/pinecone/data/index.py +++ b/pinecone/data/index.py @@ -65,7 +65,6 @@ def parse_query_response(response: QueryResponse): class Index: - """ A client for interacting with a Pinecone index via REST API. For improved performance, use the Pinecone GRPC index client. diff --git a/scripts/cleanup-all.py b/scripts/cleanup-all.py index f5841173..b8b5e88f 100644 --- a/scripts/cleanup-all.py +++ b/scripts/cleanup-all.py @@ -1,25 +1,26 @@ import os from pinecone import Pinecone + def main(): - pc = Pinecone(api_key=os.environ.get('PINECONE_API_KEY', None)) + pc = Pinecone(api_key=os.environ.get("PINECONE_API_KEY", None)) for collection in pc.list_collections().names(): try: - print('Deleting collection: ' + collection) + print("Deleting collection: " + collection) pc.delete_collection(collection) except Exception as e: - print('Failed to delete collection: ' + collection + ' ' + str(e)) + print("Failed to delete collection: " + collection + " " + str(e)) pass for index in pc.list_indexes().names(): try: - print('Deleting index: ' + index) + print("Deleting index: " + index) pc.delete_index(index) except Exception as e: - print('Failed to delete index: ' + index + ' ' + str(e)) + print("Failed to delete index: " + index + " " + str(e)) pass -if __name__ == '__main__': - main() +if __name__ == "__main__": + main() diff --git a/scripts/create-index-legacy.py b/scripts/create-index-legacy.py index 2a98025e..6c85109d 100644 --- a/scripts/create-index-legacy.py +++ b/scripts/create-index-legacy.py @@ -4,60 +4,58 @@ import pinecone import time + def read_env_var(name): value = os.environ.get(name) if value is None: - raise Exception('Environment variable {} is not set'.format(name)) + raise Exception("Environment variable {} is not set".format(name)) return value + def random_embedding_values(dimension=2): return [random.random() for _ in range(dimension)] + def random_string(length): - return ''.join(random.choice(string.ascii_lowercase) for i in range(length)) + return "".join(random.choice(string.ascii_lowercase) for i in range(length)) + def main(): - api_key = read_env_var('PINECONE_API_KEY') - environment = read_env_var('PINECONE_ENVIRONMENT') - index_name = read_env_var('INDEX_NAME') - dimension = int(read_env_var('DIMENSION')) - metric = read_env_var('METRIC') + api_key = read_env_var("PINECONE_API_KEY") + environment = read_env_var("PINECONE_ENVIRONMENT") + index_name = read_env_var("INDEX_NAME") + dimension = int(read_env_var("DIMENSION")) + metric = read_env_var("METRIC") - print(f'Beginning test with environment {environment} and index {index_name}') + print(f"Beginning test with environment {environment} and index {index_name}") - pinecone.init( - api_key=api_key, - environment=environment - ) + pinecone.init(api_key=api_key, environment=environment) if index_name in pinecone.list_indexes(): - print(f'Index {index_name} already exists') + print(f"Index {index_name} already exists") pinecone.delete_index(index_name) - - pinecone.create_index( - name=index_name, - dimension=dimension, - metric=metric - ) - - print(f'Waiting for index {index_name} to be ready...') + + pinecone.create_index(name=index_name, dimension=dimension, metric=metric) + + print(f"Waiting for index {index_name} to be ready...") time.sleep(60) - print(f'Done waiting.') + print(f"Done waiting.") description = pinecone.describe_index(index_name) - print(f'Index description: {description}') + print(f"Index description: {description}") - print(f'Beginning upsert of 1000 vectors to index {index_name}...') + print(f"Beginning upsert of 1000 vectors to index {index_name}...") index = pinecone.Index(name=index_name) for _ in range(100): vector = random_embedding_values(dimension) - vecs = [{'id': random_string(10), 'values': vector} for i in range(10)] + vecs = [{"id": random_string(10), "values": vector} for i in range(10)] index.upsert(vectors=[vecs]) - print(f'Done upserting.') + print(f"Done upserting.") - print(f'Beginning query of index {index_name}...') + print(f"Beginning query of index {index_name}...") index.query(vector=random_embedding_values(dimension)) - print(f'Done querying.') + print(f"Done querying.") + -if __name__ == '__main__': - main() \ No newline at end of file +if __name__ == "__main__": + main() diff --git a/scripts/create.py b/scripts/create.py index 352c2137..a8b63493 100644 --- a/scripts/create.py +++ b/scripts/create.py @@ -3,35 +3,39 @@ import string from pinecone import Pinecone + def read_env_var(name): value = os.environ.get(name) if value is None: - raise 'Environment variable {} is not set'.format(name) + raise "Environment variable {} is not set".format(name) return value + def random_string(length): - return ''.join(random.choice(string.ascii_lowercase) for i in range(length)) + return "".join(random.choice(string.ascii_lowercase) for i in range(length)) + def write_gh_output(name, value): - with open(os.environ['GITHUB_OUTPUT'], 'a') as fh: - print(f'{name}={value}', file=fh) + with open(os.environ["GITHUB_OUTPUT"], "a") as fh: + print(f"{name}={value}", file=fh) + def main(): - pc = Pinecone(api_key=read_env_var('PINECONE_API_KEY')) - index_name = read_env_var('NAME_PREFIX') + random_string(20) + pc = Pinecone(api_key=read_env_var("PINECONE_API_KEY")) + index_name = read_env_var("NAME_PREFIX") + random_string(20) pc.create_index( name=index_name, - metric=read_env_var('METRIC'), - dimension=int(read_env_var('DIMENSION')), + metric=read_env_var("METRIC"), + dimension=int(read_env_var("DIMENSION")), spec={ - 'serverless': { - 'cloud': read_env_var('CLOUD'), - 'region': read_env_var('REGION'), + "serverless": { + "cloud": read_env_var("CLOUD"), + "region": read_env_var("REGION"), } - } + }, ) - write_gh_output('index_name', index_name) + write_gh_output("index_name", index_name) -if __name__ == '__main__': - main() +if __name__ == "__main__": + main() diff --git a/scripts/delete-all-collections.py b/scripts/delete-all-collections.py index 1a20c8a9..0f03c1bc 100644 --- a/scripts/delete-all-collections.py +++ b/scripts/delete-all-collections.py @@ -1,20 +1,22 @@ import os from pinecone import Pinecone + def read_env_var(name): value = os.environ.get(name) if value is None: - raise Exception('Environment variable {} is not set'.format(name)) + raise Exception("Environment variable {} is not set".format(name)) return value + def main(): - pc = Pinecone(api_key=read_env_var('PINECONE_API_KEY')) + pc = Pinecone(api_key=read_env_var("PINECONE_API_KEY")) collections = pc.list_collections().names() for collection in collections: if collection != "": pc.delete_collection(collection) -if __name__ == '__main__': - main() +if __name__ == "__main__": + main() diff --git a/scripts/delete.py b/scripts/delete.py index af047fea..e51d5588 100644 --- a/scripts/delete.py +++ b/scripts/delete.py @@ -1,17 +1,20 @@ import os from pinecone import Pinecone + def read_env_var(name): value = os.environ.get(name) if value is None: - raise 'Environment variable {} is not set'.format(name) + raise "Environment variable {} is not set".format(name) return value + def main(): - pc = Pinecone(api_key=read_env_var('PINECONE_API_KEY')) - to_delete = read_env_var('INDEX_NAME') + pc = Pinecone(api_key=read_env_var("PINECONE_API_KEY")) + to_delete = read_env_var("INDEX_NAME") pc.delete_index(name=to_delete) - print('Index deleted: ' + to_delete) + print("Index deleted: " + to_delete) + -if __name__ == '__main__': - main() \ No newline at end of file +if __name__ == "__main__": + main() diff --git a/scripts/generate_usage.py b/scripts/generate_usage.py index 1a2fc4a3..ba5791e0 100755 --- a/scripts/generate_usage.py +++ b/scripts/generate_usage.py @@ -3,45 +3,53 @@ import string from pinecone.grpc import PineconeGRPC + def read_env_var(name): value = os.environ.get(name) if value is None: - raise Exception('Environment variable {} is not set'.format(name)) + raise Exception("Environment variable {} is not set".format(name)) return value + def random_string(length): - return ''.join(random.choice(string.ascii_lowercase) for i in range(length)) + return "".join(random.choice(string.ascii_lowercase) for i in range(length)) + def random_embedding_values(dimension=2): return [random.random() for _ in range(dimension)] + def write_gh_output(name, value): - with open(os.environ['GITHUB_OUTPUT'], 'a') as fh: - print(f'{name}={value}', file=fh) + with open(os.environ["GITHUB_OUTPUT"], "a") as fh: + print(f"{name}={value}", file=fh) + + +DIMENSION = 1536 # common for openai embeddings -DIMENSION = 1536 # common for openai embeddings def create_index_if_not_exists(pc, index_name): if index_name not in pc.list_indexes().names(): - print(f'Index {index_name} does not exist, creating it') + print(f"Index {index_name} does not exist, creating it") pc.create_index( name=index_name, - metric='cosine', + metric="cosine", dimension=DIMENSION, spec={ - 'serverless': { - 'cloud': read_env_var('CLOUD'), - 'region': read_env_var('REGION'), + "serverless": { + "cloud": read_env_var("CLOUD"), + "region": read_env_var("REGION"), } - } + }, ) + upserted_ids = set() + def main(): - pc = PineconeGRPC(api_key=read_env_var('PINECONE_API_KEY')) - index_name = read_env_var('INDEX_NAME') - iterations = int(read_env_var('ITERATIONS')) + pc = PineconeGRPC(api_key=read_env_var("PINECONE_API_KEY")) + index_name = read_env_var("INDEX_NAME") + iterations = int(read_env_var("ITERATIONS")) create_index_if_not_exists(pc, index_name) @@ -52,39 +60,40 @@ def main(): items_to_upsert = random.randint(1, 100) vector_list = [ { - 'id': random_string(10), - 'values': random_embedding_values(DIMENSION), - 'metadata': { - 'genre': random.choice(['action', 'comedy', 'drama']), - 'runtime': random.randint(60, 120) - } - } for x in range(items_to_upsert) + "id": random_string(10), + "values": random_embedding_values(DIMENSION), + "metadata": { + "genre": random.choice(["action", "comedy", "drama"]), + "runtime": random.randint(60, 120), + }, + } + for x in range(items_to_upsert) ] index.upsert(vectors=vector_list) - print('Upserted {} vectors'.format(items_to_upsert)) + print("Upserted {} vectors".format(items_to_upsert)) for v in vector_list: - upserted_ids.add(v['id']) + upserted_ids.add(v["id"]) # Fetch some vectors ids_to_fetch = random.sample(upserted_ids, k=random.randint(1, 20)) - print('Fetching {} vectors'.format(len(ids_to_fetch))) + print("Fetching {} vectors".format(len(ids_to_fetch))) fetched_vectors = index.fetch(ids=ids_to_fetch) # Query some vectors - print('Querying 10 times') + print("Querying 10 times") for i in range(10): # Query by vector values query_vector = random_embedding_values(DIMENSION) query_results = index.query(vector=query_vector, top_k=10) - + # Delete some vectors - print('Deleting some vectors') + print("Deleting some vectors") id_to_delete = random.sample(upserted_ids, k=random.randint(1, 10)) index.delete(ids=id_to_delete) except Exception as e: - print('Exception: {}'.format(e)) + print("Exception: {}".format(e)) -if __name__ == '__main__': - main() +if __name__ == "__main__": + main()