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

Refactor: Github Service #6580

Merged
merged 17 commits into from
Feb 3, 2025
Merged

Refactor: Github Service #6580

merged 17 commits into from
Feb 3, 2025

Conversation

malhotra5
Copy link
Contributor

@malhotra5 malhotra5 commented Feb 1, 2025

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

  • 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

The motivation for this PR is "separation of concerns" with respect to the GithubService class

We want to the GithubService to

  • Execute all Github API requests
  • Return typed objects (dicts, lists, etc) or raise appropriate exceptions to ensure reliability
  • Never be responsible for constructing JSONResponses for its callers. This is for reusability purposes. The caller of the GithubService class should be responsible for handling the data and constructing the JSONResponses if need be

This PR accomplishes these constraints by -

  1. Removing the GithubTokenMiddleware; token fetching for the user occurs inside GithubService
  2. Returning only typed objects from GithubService
  3. Having the FastAPI endpoints be responsible for constructing JSONResponse objects, rather than delegating that responsibility to GithubService

This achieves "separation of concerns", and better reusability because we can use GithubService in both HTTP and non-HTTP related settings


Link of any specific issues this addresses


To run this PR locally, use the following command:

docker run -it --rm   -p 3000:3000   -v /var/run/docker.sock:/var/run/docker.sock   --add-host host.docker.internal:host-gateway   -e SANDBOX_RUNTIME_CONTAINER_IMAGE=docker.all-hands.dev/all-hands-ai/runtime:3e6c96b-nikolaik   --name openhands-app-3e6c96b   docker.all-hands.dev/all-hands-ai/openhands:3e6c96b

Copy link
Collaborator

@tofarr tofarr left a comment

Choose a reason for hiding this comment

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

🍰 - Just one question (Not a blocker)

@malhotra5 malhotra5 enabled auto-merge (squash) February 3, 2025 17:16
@malhotra5 malhotra5 merged commit 4adef57 into main Feb 3, 2025
15 checks passed
@malhotra5 malhotra5 deleted the refactor/gh-service branch February 3, 2025 17:21
zchn pushed a commit to zchn/OpenHands that referenced this pull request Feb 4, 2025
Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
adityasoni9998 pushed a commit to adityasoni9998/OpenHands that referenced this pull request Feb 7, 2025
Co-authored-by: Engel Nyst <enyst@users.noreply.github.com>
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