Skip to content
This repository was archived by the owner on Sep 30, 2024. It is now read-only.

refactor(cody): Reshape the CompletionsClient interface#63358

Merged
emidoots merged 4 commits into
mainfrom
chrsmith/refactor-completionsclient
Jun 20, 2024
Merged

refactor(cody): Reshape the CompletionsClient interface#63358
emidoots merged 4 commits into
mainfrom
chrsmith/refactor-completionsclient

Conversation

@chrsmith

Copy link
Copy Markdown
Contributor

This PR refactors the CompletionsClient interface, and all the corresponding call sites. There is no functional change, beyond bundling several function parameters into a new type.

See internal/completions/types/types.go. But the gist is this putting 3x parameters into a single CompletionRequest type.

	Complete(
            context.Context,
            log.Logger
-           CompletionsFeature,
-           CompletionsVersion,
-           CompletionRequestParameters
+           CompletionRequest
        ) (*CompletionResponse, error)

Why?

As part of reworking the codepath between receiving a completion request, dispatching it to the right CompletionsClient implementation, and serving the request, I need some "hooks" to inject new information.

In a future PR I plan on adding a *ServerSideModelConfig as another field to the CompletionRequest, so that when the CompletionClient's implementation is trying to serve that request it has any additional data it needs. (For example, the AWS Bedrock provisioned capacity ARN, etc.)

Test plan

Updated existing tests, relying on CI/CD for any other issues.

Changelog

NA, just some under the hood refactoring that shouldn't impact any functionality.

@chrsmith chrsmith requested a review from emidoots June 19, 2024 22:00
@cla-bot cla-bot Bot added the cla-signed label Jun 19, 2024
) (*types.CompletionResponse, error) {
request types.CompletionRequest) (*types.CompletionResponse, error) {

feature := request.Feature

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.

If we want to do a more invasive refactoring, we can probably just remove these local params and instead have request.Feature be used in-line. But doing this "explode the type into local variables" lead to the smallest diff.

@emidoots emidoots 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 - yep, makes sense

@emidoots

Copy link
Copy Markdown
Member

Gonna go ahead and merge because I know someone else is working on this same code, to spare some conflicts.

@emidoots emidoots merged commit 4613452 into main Jun 20, 2024
@emidoots emidoots deleted the chrsmith/refactor-completionsclient branch June 20, 2024 02:17
@Chickensoupwithrice Chickensoupwithrice added backport 5.4.5099 label used to backport PRs to the 5.4.5099 release branch backports labels Jun 20, 2024
@sourcegraph-release-bot

Copy link
Copy Markdown
Collaborator

The backport to 5.4.5099 failed at https://github.com/sourcegraph/sourcegraph/actions/runs/9603516068:

The process '/usr/bin/git' failed with exit code 1

To backport this PR manually, you can either:

Via the sg tool

Use the sg backport command to backport your commit to the release branch.

sg backport -r 5.4.5099 -p 63358
Via your terminal

To backport manually, run these commands in your terminal:

# Fetch latest updates from GitHub
git fetch
# Create a new working tree
git worktree add .worktrees/backport-5.4.5099 5.4.5099
# Navigate to the new working tree
cd .worktrees/backport-5.4.5099
# Create a new branch
git switch --create backport-63358-to-5.4.5099
# Cherry-pick the merged commit of this pull request and resolve the conflicts
git cherry-pick -x --mainline 1 46134524c79dd2b30b619b17d3a30ac61aeb9295
# Push it to GitHub
git push --set-upstream origin backport-63358-to-5.4.5099
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-5.4.5099

If you encouter conflict, first resolve the conflict and stage all files, then run the commands below:

git cherry-pick --continue
# Push it to GitHub
git push --set-upstream origin backport-63358-to-5.4.5099
# Go back to the original working tree
cd ../..
# Delete the working tree
git worktree remove .worktrees/backport-5.4.5099
  • Follow above instructions to backport the commit.
  • Create a pull request where the base branch is 5.4.5099 and the compare/head branch is backport-63358-to-5.4.5099., click here to create the pull request.

Once the pull request has been created, please ensure the following:

  • Make sure to tag @sourcegraph/release in the pull request description.

  • kindly remove the release-blocker from this pull request.

@sourcegraph-release-bot sourcegraph-release-bot added failed-backport-to-5.4.5099 release-blocker Prevents us from releasing: https://about.sourcegraph.com/handbook/engineering/releases labels Jun 20, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

backport 5.4.5099 label used to backport PRs to the 5.4.5099 release branch backports cla-signed failed-backport-to-5.4.5099 release-blocker Prevents us from releasing: https://about.sourcegraph.com/handbook/engineering/releases

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants