Skip to content

Parse connection URL string to autofill indexName, environment, and projectName - #18

Closed
rohanshah18 wants to merge 5 commits into
mainfrom
rohan/parseconnectionurl
Closed

rohanshah18 wants to merge 5 commits into
mainfrom
rohan/parseconnectionurl

Conversation

@rohanshah18

@rohanshah18 rohanshah18 commented Aug 24, 2023 •

Copy link
Copy Markdown
Contributor

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:

  1. Delete connectionConfig class completely and add the members (indexName and customChannelBuilder for custom GRPC calls) in the clientConfig. This approach would have made things cleaner since the end user will only have to define one config object and use it to instantiate the PineconeClient class but the downside was in order for it to be backwards compatible, we'll have to maintain the connectionConfig for a while and secondly, the clientConfig would be bigger and harder to maintain over time.
  2. Create PineconeConfigs class which has clientConfig and connectionConfig. Parse the connection url string as a part of the PineconeConfigs constructor that accepts apiKey and url, and set the values of clientConfig (apiKey, environment, and projectName) as well as of the connectionConfig (indexName). If the user is now interested in setting serverSideTimeouts to clientConfig or use customChannelBuilder of connectionConfig, they can do so by extracting the config objects and use there respective .with().

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

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update
  • Infrastructure change (CI configs, etc)
  • Non-code change (docs, etc)
  • None of the above: (explain here)

Test Plan

A series of unit tests have been added. The follow up subtask to this ticket is integration test.

@rohanshah18
rohanshah18 marked this pull request as ready for review August 24, 2023 18:53
connectionConfig = connectionConfig.withIndexName(indexName);
}
else {
throw new PineconeValidationException("Unable to parse connection url");

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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() {

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

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.

@jhamon

jhamon commented Aug 25, 2023

Copy link
Copy Markdown
Contributor

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 jhamon left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Approving based on our in-person group review today

@austin-denoble austin-denoble left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

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.

Comment on lines +6 to +7
import java.util.regex.Matcher;
import java.util.regex.Pattern;

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

nit / question: Are these imports actually needed in this file?

@rohanshah18
rohanshah18 deleted the rohan/parseconnectionurl branch July 10, 2024 21:23
jhamon added a commit that referenced this pull request Nov 12, 2026
* 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.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants