Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[feat] Create endpoints to handle reviewing a PR and checking state of the review #1478

Merged
merged 2 commits into from
Nov 22, 2024
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
18 changes: 17 additions & 1 deletion src/seer/app.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,16 @@
)
from seer.automation.codebase.repo_client import RepoClient
from seer.automation.codegen.models import (
CodegenPrReviewRequest,
CodegenPrReviewResponse,
CodegenPrReviewStateRequest,
CodegenPrReviewStateResponse,
CodegenUnitTestsRequest,
CodegenUnitTestsResponse,
CodegenUnitTestsStateRequest,
CodegenUnitTestsStateResponse,
)
from seer.automation.codegen.tasks import codegen_unittest, get_unittest_state
from seer.automation.codegen.tasks import codegen_pr_review, codegen_unittest, get_unittest_state
from seer.automation.summarize.issue import run_summarize_issue
from seer.automation.summarize.models import SummarizeIssueRequest, SummarizeIssueResponse
from seer.automation.utils import raise_if_no_genai_consent
Expand Down Expand Up @@ -260,6 +264,18 @@ def codegen_unit_tests_state_endpoint(
)


@json_api(blueprint, "/v1/automation/codegen/pr-review")
def codegen_pr_review_endpoint(data: CodegenPrReviewRequest) -> CodegenPrReviewResponse:
return codegen_pr_review(data)


@json_api(blueprint, "/v1/automation/codegen/pr-review/state")
def codegen_pr_review_state_endpoint(
data: CodegenPrReviewStateRequest,
) -> CodegenPrReviewStateResponse:
raise NotImplementedError("PR Review state is not implemented yet.")


@json_api(blueprint, "/v1/automation/summarize/issue")
def summarize_issue_endpoint(data: SummarizeIssueRequest) -> SummarizeIssueResponse:
return run_summarize_issue(data)
Expand Down
22 changes: 22 additions & 0 deletions src/seer/automation/codegen/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,11 @@ class CodegenUnitTestsRequest(BaseModel):
pr_id: int # The PR number


class CodegenPrReviewRequest(BaseModel):
repo: RepoDefinition
pr_id: int # The PR number


class CodegenContinuation(CodegenState):
request: CodegenUnitTestsRequest

Expand All @@ -52,6 +57,10 @@ class CodegenUnitTestsResponse(BaseModel):
run_id: int


class CodegenPrReviewResponse(BaseModel):
run_id: int


class CodegenUnitTestsStateRequest(BaseModel):
run_id: int

Expand All @@ -63,3 +72,16 @@ class CodegenUnitTestsStateResponse(BaseModel):
triggered_at: datetime.datetime
updated_at: datetime.datetime
completed_at: datetime.datetime | None = None


class CodegenPrReviewStateRequest(BaseModel):
run_id: int


class CodegenPrReviewStateResponse(BaseModel):
run_id: int
status: CodegenStatus
changes: list[FileChange]
Copy link
Member

Choose a reason for hiding this comment

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

Are file changes the right data type here or is this just a placeholder?

Copy link
Member Author

Choose a reason for hiding this comment

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

Placeholder for now, will update with implementation.

triggered_at: datetime.datetime
updated_at: datetime.datetime
completed_at: datetime.datetime | None = None
5 changes: 5 additions & 0 deletions src/seer/automation/codegen/tasks.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from celery_app.config import CeleryQueues
from seer.automation.codegen.models import (
CodegenContinuation,
CodegenPrReviewRequest,
CodegenStatus,
CodegenUnitTestsRequest,
CodegenUnitTestsResponse,
Expand Down Expand Up @@ -46,3 +47,7 @@ def codegen_unittest(request: CodegenUnitTestsRequest):
def get_unittest_state(request: CodegenUnitTestsStateRequest):
state = CodegenContinuationState.from_id(request.run_id, model=CodegenContinuation)
return state.get()


def codegen_pr_review(request: CodegenPrReviewRequest):
raise NotImplementedError("PR Review is not implemented yet.")
Loading