Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Delete indexes with deletion protection enabled after integration tests #172

Draft
wants to merge 4 commits into
base: main
Choose a base branch
from
Draft
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
2 changes: 1 addition & 1 deletion codegen/apis
Submodule apis updated from 39e90e to 24c626
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,10 @@
public class CleanupAllTestResourcesListener implements TestExecutionListener {
@Override
public void testPlanExecutionFinished(TestPlan testPlan) {
TestResourcesManager.getInstance().cleanupResources();
try {
TestResourcesManager.getInstance().cleanupResources();
} catch (InterruptedException e) {
throw new RuntimeException(e);
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -256,12 +256,20 @@ public CollectionModel getOrCreateCollectionModel() throws InterruptedException
* Cleans up any resources that have been created by the manager. Called in {@link io.pinecone.CleanupAllTestResourcesListener}
* after all tests have finished running.
*/
public void cleanupResources() {
public void cleanupResources() throws InterruptedException {
if (podIndexName != null) {
if(pineconeClient.describeIndex(podIndexName).getDeletionProtection() == DeletionProtection.ENABLED) {
pineconeClient.configurePodsIndex(podIndexName, DeletionProtection.DISABLED);
Thread.sleep(5000);
}
pineconeClient.deleteIndex(podIndexName);
}

if (serverlessIndexName != null) {
if(pineconeClient.describeIndex(serverlessIndexName).getDeletionProtection() == DeletionProtection.ENABLED) {
pineconeClient.configureServerlessIndex(serverlessIndexName, DeletionProtection.DISABLED, null);
Thread.sleep(5000);
}
pineconeClient.deleteIndex(serverlessIndexName);
}

Expand Down Expand Up @@ -387,8 +395,5 @@ private void seedIndex(List<String> vectorIds, String indexName, String namespac
totalTimeWaitedForVectors += 2000;
indexStats = indexClient.describeIndexStats();
}
if (indexStats.getTotalVectorCount() == 0 && totalTimeWaitedForVectors >= 60000) {
throw new PineconeException("Failed to seed index " + indexName + "with vectors");
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ public void testGenerateEmbeddings() throws ApiException {

assertNotNull(embeddings, "Expected embedding to be not null");
Assertions.assertEquals(embeddingModel, embeddings.getModel());
Assertions.assertEquals(1024, embeddings.getData().get(0).getValues().size());
Assertions.assertEquals(1024, embeddings.getData().get(0).getDenseEmbedding().getValues().size());
Assertions.assertEquals(2, embeddings.getData().size());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,32 +22,32 @@ public class RerankTest {
public void testRerank() throws ApiException {
String model = "bge-reranker-v2-m3";
String query = "The tech company Apple is known for its innovative products like the iPhone.";
List<Map<String, String>> documents = new ArrayList<>();
List<Map<String, Object>> documents = new ArrayList<>();

Map<String, String> doc1 = new HashMap<>();
Map<String, Object> doc1 = new HashMap<>();
doc1.put("id", "vec1");
doc1.put("my_field", "Apple is a popular fruit known for its sweetness and crisp texture.");
documents.add(doc1);

Map<String, String> doc2 = new HashMap<>();
Map<String, Object> doc2 = new HashMap<>();
doc2.put("id", "vec2");
doc2.put("my_field", "Many people enjoy eating apples as a healthy snack.");
documents.add(doc2);

Map<String, String> doc3 = new HashMap<>();
Map<String, Object> doc3 = new HashMap<>();
doc3.put("id", "vec3");
doc3.put("my_field", "Apple Inc. has revolutionized the tech industry with its sleek designs and user-friendly interfaces.");
documents.add(doc3);

Map<String, String> doc4 = new HashMap<>();
Map<String, Object> doc4 = new HashMap<>();
doc4.put("id", "vec4");
doc4.put("my_field", "An apple a day keeps the doctor away, as the saying goes.");
documents.add(doc4);

List<String> rankFields = Arrays.asList("my_field");
int topN = 2;
boolean returnDocuments = true;
Map<String, String> parameters = new HashMap<>();
Map<String, Object> parameters = new HashMap<>();
parameters.put("truncate", "END");

RerankResult result = inference.rerank(model, query, documents, rankFields, topN, returnDocuments, parameters);
Expand All @@ -63,24 +63,24 @@ public void testRerank() throws ApiException {
public void testRerankWithRequiredParameters() throws ApiException {
String model = "bge-reranker-v2-m3";
String query = "The tech company Apple is known for its innovative products like the iPhone.";
List<Map<String, String>> documents = new ArrayList<>();
List<Map<String, Object>> documents = new ArrayList<>();

Map<String, String> doc1 = new HashMap<>();
Map<String, Object> doc1 = new HashMap<>();
doc1.put("id", "vec1");
doc1.put("text", "Apple is a popular fruit known for its sweetness and crisp texture.");
documents.add(doc1);

Map<String, String> doc2 = new HashMap<>();
Map<String, Object> doc2 = new HashMap<>();
doc2.put("id", "vec2");
doc2.put("text", "Many people enjoy eating apples as a healthy snack.");
documents.add(doc2);

Map<String, String> doc3 = new HashMap<>();
Map<String, Object> doc3 = new HashMap<>();
doc3.put("id", "vec3");
doc3.put("text", "Apple Inc. has revolutionized the tech industry with its sleek designs and user-friendly interfaces.");
documents.add(doc3);

Map<String, String> doc4 = new HashMap<>();
Map<String, Object> doc4 = new HashMap<>();
doc4.put("id", "vec4");
doc4.put("text", "An apple a day keeps the doctor away, as the saying goes.");
documents.add(doc4);
Expand Down
11 changes: 4 additions & 7 deletions src/main/java/io/pinecone/clients/Inference.java
Original file line number Diff line number Diff line change
Expand Up @@ -49,12 +49,9 @@ public Inference(PineconeConfig config) {
* @throws ApiException If the API call fails, an ApiException is thrown.
*/
public EmbeddingsList embed(String model, Map<String, Object> parameters, List<String> inputs) throws ApiException {
EmbedRequestParameters embedRequestParameters = new EmbedRequestParameters();
parameters.forEach(embedRequestParameters::putAdditionalProperty);

EmbedRequest embedRequest = new EmbedRequest()
.model(model)
.parameters(embedRequestParameters)
.parameters(parameters)
.inputs(convertToEmbedInputs(inputs));

return inferenceApi.embed(embedRequest);
Expand All @@ -74,7 +71,7 @@ public EmbeddingsList embed(String model, Map<String, Object> parameters, List<S
*/
public RerankResult rerank(String model,
String query,
List<Map<String, String>> documents) throws ApiException {
List<Map<String, Object>> documents) throws ApiException {
return rerank(model,
query,
documents,
Expand All @@ -100,11 +97,11 @@ public RerankResult rerank(String model,
*/
public RerankResult rerank(String model,
String query,
List<Map<String, String>> documents,
List<Map<String, Object>> documents,
List<String> rankFields,
int topN,
boolean returnDocuments,
Map<String, String> parameters) throws ApiException {
Map<String, Object> parameters) throws ApiException {
RerankRequest rerankRequest = new RerankRequest();

rerankRequest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Pinecone Control Plane API
* Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors.
*
* The version of the OpenAPI document: 2024-10
* The version of the OpenAPI document: 2025-01
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Pinecone Control Plane API
* Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors.
*
* The version of the OpenAPI document: 2024-10
* The version of the OpenAPI document: 2025-01
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down Expand Up @@ -140,7 +140,7 @@ private void init() {
json = new JSON();

// Set default User-Agent.
setUserAgent("OpenAPI-Generator/2024-10/java");
setUserAgent("OpenAPI-Generator/2025-01/java");

authentications = new HashMap<String, Authentication>();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Pinecone Control Plane API
* Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors.
*
* The version of the OpenAPI document: 2024-10
* The version of the OpenAPI document: 2025-01
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand All @@ -21,7 +21,7 @@
* <p>ApiException class.</p>
*/
@SuppressWarnings("serial")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-10-23T20:47:10.542209Z[Etc/UTC]")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-01-10T18:59:18.406889Z[Etc/UTC]")
public class ApiException extends Exception {
private int code = 0;
private Map<String, List<String>> responseHeaders = null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Pinecone Control Plane API
* Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors.
*
* The version of the OpenAPI document: 2024-10
* The version of the OpenAPI document: 2025-01
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Pinecone Control Plane API
* Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors.
*
* The version of the OpenAPI document: 2024-10
* The version of the OpenAPI document: 2025-01
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand All @@ -13,9 +13,9 @@

package org.openapitools.db_control.client;

@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-10-23T20:47:10.542209Z[Etc/UTC]")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-01-10T18:59:18.406889Z[Etc/UTC]")
public class Configuration {
public static final String VERSION = "2024-10";
public static final String VERSION = "2025-01";

private static ApiClient defaultApiClient = new ApiClient();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Pinecone Control Plane API
* Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors.
*
* The version of the OpenAPI document: 2024-10
* The version of the OpenAPI document: 2025-01
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/org/openapitools/db_control/client/JSON.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Pinecone Control Plane API
* Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors.
*
* The version of the OpenAPI document: 2024-10
* The version of the OpenAPI document: 2025-01
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down Expand Up @@ -96,9 +96,12 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.db_control.client.model.CollectionList.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.db_control.client.model.CollectionModel.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.db_control.client.model.ConfigureIndexRequest.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.db_control.client.model.ConfigureIndexRequestEmbed.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.db_control.client.model.ConfigureIndexRequestSpec.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.db_control.client.model.ConfigureIndexRequestSpecPod.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.db_control.client.model.CreateCollectionRequest.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.db_control.client.model.CreateIndexForModelRequest.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.db_control.client.model.CreateIndexForModelRequestEmbed.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.db_control.client.model.CreateIndexRequest.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.db_control.client.model.ErrorResponse.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.db_control.client.model.ErrorResponseError.CustomTypeAdapterFactory());
Expand All @@ -107,6 +110,7 @@ private static Class getClassByDiscriminator(Map classByDiscriminatorValue, Stri
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.db_control.client.model.IndexModelSpec.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.db_control.client.model.IndexModelStatus.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.db_control.client.model.IndexSpec.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.db_control.client.model.ModelIndexEmbed.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.db_control.client.model.PodSpec.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.db_control.client.model.PodSpecMetadataConfig.CustomTypeAdapterFactory());
gsonBuilder.registerTypeAdapterFactory(new org.openapitools.db_control.client.model.ServerlessSpec.CustomTypeAdapterFactory());
Expand Down
4 changes: 2 additions & 2 deletions src/main/java/org/openapitools/db_control/client/Pair.java
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Pinecone Control Plane API
* Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors.
*
* The version of the OpenAPI document: 2024-10
* The version of the OpenAPI document: 2025-01
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand All @@ -13,7 +13,7 @@

package org.openapitools.db_control.client;

@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-10-23T20:47:10.542209Z[Etc/UTC]")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-01-10T18:59:18.406889Z[Etc/UTC]")
public class Pair {
private String name = "";
private String value = "";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Pinecone Control Plane API
* Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors.
*
* The version of the OpenAPI document: 2024-10
* The version of the OpenAPI document: 2025-01
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Pinecone Control Plane API
* Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors.
*
* The version of the OpenAPI document: 2024-10
* The version of the OpenAPI document: 2025-01
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
* Pinecone Control Plane API
* Pinecone is a vector database that makes it easy to search and retrieve billions of high-dimensional vectors.
*
* The version of the OpenAPI document: 2024-10
* The version of the OpenAPI document: 2025-01
* Contact: [email protected]
*
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
Expand All @@ -16,7 +16,7 @@
import java.util.Collection;
import java.util.Iterator;

@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2024-10-23T20:47:10.542209Z[Etc/UTC]")
@javax.annotation.Generated(value = "org.openapitools.codegen.languages.JavaClientCodegen", date = "2025-01-10T18:59:18.406889Z[Etc/UTC]")
public class StringUtil {
/**
* Check if the given array contains the given value (with case-insensitive comparison).
Expand Down
Loading
Loading