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

Refactor configs and disable collections and configure tests #77

Merged
merged 10 commits into from
Mar 12, 2024
18 changes: 6 additions & 12 deletions src/integration/java/io/pinecone/helpers/IndexManager.java
Original file line number Diff line number Diff line change
@@ -1,10 +1,8 @@
package io.pinecone.helpers;

import io.pinecone.clients.PineconeControlPlaneClient;
import io.pinecone.configs.PineconeClient;
import io.pinecone.configs.PineconeClientConfig;
import io.pinecone.configs.PineconeConfig;
import io.pinecone.configs.PineconeConnection;
import io.pinecone.configs.PineconeConnectionConfig;
import io.pinecone.exceptions.PineconeException;
import org.openapitools.client.model.*;
import org.slf4j.Logger;
Expand All @@ -30,7 +28,10 @@ public static PineconeConnection createIndexIfNotExistsDataPlane(int dimension,

// Do not proceed until the newly created index is ready
isIndexReady(indexName, controlPlaneClient);
return new PineconeConnection(apiKey, indexName);

// Adding to test PineconeConnection(pineconeConfig, indexName) constructor
PineconeConfig config = new PineconeConfig(apiKey);
return new PineconeConnection(config, indexName);
austin-denoble marked this conversation as resolved.
Show resolved Hide resolved
}

public static String createIndexIfNotExistsControlPlane(PineconeControlPlaneClient controlPlaneClient, int dimension, String indexType) throws IOException, InterruptedException {
Expand Down Expand Up @@ -117,14 +118,7 @@ public static PineconeConnection createNewIndexAndConnect(PineconeControlPlaneCl
// wait a bit more before we connect...
Thread.sleep(15000);

String host = controlPlaneClient.describeIndex(indexName).getHost();

PineconeClientConfig specificConfig = new PineconeClientConfig().withApiKey(System.getenv("PINECONE_API_KEY"));
PineconeClient dataPlaneClient = new PineconeClient(specificConfig);

return dataPlaneClient.connect(
new PineconeConnectionConfig()
.withConnectionUrl("https://" + host));
return new PineconeConnection(apiKey, indexName);
}

public static CollectionModel createCollection(PineconeControlPlaneClient controlPlaneClient, String collectionName, String indexName, boolean waitUntilReady) throws InterruptedException {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,12 @@
package io.pinecone.integration.controlPlane.pod;

import io.pinecone.clients.PineconeControlPlaneClient;
import io.pinecone.configs.PineconeClient;
import io.pinecone.configs.PineconeClientConfig;
import io.pinecone.configs.PineconeConnection;
import io.pinecone.configs.PineconeConnectionConfig;
import io.pinecone.configs.*;
import io.pinecone.helpers.RandomStringBuilder;
import io.pinecone.proto.*;
import org.junit.jupiter.api.AfterAll;
import org.junit.jupiter.api.BeforeAll;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.openapitools.client.model.*;
import org.slf4j.Logger;
Expand All @@ -24,6 +22,7 @@
import static io.pinecone.helpers.BuildUpsertRequest.*;
import static org.junit.jupiter.api.Assertions.*;

@Disabled("Disable the entire class")
public class CollectionTest {

private static PineconeControlPlaneClient controlPlaneClient;
Expand Down Expand Up @@ -125,9 +124,8 @@ public void testIndexToCollectionHappyPath() throws InterruptedException {
assertEquals(indexDescription.getStatus().getReady(), true);

// Set up new index data plane connection
PineconeClient newIndexClient = new PineconeClient(new PineconeClientConfig().withApiKey(apiKey).withEnvironment(environment));
PineconeConnection newIndexDataPlaneClient = newIndexClient.connect(new PineconeConnectionConfig().withConnectionUrl("https://" + indexDescription.getHost()));
VectorServiceGrpc.VectorServiceBlockingStub newIndexBlockingStub = newIndexDataPlaneClient.getBlockingStub();
PineconeConnection connection = new PineconeConnection(apiKey, indexName);
VectorServiceGrpc.VectorServiceBlockingStub newIndexBlockingStub = connection.getBlockingStub();
DescribeIndexStatsResponse describeResponse = newIndexBlockingStub.describeIndexStats(DescribeIndexStatsRequest.newBuilder().build());

// Verify stats reflect the vectors in the collection
Expand Down Expand Up @@ -162,7 +160,7 @@ public void testIndexToCollectionHappyPath() throws InterruptedException {
}
}

newIndexDataPlaneClient.close();
connection.close();
}

@Test
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import static io.pinecone.helpers.IndexManager.isIndexReady;
import static org.junit.jupiter.api.Assertions.assertEquals;

@Disabled("Disable the entire class")
public class ConfigureIndexTest {
private static PineconeControlPlaneClient controlPlaneClient;
private static String indexName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -157,9 +157,12 @@ public void upsertOptionalVectorsAndQueryIndexFutureTest() throws InterruptedExc
true).get();

ScoredVectorWithUnsignedIndices scoredVectorV1 = null;
for (int i = 0; i < topK; i++) {
if (upsertIds.get(0).equals(queryResponse.getMatches(i).getId())) {
scoredVectorV1 = queryResponse.getMatches(i);
// if the sizes are not equal, let the following assertions fail and retry again
rohanshah18 marked this conversation as resolved.
Show resolved Hide resolved
if(queryResponse.getMatchesList().size() == upsertIds.size()) {
for (int i = 0; i < topK; i++) {
if (upsertIds.get(0).equals(queryResponse.getMatches(i).getId())) {
scoredVectorV1 = queryResponse.getMatches(i);
}
}
}

Expand Down
46 changes: 0 additions & 46 deletions src/main/java/io/pinecone/configs/PineconeClient.java

This file was deleted.

119 changes: 0 additions & 119 deletions src/main/java/io/pinecone/configs/PineconeClientConfig.java

This file was deleted.

63 changes: 63 additions & 0 deletions src/main/java/io/pinecone/configs/PineconeConfig.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
package io.pinecone.configs;

import io.grpc.ManagedChannel;
import io.pinecone.exceptions.PineconeValidationException;

public class PineconeConfig {

private String apiKey;
private String host;
private String usageContext;
rohanshah18 marked this conversation as resolved.
Show resolved Hide resolved
private ManagedChannel customChannelBuilder;

public PineconeConfig(String apiKey) {
this.apiKey = apiKey;
}

public String getApiKey() {
return apiKey;
}

public void setApiKey(String apiKey) {
this.apiKey = apiKey;
}

public String getHost() {
return host;
}

public void setHost(String host) {
this.host = host;
}

public String getUsageContext() {
return usageContext;
}

public void setUsageContext(String usageContext) {
this.usageContext = usageContext;
}

public ManagedChannel getCustomChannelBuilder() {
return this.customChannelBuilder;
}

public void setCustomChannelBuilder(ManagedChannel customChannelBuilder) {
this.customChannelBuilder = customChannelBuilder;
}

public interface CustomChannelBuilder {
ManagedChannel buildChannel();
}
rohanshah18 marked this conversation as resolved.
Show resolved Hide resolved

void validate() {
if (apiKey == null)
throw new PineconeValidationException("Invalid PineconeConfig: missing apiKey");
}

public String getUserAgent() {
String userAgentLanguage = "lang=java; pineconeClientVersion = v0.8.0";
jhamon marked this conversation as resolved.
Show resolved Hide resolved
return (this.getUsageContext() != null) ?
userAgentLanguage + "; usageContext=" + this.getUsageContext() : userAgentLanguage;
rohanshah18 marked this conversation as resolved.
Show resolved Hide resolved
}
}
Loading
Loading