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

[Resolver] (refactor) Generalize the resolver #6125

Draft
wants to merge 18 commits into
base: main
Choose a base branch
from

Conversation

cuococarlos
Copy link

End-user friendly description of the problem this fixes or functionality that this introduces

This PR separates the logic of GitHub from the resolver component. The final objective is for OpenHands to use in various code repositories, not just GitHub.
This PR has two steps to achieve the objective:

  • A new handler to manage all pull requests and issue logic

  • Make the resolver's GitHub-related logic more abstract and give GitHub's logic to the GithubIssueHandler class.

  • Include this change in the Release Notes. If checked, you must provide an end-user friendly description for your change below


Give a summary of what the PR does, explaining any non-trivial design decisions

Here are some important decisions:

  • Move all the Github logic to the new file. Openhands/resolver/github.py will create GithubIssueHandler and GithubPRHandler.
  • Make the classes that were Github-specific general so that they can fulfill an interface. This will allow new classes to be generated that can be adapted to other solutions.
  • Adapt the tests for the above changes.

Link of any specific issues this addresses
[Resolver]: Gitlab support #5210

@cuococarlos cuococarlos changed the title [Resolver] (refactor) Generalize the resolver to [Resolver] (refactor) Generalize the resolver Jan 7, 2025
@neubig neubig requested review from neubig and malhotra5 January 8, 2025 04:19
Copy link
Contributor

@malhotra5 malhotra5 left a comment

Choose a reason for hiding this comment

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

I really like where this is going, with respect to create a ServiceContext layer into where the IssueHandler can be interchangeable!

I've left some feedback regarding the granularity of the abstraction; LMK what you think!

self.owner = owner
self.repo = repo
self.token = token
def __init__(self, strategy, llm_config: LLMConfig):
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
def __init__(self, strategy, llm_config: LLMConfig):
def __init__(self, strategy: IssueHandlerInterface, llm_config: LLMConfig):

It would be nice to add typing to strategy; same for other places where strategy is used

from openhands.resolver.utils import extract_issue_references


class IssueHandlerInterface(ABC):
Copy link
Contributor

Choose a reason for hiding this comment

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

Just to confirm, when supporting Gitlab all of these interface methods will be implemented?

I'd assume yes, but want to double check

@@ -6,7 +6,7 @@ class ReviewThread(BaseModel):
files: list[str]


class GithubIssue(BaseModel):
class Issue(BaseModel):
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we add another field Source, which would be either an enum Github or Gitlab?

Comment on lines +446 to +450
all_issues = [
issue
for issue in all_issues
if issue['number'] in issue_numbers and 'pull_request' not in issue
]
Copy link
Contributor

Choose a reason for hiding this comment

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

Could we do these checks in the GithubHandler? I'm thinking the following

  1. The handler pulls all the issues and relevant context, and normalizes the data to follow the structure in openhands/resolver/issue.py
  2. The service context will return details of the context (the issue itself), and all instruction prompts for the resolver task/guessing success

This is for pull requests but similar idea applies to regular issues

@@ -0,0 +1,481 @@
from abc import ABC, abstractmethod
Copy link
Contributor

Choose a reason for hiding this comment

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

NIT:

  1. Can we create a subfolder at this directory level
  2. In the subfolder, a file which contains the interface definition
  3. In the same subfolder, the file github.py that implements the interface

When adding Gitlab support, I'd imagine we just need to create another file gitlab.py in this subfolder

),
None,
# Handle PRs with file-specific review comments
if issue.review_threads:
Copy link
Contributor

Choose a reason for hiding this comment

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

In Github, we have review_threads, thread_comments, and review_comments

Is this same in Gitlab? Reason I ask, is because I'd imagine the next step from this PR is to create a GitlabHandler which can be plugged right into ServiceContext

If Github and Gitlab don't match on this terminology, we may need to do further abstracting on the IssueHandler level? LMK what you think!

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.

5 participants