Skip to content
Open
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 .cursor/commands/create-improvement.md
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ When the planned code changes are complete, the agent should take the following
- Ensure changes are adequately tested

2. **Create Pull Request**
- Create a PR in draft mode
- Create a PR
- Rename the PR with a title that follows the Conventional Commits 1.0.0 format
- Update the PR description with:
- A clear description of the problem and solution
Expand Down
5 changes: 5 additions & 0 deletions .env.example
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
# Pinecone API Configuration
# Copy this file to .env and fill in your actual API key
# The .env file is gitignored and will not be committed

PINECONE_API_KEY=your-api-key-here
6 changes: 4 additions & 2 deletions .github/workflows/cleanup-test-resources.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ on:
age_threshold_days:
description: 'Minimum age in days for resources to be deleted'
required: false
default: '1'
default: 1
type: number
dry_run:
description: 'Preview deletions without executing (dry-run mode)'
Expand Down Expand Up @@ -63,7 +63,9 @@ jobs:
echo "Running cleanup with: $ARGS"

# Run the cleanup utility
java -cp "build/libs/*:build/classes/java/main" \
# Use only the shadow JAR (-all.jar) which contains all dependencies
# This avoids classpath conflicts from mixing regular JAR, shadow JAR, and other artifacts
java -cp build/libs/*-all.jar \
io.pinecone.helpers.IndexCleanupUtility $ARGS

- name: Summary
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -108,6 +108,6 @@ jobs:
continue-on-error: true
run: |
echo "Running IndexCleanupUtility to clean up test indexes..."
java -cp "build/libs/*" io.pinecone.helpers.IndexCleanupUtility
java -cp build/libs/*-all.jar io.pinecone.helpers.IndexCleanupUtility
env:
PINECONE_API_KEY: ${{ secrets.PINECONE_API_KEY }}
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -81,4 +81,10 @@ nb-configuration.xml
##############################
.DS_Store

##############################
## Environment Variables
##############################
.env
.env.local

gen
24 changes: 19 additions & 5 deletions src/main/java/io/pinecone/helpers/IndexCleanupUtility.java
Original file line number Diff line number Diff line change
@@ -1,13 +1,15 @@
package io.pinecone.helpers;

import io.pinecone.clients.Pinecone;
import okhttp3.OkHttpClient;
import org.openapitools.db_control.client.model.CollectionList;
import org.openapitools.db_control.client.model.CollectionModel;
import org.openapitools.db_control.client.model.IndexList;
import org.openapitools.db_control.client.model.IndexModel;

import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.TimeUnit;

/**
* Utility for cleaning up Pinecone indexes and collections.
Expand Down Expand Up @@ -65,7 +67,17 @@ public static void main(String[] args) {
System.exit(1);
}

Pinecone pinecone = new Pinecone.Builder(apiKey).build();
// Configure OkHttpClient with longer timeouts for delete operations
// Delete operations can take longer, especially for large indexes
OkHttpClient httpClient = new OkHttpClient.Builder()
.connectTimeout(30, TimeUnit.SECONDS)
.readTimeout(120, TimeUnit.SECONDS)
.writeTimeout(30, TimeUnit.SECONDS)
.build();

Pinecone pinecone = new Pinecone.Builder(apiKey)
.withOkHttpClient(httpClient)
.build();
IndexCleanupUtility utility = new IndexCleanupUtility(
pinecone,
parsedArgs.ageThresholdDays,
Expand Down Expand Up @@ -243,8 +255,9 @@ private boolean cleanupIndex(IndexModel index) throws Exception {
pinecone.deleteIndex(indexName);
logInfo("Successfully initiated deletion of index: %s", indexName);

// Add small delay to avoid rate limiting
Thread.sleep(1000);
// Add delay to avoid overwhelming the backend
logInfo("Waiting 30 seconds before next deletion...");
Thread.sleep(30000);
return true;
}

Expand Down Expand Up @@ -279,8 +292,9 @@ private boolean cleanupCollection(CollectionModel collection) throws Exception {
pinecone.deleteCollection(collectionName);
logInfo("Successfully initiated deletion of collection: %s", collectionName);

// Add small delay to avoid rate limiting
Thread.sleep(1000);
// Add delay to avoid overwhelming the backend
logInfo("Waiting 30 seconds before next deletion...");
Thread.sleep(30000);
return true;
}

Expand Down
Loading