From 301622216f82d19a708efe2a000df9fec23c1b3e Mon Sep 17 00:00:00 2001 From: mrT23 Date: Tue, 11 Jul 2023 08:50:28 +0300 Subject: [PATCH] Focused PR update --- README.md | 6 +++--- pr_agent/algo/utils.py | 2 +- pr_agent/settings/configuration.toml | 2 +- pr_agent/settings/pr_reviewer_prompts.toml | 10 +++++----- pr_agent/tools/pr_reviewer.py | 2 +- requirements.txt | 1 + tests/unit/test_convert_to_markdown.py | 10 ++++------ tests/unit/test_parse_code_suggestion.py | 6 +++--- 8 files changed, 19 insertions(+), 20 deletions(-) diff --git a/README.md b/README.md index 084bd670..5b1e17af 100644 --- a/README.md +++ b/README.md @@ -186,7 +186,7 @@ Here is a quick overview of the different sub-tools of PR Reviewer: - PR description and title - PR type classification - Is the PR covered by relevant tests - - Is the PR minimal and focused + - Is this a focused PR - Are there security concerns - PR Feedback - General PR suggestions @@ -202,7 +202,7 @@ This is how a typical output of the PR Reviewer looks like: - ๐Ÿ” **Description and title:** Yes - ๐Ÿ“Œ **Type of PR:** Enhancement - ๐Ÿงช **Relevant tests added:** No -- โœจ **Minimal and focused:** Yes, the PR is focused on adding two new handlers for language extension and token counting. +- โœจ **Focused PR:** Yes, the PR is focused on adding two new handlers for language extension and token counting. - ๐Ÿ”’ **Security concerns:** No, the PR does not introduce possible security concerns or issues. #### PR Feedback @@ -245,7 +245,7 @@ The different tools and sub-tools used by CodiumAI pr-agent are easily configura You can enable/disable the different PR Reviewer sub-sections with the following flags: ``` -require_minimal_and_focused_review=true +require_focused_review=true require_tests_review=true require_security_review=true ``` diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index 70994fd8..045144d2 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -12,7 +12,7 @@ def convert_to_markdown(output_data: dict) -> str: "Type of PR": "๐Ÿ“Œ", "Relevant tests added": "๐Ÿงช", "Unrelated changes": "โš ๏ธ", - "Minimal and focused": "โœจ", + "Focused PR": "โœจ", "Security concerns": "๐Ÿ”’", "General PR suggestions": "๐Ÿ’ก", "Code suggestions": "๐Ÿค–" diff --git a/pr_agent/settings/configuration.toml b/pr_agent/settings/configuration.toml index 7368b1eb..50b34cff 100644 --- a/pr_agent/settings/configuration.toml +++ b/pr_agent/settings/configuration.toml @@ -5,7 +5,7 @@ publish_review=true verbosity_level=0 # 0,1,2 [pr_reviewer] -require_minimal_and_focused_review=true +require_focused_review=true require_tests_review=true require_security_review=true extended_code_suggestions=false diff --git a/pr_agent/settings/pr_reviewer_prompts.toml b/pr_agent/settings/pr_reviewer_prompts.toml index 3b3549f0..678c7520 100644 --- a/pr_agent/settings/pr_reviewer_prompts.toml +++ b/pr_agent/settings/pr_reviewer_prompts.toml @@ -30,10 +30,10 @@ You must use the following JSON schema to format your answer: "description": "yes\\no question: does this PR have relevant tests ?" }, {%- endif %} -{%- if require_minimal_and_focused %} - "Minimal and focused": { +{%- if require_focused %} + "Focused PR": { "type": "string", - "description": "is this PR as minimal and focused as possible, with all code changes centered around a single coherent theme, described in the PR description and title ?" Make sure to explain your answer" + "description": "Is this a focused PR, in the sense that it has a clear and coherent title and description, and all PR code diff changes are properly derived from the title and description? Explain your response." } }, {%- endif %} @@ -106,8 +106,8 @@ Example output: {%- if require_tests %} "Relevant tests added": "No", {%- endif %} -{%- if require_minimal_and_focused %} - "Minimal and focused": "yes\\no, because ..." +{%- if require_focused %} + "Focused PR": "yes\\no, because ..." {%- endif %} }, "PR Feedback": diff --git a/pr_agent/tools/pr_reviewer.py b/pr_agent/tools/pr_reviewer.py index b39a231e..97d527c1 100644 --- a/pr_agent/tools/pr_reviewer.py +++ b/pr_agent/tools/pr_reviewer.py @@ -31,7 +31,7 @@ class PRReviewer: "diff": "", # empty diff for initial calculation "require_tests": settings.pr_reviewer.require_tests_review, "require_security": settings.pr_reviewer.require_security_review, - "require_minimal_and_focused": settings.pr_reviewer.require_minimal_and_focused_review, + "require_focused": settings.pr_reviewer.require_focused_review, 'extended_code_suggestions': settings.pr_reviewer.extended_code_suggestions, 'num_code_suggestions': settings.pr_reviewer.num_code_suggestions, } diff --git a/requirements.txt b/requirements.txt index d7610000..e7c6d4c1 100644 --- a/requirements.txt +++ b/requirements.txt @@ -6,3 +6,4 @@ openai==0.27.8 Jinja2==3.1.2 tiktoken==0.4.0 uvicorn==0.22.0 +pytest==7.4.0 \ No newline at end of file diff --git a/tests/unit/test_convert_to_markdown.py b/tests/unit/test_convert_to_markdown.py index 05c84a77..08a49f76 100644 --- a/tests/unit/test_convert_to_markdown.py +++ b/tests/unit/test_convert_to_markdown.py @@ -1,6 +1,6 @@ # Generated by CodiumAI from pr_agent.algo.utils import convert_to_markdown - +import pytest """ Code Analysis @@ -50,7 +50,7 @@ class TestConvertToMarkdown: 'Type of PR': 'Test type', 'Relevant tests added': 'no', 'Unrelated changes': 'n/a', # won't be included in the output - 'Minimal and focused': 'Yes', + 'Focused PR': 'Yes', 'General PR suggestions': 'general suggestion...', 'Code suggestions': [ { @@ -74,12 +74,11 @@ class TestConvertToMarkdown: - ๐Ÿ” **Description and title:** Test description - ๐Ÿ“Œ **Type of PR:** Test type - ๐Ÿงช **Relevant tests added:** no -- โœจ **Minimal and focused:** Yes +- โœจ **Focused PR:** Yes - ๐Ÿ’ก **General PR suggestions:** general suggestion... - ๐Ÿค– **Code suggestions:** -- **suggestion 1:** - **Code example:** - **Before:** ``` @@ -90,7 +89,6 @@ class TestConvertToMarkdown: Code after ``` -- **suggestion 2:** - **Code example:** - **Before:** ``` @@ -116,7 +114,7 @@ class TestConvertToMarkdown: 'Type of PR': {}, 'Relevant tests added': {}, 'Unrelated changes': {}, - 'Minimal and focused': {}, + 'Focused PR': {}, 'General PR suggestions': {}, 'Code suggestions': {} } diff --git a/tests/unit/test_parse_code_suggestion.py b/tests/unit/test_parse_code_suggestion.py index a0da856d..082fed77 100644 --- a/tests/unit/test_parse_code_suggestion.py +++ b/tests/unit/test_parse_code_suggestion.py @@ -47,7 +47,7 @@ class TestParseCodeSuggestion: "Suggestion number": "one", "Description": "This is a suggestion" } - expected_output = "- **suggestion one:**\n - **Description:** This is a suggestion\n\n" + expected_output = " **Description:** This is a suggestion\n\n" assert parse_code_suggestion(input_data) == expected_output # Tests that function returns correct output when 'before' or 'after' key has a non-string value @@ -70,7 +70,7 @@ class TestParseCodeSuggestion: 'before': 'Before 1', 'after': 'After 1' } - expected_output = "- **suggestion 1:**\n - **suggestion:** Suggestion 1\n - **description:** Description 1\n - **before:** Before 1\n - **after:** After 1\n\n" # noqa: E501 + expected_output = " **suggestion:** Suggestion 1\n **description:** Description 1\n **before:** Before 1\n **after:** After 1\n\n" assert parse_code_suggestion(code_suggestions) == expected_output # Tests that function returns correct output when input dictionary has 'code example' key @@ -84,5 +84,5 @@ class TestParseCodeSuggestion: 'after': 'After 2' } } - expected_output = "- **suggestion 2:**\n - **suggestion:** Suggestion 2\n - **description:** Description 2\n - **code example:**\n - **before:**\n ```\n Before 2\n ```\n - **after:**\n ```\n After 2\n ```\n\n" # noqa: E501 + expected_output = " **suggestion:** Suggestion 2\n **description:** Description 2\n - **code example:**\n - **before:**\n ```\n Before 2\n ```\n - **after:**\n ```\n After 2\n ```\n\n" assert parse_code_suggestion(code_suggestions) == expected_output