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

Update changelogs, examples, and readme #52

Merged
merged 3 commits into from
Dec 18, 2023
Merged
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
5 changes: 4 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
14 changes: 4 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,30 +15,24 @@ Maven:
<dependency>
<groupId>io.pinecone</groupId>
<artifactId>pinecone-client</artifactId>
<version>0.2.3</version>
<version>0.7.0</version>
</dependency>
```

[comment]: <> (^ [pc:VERSION_LATEST_RELEASE])

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.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 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.
- The data and control plane operation examples can be found in `io/pinecone/integration` folder.
Original file line number Diff line number Diff line change
Expand Up @@ -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
rohanshah18 marked this conversation as resolved.
Show resolved Hide resolved
UpsertRequest upsertRequest = UpsertRequest.newBuilder()
.addVectors(v1)
.addVectors(v2)
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1 +1 @@
pineconeClientVersion = 0.6.0
pineconeClientVersion = 0.7.0
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
Original file line number Diff line number Diff line change
@@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
@@ -1,59 +1,39 @@
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.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.createIndexIfNotExistsDataPlane;
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 VectorServiceGrpc.VectorServiceBlockingStub blockingStub;

private PineconeClient dataPlaneClient;
private PineconeIndexOperationClient controlPlaneClient;

@BeforeEach
public void setUp() {
PineconeClientConfig config = new PineconeClientConfig()
.withApiKey(System.getenv("PINECONE_API_KEY"))
.withEnvironment(System.getenv("PINECONE_ENVIRONMENT"))
.withServerSideTimeoutSec(10);

controlPlaneClient = new PineconeIndexOperationClient(config);
dataPlaneClient = new PineconeClient(config);
@BeforeAll
public static void defineConfig() throws IOException, InterruptedException {
PineconeConnection connection = createIndexIfNotExistsDataPlane(3);
blockingStub = connection.getBlockingStub();
}

@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);
String host = indexMeta.getStatus().getHost();
PineconeConnection conn = dataPlaneClient.connect(
new PineconeConnectionConfig()
.withConnectionUrl("https://" + host));

public void sanity() {
String namespace = RandomStringBuilder.build("ns", 8);

// upsert
Expand All @@ -76,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);

Expand All @@ -100,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<String> 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
Expand All @@ -116,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.
Expand All @@ -145,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));
Expand All @@ -159,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));
Expand All @@ -172,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));
Expand All @@ -185,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
Expand All @@ -196,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);
}
}