From 837236a802cceb69a0acc18780ee9d751a30f1bc Mon Sep 17 00:00:00 2001 From: rohanshah18 Date: Mon, 18 Dec 2023 13:25:48 -0500 Subject: [PATCH 1/3] update changelogs, examples, and readme --- CHANGELOG.md | 5 +++- README.md | 10 +++---- .../MinimalUpsertAndQueryExample.java | 1 + .../UpsertsAndQueriesConcurrentExample.java | 2 ++ gradle.properties | 2 +- .../pinecone/PineconeClientLiveIntegTest.java | 28 +++++++------------ .../CreateListAndDeleteIndexTest.java} | 6 ++-- 7 files changed, 26 insertions(+), 28 deletions(-) rename src/integration/java/io/pinecone/{PineconeIndexOperationsClientIntegrationTest.java => integration/controlPlane/CreateListAndDeleteIndexTest.java} (90%) diff --git a/CHANGELOG.md b/CHANGELOG.md index 1b8c14b6..3ccd2da4 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,9 +2,12 @@ [comment]: <> (When bumping [pc:VERSION_LATEST_RELEASE] create a new entry below) ### Unreleased version + +### v0.7.0 - Add support to list indexes - Add support to configure index -- Add user-agent as a header +- Add user-agent to the header +- Add integration tests for data plane operations ### v0.6.0 - Add async stub for data plane operations diff --git a/README.md b/README.md index 7b2b8e47..8d6e9bd1 100644 --- a/README.md +++ b/README.md @@ -15,7 +15,7 @@ Maven: io.pinecone pinecone-client - 0.2.3 + 0.7.0 ``` @@ -23,12 +23,12 @@ Maven: Gradle: ``` -implementation "io.pinecone:pinecone-client:0.2.3" +implementation "io.pinecone:pinecone-client:0.7.0" ``` [comment]: <> (^ [pc:VERSION_LATEST_RELEASE]) -Alternatively, you can use our standalone uberjar [pinecone-client-0.2.3-all.jar](https://repo1.maven.org/maven2/io/pinecone/pinecone-client/0.2.3/pinecone-client-0.2.3-all.jar), which bundles the pinecone client and all dependencies together inside a single jar. You can include this on your classpath like any 3rd party JAR without having to obtain the *pinecone-client* dependencies separately. +Alternatively, you can use our standalone uberjar [pinecone-client-0.7.0-all.jar](https://repo1.maven.org/maven2/io/pinecone/pinecone-client/0.2.3/pinecone-client-0.2.3-all.jar), which bundles the pinecone client and all dependencies together inside a single jar. You can include this on your classpath like any 3rd party JAR without having to obtain the *pinecone-client* dependencies separately. [comment]: <> (^ [pc:VERSION_LATEST_RELEASE]) @@ -39,6 +39,4 @@ The Java client doesn't support managing Pinecone services, only reading and wri ## Examples -- The most basic example usage is in `src/test/java/io/pinecone/PineconeClientLiveIntegTest.java`, covering most basic operations. -> [!NOTE] -> The java-basic-mvn example is outdated. \ No newline at end of file +- The data and control plane operations can be found in `io/pinecone/integration` folder. \ No newline at end of file diff --git a/examples/java-basic-mvn/src/main/java/pineconeexamples/MinimalUpsertAndQueryExample.java b/examples/java-basic-mvn/src/main/java/pineconeexamples/MinimalUpsertAndQueryExample.java index fdd572f9..88fe1a99 100644 --- a/examples/java-basic-mvn/src/main/java/pineconeexamples/MinimalUpsertAndQueryExample.java +++ b/examples/java-basic-mvn/src/main/java/pineconeexamples/MinimalUpsertAndQueryExample.java @@ -53,6 +53,7 @@ public static void main(String[] cliArgs) { .addAllValues(Floats.asList(5F, 3F, 1F)) .build(); + // Deprecated: use addValue() or addAllValues() instead of addVector() and addAllVectors() respectively UpsertRequest upsertRequest = UpsertRequest.newBuilder() .addVectors(v1) .addVectors(v2) diff --git a/examples/java-basic-mvn/src/main/java/pineconeexamples/UpsertsAndQueriesConcurrentExample.java b/examples/java-basic-mvn/src/main/java/pineconeexamples/UpsertsAndQueriesConcurrentExample.java index e88db89a..2f37013f 100644 --- a/examples/java-basic-mvn/src/main/java/pineconeexamples/UpsertsAndQueriesConcurrentExample.java +++ b/examples/java-basic-mvn/src/main/java/pineconeexamples/UpsertsAndQueriesConcurrentExample.java @@ -106,6 +106,8 @@ public static void main(String[] cliArgs) throws InterruptedException { } try { + // Deprecated: use addValue() or addAllValues() instead of addVector() + // and addAllVectors() respectively UpsertRequest upsertRequest = UpsertRequest.newBuilder() .addAllVectors(vectors) .build(); diff --git a/gradle.properties b/gradle.properties index 7a16702b..54602b59 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1 +1 @@ -pineconeClientVersion = 0.6.0 +pineconeClientVersion = 0.7.0 diff --git a/src/integration/java/io/pinecone/PineconeClientLiveIntegTest.java b/src/integration/java/io/pinecone/PineconeClientLiveIntegTest.java index 0d9e9b0b..b7b3b3b3 100644 --- a/src/integration/java/io/pinecone/PineconeClientLiveIntegTest.java +++ b/src/integration/java/io/pinecone/PineconeClientLiveIntegTest.java @@ -6,46 +6,38 @@ import io.pinecone.helpers.RandomStringBuilder; import io.pinecone.model.IndexMeta; import io.pinecone.proto.*; -import org.junit.jupiter.api.BeforeEach; +import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; import org.slf4j.Logger; import org.slf4j.LoggerFactory; +import java.io.IOException; import java.util.ArrayList; import java.util.Arrays; import java.util.List; +import static io.pinecone.helpers.IndexManager.createIndexIfNotExistsControlPlane; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.notNullValue; -import static org.junit.jupiter.api.Assertions.assertEquals; public class PineconeClientLiveIntegTest { - public String indexName = "integ-test-sanity"; - private static final Logger logger = LoggerFactory.getLogger(PineconeClientLiveIntegTest.class); + private static PineconeIndexOperationClient controlPlaneClient; + private static PineconeClient dataPlaneClient; + public static String indexName; - private PineconeClient dataPlaneClient; - private PineconeIndexOperationClient controlPlaneClient; - - @BeforeEach - public void setUp() { + @BeforeAll + public static void defineConfig() throws IOException, InterruptedException { PineconeClientConfig config = new PineconeClientConfig() .withApiKey(System.getenv("PINECONE_API_KEY")) - .withEnvironment(System.getenv("PINECONE_ENVIRONMENT")) - .withServerSideTimeoutSec(10); - + .withEnvironment(System.getenv("PINECONE_ENVIRONMENT")); + indexName = createIndexIfNotExistsControlPlane(config, 3); controlPlaneClient = new PineconeIndexOperationClient(config); dataPlaneClient = new PineconeClient(config); } - @Test - public void checkIndexSetup() throws Exception { - IndexMeta indexMeta = controlPlaneClient.describeIndex(indexName); - assertEquals(3, indexMeta.getDatabase().getDimension()); - } - @Test public void sanity() throws Exception { IndexMeta indexMeta = controlPlaneClient.describeIndex(indexName); diff --git a/src/integration/java/io/pinecone/PineconeIndexOperationsClientIntegrationTest.java b/src/integration/java/io/pinecone/integration/controlPlane/CreateListAndDeleteIndexTest.java similarity index 90% rename from src/integration/java/io/pinecone/PineconeIndexOperationsClientIntegrationTest.java rename to src/integration/java/io/pinecone/integration/controlPlane/CreateListAndDeleteIndexTest.java index 071be2a3..adc05949 100644 --- a/src/integration/java/io/pinecone/PineconeIndexOperationsClientIntegrationTest.java +++ b/src/integration/java/io/pinecone/integration/controlPlane/CreateListAndDeleteIndexTest.java @@ -1,5 +1,7 @@ -package io.pinecone; +package io.pinecone.integration.controlPlane; +import io.pinecone.PineconeClientConfig; +import io.pinecone.PineconeIndexOperationClient; import io.pinecone.helpers.RandomStringBuilder; import io.pinecone.model.CreateIndexRequest; import io.pinecone.model.IndexMeta; @@ -12,7 +14,7 @@ import static org.junit.jupiter.api.Assertions.assertEquals; import static org.junit.jupiter.api.Assertions.assertNotNull; -public class PineconeIndexOperationsClientIntegrationTest { +public class CreateListAndDeleteIndexTest { private PineconeIndexOperationClient pinecone; @BeforeEach From 91af6d0d302d8ac37ffedfb585db78e369b56828 Mon Sep 17 00:00:00 2001 From: rohanshah18 Date: Mon, 18 Dec 2023 13:42:23 -0500 Subject: [PATCH 2/3] cleanup --- .../controlPlane/ConfigureIndexTest.java | 2 +- .../PineconeClientLiveIntegTest.java | 50 +++++++------------ 2 files changed, 20 insertions(+), 32 deletions(-) rename src/integration/java/io/pinecone/{ => integration/dataplane}/PineconeClientLiveIntegTest.java (79%) diff --git a/src/integration/java/io/pinecone/integration/controlPlane/ConfigureIndexTest.java b/src/integration/java/io/pinecone/integration/controlPlane/ConfigureIndexTest.java index d945c5d2..8555b35d 100644 --- a/src/integration/java/io/pinecone/integration/controlPlane/ConfigureIndexTest.java +++ b/src/integration/java/io/pinecone/integration/controlPlane/ConfigureIndexTest.java @@ -1,7 +1,7 @@ package io.pinecone.integration.controlPlane; import io.pinecone.PineconeClientConfig; -import io.pinecone.PineconeClientLiveIntegTest; +import io.pinecone.integration.dataplane.PineconeClientLiveIntegTest; import io.pinecone.PineconeIndexOperationClient; import io.pinecone.exceptions.PineconeBadRequestException; import io.pinecone.exceptions.PineconeNotFoundException; diff --git a/src/integration/java/io/pinecone/PineconeClientLiveIntegTest.java b/src/integration/java/io/pinecone/integration/dataplane/PineconeClientLiveIntegTest.java similarity index 79% rename from src/integration/java/io/pinecone/PineconeClientLiveIntegTest.java rename to src/integration/java/io/pinecone/integration/dataplane/PineconeClientLiveIntegTest.java index b7b3b3b3..a071c880 100644 --- a/src/integration/java/io/pinecone/PineconeClientLiveIntegTest.java +++ b/src/integration/java/io/pinecone/integration/dataplane/PineconeClientLiveIntegTest.java @@ -1,10 +1,10 @@ -package io.pinecone; +package io.pinecone.integration.dataplane; import com.google.common.primitives.Floats; import com.google.protobuf.Struct; import com.google.protobuf.Value; +import io.pinecone.PineconeConnection; import io.pinecone.helpers.RandomStringBuilder; -import io.pinecone.model.IndexMeta; import io.pinecone.proto.*; import org.junit.jupiter.api.BeforeAll; import org.junit.jupiter.api.Test; @@ -16,7 +16,7 @@ import java.util.Arrays; import java.util.List; -import static io.pinecone.helpers.IndexManager.createIndexIfNotExistsControlPlane; +import static io.pinecone.helpers.IndexManager.createIndexIfNotExistsDataPlane; import static org.hamcrest.MatcherAssert.assertThat; import static org.hamcrest.Matchers.equalTo; import static org.hamcrest.Matchers.notNullValue; @@ -24,28 +24,16 @@ public class PineconeClientLiveIntegTest { private static final Logger logger = LoggerFactory.getLogger(PineconeClientLiveIntegTest.class); - private static PineconeIndexOperationClient controlPlaneClient; - private static PineconeClient dataPlaneClient; - public static String indexName; + private static VectorServiceGrpc.VectorServiceBlockingStub blockingStub; @BeforeAll public static void defineConfig() throws IOException, InterruptedException { - PineconeClientConfig config = new PineconeClientConfig() - .withApiKey(System.getenv("PINECONE_API_KEY")) - .withEnvironment(System.getenv("PINECONE_ENVIRONMENT")); - indexName = createIndexIfNotExistsControlPlane(config, 3); - controlPlaneClient = new PineconeIndexOperationClient(config); - dataPlaneClient = new PineconeClient(config); + PineconeConnection connection = createIndexIfNotExistsDataPlane(3); + blockingStub = connection.getBlockingStub(); } @Test - public void sanity() throws Exception { - IndexMeta indexMeta = controlPlaneClient.describeIndex(indexName); - String host = indexMeta.getStatus().getHost(); - PineconeConnection conn = dataPlaneClient.connect( - new PineconeConnectionConfig() - .withConnectionUrl("https://" + host)); - + public void sanity() { String namespace = RandomStringBuilder.build("ns", 8); // upsert @@ -68,7 +56,7 @@ public void sanity() throws Exception { .setNamespace(namespace) .build(); - UpsertResponse upsertResponse = conn.getBlockingStub().upsert(request); + UpsertResponse upsertResponse = blockingStub.upsert(request); logger.info("Put " + upsertResponse.getUpsertedCount() + " vectors into the index"); assert (upsertResponse.getUpsertedCount() == 3); @@ -92,14 +80,14 @@ public void sanity() throws Exception { .addAllVectors(hybridVectors) .setNamespace(namespace) .build(); - UpsertResponse hybridResponse = conn.getBlockingStub().upsert(hybridRequest); + UpsertResponse hybridResponse = blockingStub.upsert(hybridRequest); logger.info("Put " + hybridResponse.getUpsertedCount() + " vectors into the index"); assert (hybridResponse.getUpsertedCount() == 3); // fetch List ids = Arrays.asList("v1", "v2"); FetchRequest fetchRequest = FetchRequest.newBuilder().addAllIds(ids).setNamespace(namespace).build(); - FetchResponse fetchResponse = conn.getBlockingStub().fetch(fetchRequest); + FetchResponse fetchResponse = blockingStub.fetch(fetchRequest); assert (fetchResponse.containsVectors("v1")); // Updates vector v1's values to 10.0, 11.0, and 12.0 from 1.0, 2.0, and 3.0 @@ -108,9 +96,9 @@ public void sanity() throws Exception { .setNamespace(namespace) .addAllValues(Floats.asList(10F, 11F, 12F)) .build(); - conn.getBlockingStub().update(updateRequest); + blockingStub.update(updateRequest); fetchRequest = FetchRequest.newBuilder().addIds("v1").setNamespace(namespace).build(); - conn.getBlockingStub().fetch(fetchRequest); + blockingStub.fetch(fetchRequest); // DEPRECATED: all methods related to queries in QueryVector // Use methods related to Vector. Example: addVector, addAllVector, etc. @@ -137,7 +125,7 @@ public void sanity() throws Exception { .setIncludeMetadata(true) .build(); - QueryResponse queryResponse = conn.getBlockingStub().query(batchQueryRequest); + QueryResponse queryResponse = blockingStub.query(batchQueryRequest); assertThat(queryResponse, notNullValue()); assertThat(queryResponse.getResultsList(), notNullValue()); assertThat(queryResponse.getResultsCount(), equalTo(1)); @@ -151,7 +139,7 @@ public void sanity() throws Exception { .build(); // When querying using a single vector, we get matches instead of results - queryResponse = conn.getBlockingStub().query(queryRequest); + queryResponse = blockingStub.query(queryRequest); assertThat(queryResponse, notNullValue()); assertThat(queryResponse.getMatchesList(), notNullValue()); assertThat(queryResponse.getMatchesCount(), equalTo(2)); @@ -164,7 +152,7 @@ public void sanity() throws Exception { .setIncludeMetadata(true) .build(); - queryResponse = conn.getBlockingStub().query(queryByIdRequest); + queryResponse = blockingStub.query(queryByIdRequest); assertThat(queryResponse, notNullValue()); assertThat(queryResponse.getMatchesList(), notNullValue()); assertThat(queryResponse.getMatchesCount(), equalTo(2)); @@ -177,9 +165,9 @@ public void sanity() throws Exception { .setDeleteAll(false) .build(); - conn.getBlockingStub().delete(deleteRequest); + blockingStub.delete(deleteRequest); fetchRequest = FetchRequest.newBuilder().addAllIds(ids).setNamespace(namespace).build(); - fetchResponse = conn.getBlockingStub().fetch(fetchRequest); + fetchResponse = blockingStub.fetch(fetchRequest); assert (fetchResponse.getVectorsCount() == ids.size() - 1); // Clear out the test @@ -188,9 +176,9 @@ public void sanity() throws Exception { .setDeleteAll(true) .build(); - conn.getBlockingStub().delete(deleteAllRequest); + blockingStub.delete(deleteAllRequest); fetchRequest = FetchRequest.newBuilder().addAllIds(ids).setNamespace(namespace).build(); - fetchResponse = conn.getBlockingStub().fetch(fetchRequest); + fetchResponse = blockingStub.fetch(fetchRequest); assert (fetchResponse.getVectorsCount() == 0); } } From d2d6c6f5064d7863f5971e0c029a862b68b1975f Mon Sep 17 00:00:00 2001 From: rohanshah18 Date: Mon, 18 Dec 2023 15:17:48 -0500 Subject: [PATCH 3/3] cleanupx2 --- README.md | 8 ++------ 1 file changed, 2 insertions(+), 6 deletions(-) diff --git a/README.md b/README.md index 8d6e9bd1..7219f4e8 100644 --- a/README.md +++ b/README.md @@ -28,15 +28,11 @@ implementation "io.pinecone:pinecone-client:0.7.0" [comment]: <> (^ [pc:VERSION_LATEST_RELEASE]) -Alternatively, you can use our standalone uberjar [pinecone-client-0.7.0-all.jar](https://repo1.maven.org/maven2/io/pinecone/pinecone-client/0.2.3/pinecone-client-0.2.3-all.jar), which bundles the pinecone client and all dependencies together inside a single jar. You can include this on your classpath like any 3rd party JAR without having to obtain the *pinecone-client* dependencies separately. +Alternatively, you can use our standalone uberjar [pinecone-client-0.7.0-all.jar](https://repo1.maven.org/maven2/io/pinecone/pinecone-client/0.7.0/pinecone-client-0.7.0-all.jar), which bundles the pinecone client and all dependencies together inside a single jar. You can include this on your classpath like any 3rd party JAR without having to obtain the *pinecone-client* dependencies separately. [comment]: <> (^ [pc:VERSION_LATEST_RELEASE]) -## Features - -The Java client doesn't support managing Pinecone services, only reading and writing from existing indices. To create or delete an index, use the Python client. - ## Examples -- The data and control plane operations can be found in `io/pinecone/integration` folder. \ No newline at end of file +- The data and control plane operation examples can be found in `io/pinecone/integration` folder. \ No newline at end of file