Skip to content
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
40 changes: 34 additions & 6 deletions .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,10 +14,10 @@
matrix:
os: [ubuntu-latest]
versions: [
{ java: 8, gradle: 6.8 },
{ java: 11, gradle: 6.8 },
{ java: 16, gradle: 7.3.1 },
{ java: 17, gradle: 7.3.1 }
{ java: 8, gradle: 8.5 },
{ java: 11, gradle: 8.5 },
{ java: 16, gradle: 8.5 },
{ java: 17, gradle: 8.5 }
]
runs-on: ${{ matrix.os }}
steps:
Expand Down Expand Up @@ -55,8 +55,8 @@
matrix:
os: [ubuntu-latest]
versions: [
{ java: 8, gradle: 6.8 },
{ java: 17, gradle: 7.3.1 }
{ java: 8, gradle: 8.5 },
{ java: 17, gradle: 8.5 }
]
steps:
- uses: actions/checkout@v4
Expand All @@ -83,3 +83,31 @@
env:
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }}
PINECONE_ENVIRONMENT: ${{ secrets.PINECONE_ENVIRONMENT }}

cleanup:
runs-on: ubuntu-latest
needs: [build, integration-test]
if: always()
steps:
- uses: actions/checkout@v4

- uses: actions/setup-java@v4
with:
distribution: temurin
java-version: 17

- name: Setup Gradle
uses: gradle/actions/setup-gradle@v3
with:
gradle-version: 8.5

- name: Build project
run: gradle clean build

- name: Cleanup Test Indexes
continue-on-error: true
run: |
echo "Running IndexCleanupUtility to clean up test indexes..."
java -cp "build/libs/*" io.pinecone.helpers.IndexCleanupUtility
env:
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }}
26 changes: 13 additions & 13 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
plugins {
id 'com.github.johnrengelman.shadow' version '6.1.0'
id 'com.github.johnrengelman.shadow' version '8.1.1'
id 'java-library'
id 'maven-publish'
id 'signing'
Expand Down Expand Up @@ -150,21 +150,21 @@ task integrationTest(type: Test) {
outputs.upToDateWhen { false }
}

// Configure Auto Relocation
import com.github.jengelman.gradle.plugins.shadow.tasks.ConfigureShadowRelocation

task relocateShadowJar(type: ConfigureShadowRelocation) {
target = tasks.shadowJar
prefix = "io.pinecone.shadow" // Default value is "shadow"

}

tasks.shadowJar.dependsOn tasks.relocateShadowJar

// Shadow META-INF directory
// Configure Shadow JAR with relocations and transformers
import com.github.jengelman.gradle.plugins.shadow.transformers.ServiceFileTransformer

shadowJar {
relocate 'io.grpc', 'io.pinecone.shadow.io.grpc'
relocate 'com.google', 'io.pinecone.shadow.com.google'
relocate 'org.slf4j', 'io.pinecone.shadow.org.slf4j'
relocate 'okhttp3', 'io.pinecone.shadow.okhttp3'
relocate 'okio', 'io.pinecone.shadow.okio'
relocate 'com.fasterxml', 'io.pinecone.shadow.com.fasterxml'
relocate 'com.google.gson', 'io.pinecone.shadow.com.google.gson'
relocate 'io.gsonfire', 'io.pinecone.shadow.io.gsonfire'
relocate 'org.openapitools', 'io.pinecone.shadow.org.openapitools'
relocate 'com.google.protobuf', 'io.pinecone.shadow.com.google.protobuf'
relocate 'org.apache.tomcat', 'io.pinecone.shadow.org.apache.tomcat'
transform(ServiceFileTransformer)
}

Expand Down
2 changes: 1 addition & 1 deletion gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-6.8-bin.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-8.5-bin.zip
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@
import static io.pinecone.helpers.TestUtilities.*;
import static org.junit.jupiter.api.Assertions.*;

@Disabled
public class CollectionTest {
private static final TestResourcesManager indexManager = TestResourcesManager.getInstance();
private static final Pinecone pineconeClient = new Pinecone
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,12 @@
import io.pinecone.clients.Pinecone;
import io.pinecone.helpers.RandomStringBuilder;
import org.junit.jupiter.api.Assertions;
import org.junit.jupiter.api.Disabled;
import org.junit.jupiter.api.Test;
import org.openapitools.db_control.client.model.DeletionProtection;
import org.openapitools.db_control.client.model.IndexModel;

@Disabled
public class DeletionProtectionTest {
private static final Pinecone controlPlaneClient = new Pinecone
.Builder(System.getenv("PINECONE_API_KEY"))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,11 +74,7 @@ public void upsertAndSearchRecordsTest() throws ApiException, org.openapitools.d
// Wait for vectors to be upserted
Thread.sleep(5000);

SearchRecordsResponse recordsResponse = index.searchRecords(namespace, query, fields, null);
Assertions.assertEquals(upsertRecords.size(), recordsResponse.getResult().getHits().size());
Assertions.assertEquals(record3.get("_id"), recordsResponse.getResult().getHits().get(0).getId());

recordsResponse = index.searchRecordsById(record1.get("_id"), namespace, fields, 1, null, null);
SearchRecordsResponse recordsResponse = index.searchRecordsById(record1.get("_id"), namespace, fields, 1, null, null);
Assertions.assertEquals(1, recordsResponse.getResult().getHits().size());
Assertions.assertEquals(record1.get("_id"), recordsResponse.getResult().getHits().get(0).getId());

Expand Down
36 changes: 36 additions & 0 deletions src/main/java/io/pinecone/helpers/IndexCleanupUtility.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
package io.pinecone.helpers;

import io.pinecone.clients.Pinecone;
import org.openapitools.db_control.client.model.DeletionProtection;
import org.openapitools.db_control.client.model.IndexModel;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

public class IndexCleanupUtility {
private static final Logger logger = LoggerFactory.getLogger(IndexCleanupUtility.class);

public static void main(String[] args) {
try {
logger.info("Starting Pinecone index cleanup...");
Pinecone pinecone = new Pinecone.Builder(System.getenv("PINECONE_API_KEY")).build();

for(IndexModel model : pinecone.listIndexes().getIndexes()) {
String indexName = model.getName();
if(model.getDeletionProtection().equals(DeletionProtection.ENABLED)) {
if(model.getSpec().getPod() != null) {
pinecone.configurePodsIndex(indexName, DeletionProtection.DISABLED);
}
pinecone.configureServerlessIndex(indexName, DeletionProtection.DISABLED, null, null);
}
Thread.sleep(5000);
pinecone.deleteIndex(indexName);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There's a small chance the index may not be deletable if it's stuck in an upgrading or stuck or something like that. It might be nice to add a try catch here and explicitly handle possible errors on delete to make sure the cleanup process continues to other indexes.

}

logger.info("Index cleanup completed");

} catch (Exception e) {
logger.error("Error during cleanup: {}", e.getMessage(), e);
System.exit(1);
}
}
}
Loading