Repository navigation
Parse connection URL string to autofill indexName, environment, and projectName - #18
rohanshah18 wants to merge 5 commits into
Conversation
| connectionConfig = connectionConfig.withIndexName(indexName); | ||
| } | ||
| else { | ||
| throw new PineconeValidationException("Unable to parse connection url"); |
There was a problem hiding this comment.
Throwing exception if the url wasn't parsable but please feel free to comment on if this user flow doesn't look good. Another option is to return a new PineconeClientConfig with new PineconeClientConfig and PineconeConnectionConfig but the values (apiKey, env, projectName, and indexName) will not be set. So it'll throw invalidException.
| private PineconeClientConfig clientConfig; | ||
| private PineconeConnectionConfig connectionConfig; | ||
|
|
||
| public PineconeConfigs() { |
There was a problem hiding this comment.
I can initialize both config objects as a part of default constructor but if the 3 values are not passed, there's no need for new config objects since the user will instantiate both configs using .withClientConfig and .withConnectionConfig methods. But please validate this logic.
|
I have another meeting starting so I can't go through this line by line to give final approval just yet, but I'm happy to see you adding a good number of unit tests. For something like this, reliability is the most important thing so we should be very thorough in testing this. |
jhamon
left a comment
There was a problem hiding this comment.
Approving based on our in-person group review today
austin-denoble
left a comment
There was a problem hiding this comment.
Nice work here, I appreciate the detailed walkthrough you gave us earlier around the approach. Overall this looks good to me, I think for now wrapping things inside PineconeConfigs makes a lot of sense.
Approving, I'm also going to walk through the steps to get things setup locally to validate the approach there.
| } | ||
| else { | ||
| throw new PineconeValidationException("Unable to parse connection url"); | ||
| throw new PineconeValidationException("Unable to parse connection url " + connectionUrl); |
There was a problem hiding this comment.
I think we're missing an if-else condition where we check for the v4 url pattern. In that case we want to save the connecutionUrl and not throw an error here.
| import java.util.regex.Matcher; | ||
| import java.util.regex.Pattern; |
There was a problem hiding this comment.
nit / question: Are these imports actually needed in this file?
* ci: build once in pr.yml, cancel superseded runs, cap job time - The build job's three Gradle steps (clean build, a no-op jar, compileIntegrationTestJava) become one `./gradlew build compileIntegrationTestJava`. - The integration-test job no longer runs a redundant `clean build`; it runs only `./gradlew integrationTest`, which compiles what it needs. - The cleanup job builds only `shadowJar` (3.7 s) instead of a clean build (14.7 s, measured locally). - Every call uses the committed wrapper (pinned to Gradle 8.5), so the per-matrix gradle-version inputs are gone and the matrix is a plain list. - A top-level concurrency group cancels a PR's older run on a new push. Pushes to main and manual dispatches get one group per run. A cancelled run still runs its always() cleanup, which deletes only that run's resources. - timeout-minutes on every job: build 20, integration-test 45, cleanup 15. Verified: offline build green (97 unit tests); actionlint and a YAML parse pass. The workflow has not run in CI yet. * test: keep the cause in AssertRetry and skip the sleep after the last try AssertRetry threw a new AssertionError holding only the last message, which dropped the stack trace of the real failure. It also slept after the final attempt for no reason. It now rethrows with the last failure as the cause and returns as soon as an attempt passes. The class moves from src/integration to src/test (integration code still sees it through test.output) so four new keyless unit tests cover success, eventual success, exhaustion with cause, and no trailing sleep. Verified: offline build green, unit tests +4. * ci: upload test reports on failure, summarize counts, preflight the key - When a test job fails, pr.yml uploads build/reports/tests and build/test-results as an artifact named for the job and JDK. - Each Gradle Test task appends its passed/failed/skipped counts to $GITHUB_STEP_SUMMARY, so the run page shows them without opening logs. - Jobs that need PINECONE_API_KEY fail in a first step with one clear error when the secret is empty, instead of a cascade of test failures. Verified: actionlint and a YAML parse pass; offline build green. Not yet exercised in CI. * test: log integration tests at INFO with timestamps and show stderr src/test/resources sets slf4j-simple to trace, and that file is also on the integration classpath, so live runs either flooded the log or showed nothing useful. integrationTest now sets slf4j-simple to INFO with HH:mm:ss.SSS timestamps through system properties, and adds STANDARD_ERROR to the test logging events so client and fixture logs reach the CI output. TestResourcesManager logs under its own logger name (it used TestUtilities.class) and logs each index and collection it creates. Verified: live ListEndpointTest on a disposable project printed timestamped INFO lines (24 lines in total, no TRACE/DEBUG); offline build green. * test: run pod-index tests only on opt-in Pod indexes count against a per-project pod quota (20 for the CI project). Several PR runs at once exhaust it and fail with 403 "You've reached the max pods allowed in project". The 7 classes that create or use a pod index are now @tag("pod"), and integrationTest excludes that tag unless Gradle gets -PincludePodTests=true. The nightly full suite passes the flag; PR CI needs no workflow change. The shared pod fixture in TestResourcesManager is created lazily, and only pod-tagged classes ask for it. Tagged: pod/CollectionTest, pod/ConfigureIndexTest, pod/CreateDescribeListAndDeleteIndexTest, pod/DeletionProtectionTest, UpdateFetchAndQueryPodTest, UpsertAndQueryPodTest, UpsertDescribeIndexStatsAndDeletePodTest. Verified: offline build green (97 unit tests). Live on a disposable project: default integrationTest 72/72 in 248 s, 0 pod classes run, pod count unchanged at its pre-existing 6. With -PincludePodTests=true --tests '*UpsertAndQueryPodTest': 4/4, pod count 6 -> 7 -> 6.
Problem
Connection url contains indexName, environment, and projectName but currently these values are manually set by the users.
Solution
To reduce user errors, parse the connection url string to get indexName, environment, and projectName and add them to the configurations.
There are two config classes, PineconeClientConfig (will refer as clientConfig) and PineconeConnectionConfig (will refer as connectionConfig). The clientConfig contains environment and projectName, and connectionConfig contains indexName, so there were two approaches possible to set these values:
Below is the sample of how this config will be consumed:
PineconeConfigs configs = new PineconeConfigs("apiKey", "url");
PineconeClient pineconeClient = new PineconeClient(configs.getClientConfig());
PineconeConnection connection = pineconeClient.connect(configs.getConnectionConfig());
connection.doVectorOperations()
Also, note that this can be improved even further as shown below by adding an overloaded constructor in Pineconeclient class as shown below but in order for the user to set serverSideTimeout or use the custom GRPC channel, they'll have to extract the configs from PineconeConfigs. So the code below can be only helpful if the user is fine with the default serverSideTimeout and GRPC channel:
PineconeClient client = new PineconeClient();
PineconeConnection connection = client.connect("apiKey", "url");
Type of Change
Test Plan
A series of unit tests have been added. The follow up subtask to this ticket is integration test.