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

Update PR Review and Description Generation to Use YAML #188

Merged
merged 2 commits into from
Aug 9, 2023

Conversation

mrT23
Copy link
Collaborator

@mrT23 mrT23 commented Aug 9, 2023

PR Type:

Enhancement, Tests


PR Description:

This PR updates the PR review and description generation process to use YAML instead of JSON. It introduces new utility functions to load and fix YAML data, and modifies the existing functions and classes to use these new utilities. The PR also updates the prompts for PR description and review to use YAML schema, and adds unit tests for the new YAML loading function.

Additional change:
the prompt now uses 'Previous title', 'Previous description' and 'Commit messages' . It has the following message to accompany them:
Notice that the 'Previous title', 'Previous description' and 'Commit messages' sections may be partial, simplistic, non-informative or not up-to-date. Hence, compare them to the PR diff code, and use them only as a reference. @zmeir


PR Main Files Walkthrough:

pr_agent/algo/utils.py: Added new functions to load and fix YAML data.
pr_agent/tools/pr_description.py: Updated the PR description preparation process to load data from YAML instead of JSON.
pr_agent/tools/pr_reviewer.py: Updated the PR review preparation process to load data from YAML instead of JSON.
tests/unittest/test_load_yaml.py: Added unit tests for the new YAML loading function.
pr_agent/settings/pr_description_prompts.toml: Updated the PR description prompt to use YAML schema.
pr_agent/settings/pr_reviewer_prompts.toml: Updated the PR reviewer prompt to use YAML schema.

@mrT23 mrT23 changed the title Tr/update review prompt Update PR Review and Description Generation to Use YAML Aug 9, 2023
@mrT23 mrT23 added enhancement New feature or request Tests labels Aug 9, 2023
@mrT23 mrT23 requested a review from okotek August 9, 2023 08:32
@Codium-ai Codium-ai deleted a comment from github-actions bot Aug 9, 2023
@mrT23
Copy link
Collaborator Author

mrT23 commented Aug 9, 2023

PR Analysis

  • 🎯 Main theme: Updating the PR review and description generation process to use YAML instead of JSON
  • 📌 Type of PR: Enhancement
  • 🧪 Relevant tests added: True
  • Focused PR: Yes, the PR is focused on updating the PR review and description generation process to use YAML instead of JSON.
  • 🔒 Security concerns: No security concerns found

PR Feedback

  • General suggestions: The PR is well-structured and the changes are focused on the main theme. The addition of tests for the new functionality is commendable. However, there are some areas where the code could be improved for better readability and maintainability.

  • 🤖 Code feedback:

    • relevant file: pr_agent/algo/utils.py
      suggestion: The load_yaml function could be improved by handling the exception more gracefully. Instead of just logging the error and moving on, it would be better to re-raise the exception after logging it. This would allow the calling code to handle the exception as needed. [important]
      relevant line: logging.error(f"Failed to parse AI prediction: {e}")

    • relevant file: pr_agent/tools/pr_description.py
      suggestion: The load_yaml function is called with self.prediction.strip(). It would be better to strip the prediction once and store it in a variable, instead of stripping it every time it is used. [medium]
      relevant line: data = load_yaml(self.prediction.strip())

    • relevant file: pr_agent/tools/pr_reviewer.py
      suggestion: The load_yaml function is called with self.prediction.strip(). It would be better to strip the prediction once and store it in a variable, instead of stripping it every time it is used. [medium]
      relevant line: data = load_yaml(self.prediction.strip())

yaml

Example output:
```yaml
PR Title: ...
Copy link
Contributor

Choose a reason for hiding this comment

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

Maybe try
PR Title: |-
...

@mrT23
Copy link
Collaborator Author

mrT23 commented Aug 9, 2023

Preparing review...

@mrT23
Copy link
Collaborator Author

mrT23 commented Aug 9, 2023

PR Analysis

  • 🎯 Main theme: Updating the PR review and description generation process to use YAML instead of JSON
  • 📌 Type of PR: Enhancement
  • 🧪 Relevant tests added: True
  • Focused PR: Yes, the PR is focused on updating the PR review and description generation process to use YAML instead of JSON.
  • 🔒 Security concerns: No security concerns found

PR Feedback

  • General suggestions: The PR is well-structured and focused on a specific enhancement. The changes are well-documented and the addition of tests is appreciated. However, there are a few areas where the code could be improved for better readability and maintainability.

  • 🤖 Code feedback:

    • relevant file: pr_agent/algo/utils.py
      suggestion: It's a good practice to avoid using 'pass' in the 'except' block. Instead, consider logging the exception or re-raising it after handling. This would help in debugging if any issues arise in the future. [important]
      relevant line: except:

    • relevant file: pr_agent/tools/pr_description.py
      suggestion: It's recommended to use isinstance() function to check the type of a variable. This is because isinstance() not only checks the type of the variable but also considers the inheritance, which makes it more accurate. [medium]
      relevant line: if type(data['PR Type']) == list:

    • relevant file: pr_agent/tools/pr_reviewer.py
      suggestion: It's a good practice to avoid using 'pass' in the 'except' block. Instead, consider logging the exception or re-raising it after handling. This would help in debugging if any issues arise in the future. [important]
      relevant line: except Exception as e:

@mrT23 mrT23 merged commit 49a3a1e into main Aug 9, 2023
1 check passed
@mrT23 mrT23 deleted the tr/update_review_prompt branch August 9, 2023 11:14
pr_agent/algo/utils.py Show resolved Hide resolved
pr_agent/algo/utils.py Show resolved Hide resolved
pr_agent/tools/pr_description.py Show resolved Hide resolved
pr_agent/tools/pr_description.py Show resolved Hide resolved
pr_agent/tools/pr_reviewer.py Show resolved Hide resolved
pr_agent/tools/pr_reviewer.py Show resolved Hide resolved
pr_agent/tools/pr_reviewer.py Show resolved Hide resolved
tests/unittest/test_load_yaml.py Show resolved Hide resolved
@mrT23
Copy link
Collaborator Author

mrT23 commented Aug 21, 2023

Preparing review...

pr_agent/tools/pr_reviewer.py Show resolved Hide resolved
pr_agent/git_providers/github_provider.py Show resolved Hide resolved
pr_agent/algo/utils.py Show resolved Hide resolved
pr_agent/algo/utils.py Show resolved Hide resolved
pr_agent/tools/pr_reviewer.py Show resolved Hide resolved
pr_agent/tools/pr_description.py Show resolved Hide resolved
pr_agent/tools/pr_description.py Show resolved Hide resolved
pr_agent/tools/pr_reviewer.py Show resolved Hide resolved
yochail pushed a commit to yochail/pr-agent that referenced this pull request Feb 11, 2024
Update PR Review and Description Generation to Use YAML
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request Tests
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants