From bbaba2dbda77071974543a136486e39842743929 Mon Sep 17 00:00:00 2001 From: mrT23 Date: Mon, 30 Sep 2024 08:05:52 +0300 Subject: [PATCH 1/3] refactor: update terminology for issue review recommendations in utils.py style: refine field descriptions in KeyIssuesComponentLink model --- pr_agent/algo/utils.py | 20 +++++++++----------- pr_agent/settings/pr_reviewer_prompts.toml | 8 ++++---- 2 files changed, 13 insertions(+), 15 deletions(-) diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index 9e12d8a1..f8eca495 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -100,8 +100,8 @@ def convert_to_markdown_v2(output_data: dict, emojis = { "Can be split": "๐Ÿ”€", - "Possible issues": "โšก", "Key issues to review": "โšก", + "Recommended review focus areas": "โšก", "Score": "๐Ÿ…", "Relevant tests": "๐Ÿงช", "Focused PR": "โœจ", @@ -192,23 +192,21 @@ def convert_to_markdown_v2(output_data: dict, if is_value_no(value): if gfm_supported: markdown_text += f"" - markdown_text += f"{emoji} No key issues to review" + markdown_text += f"{emoji} No major issues detected" markdown_text += f"\n" else: - markdown_text += f"### {emoji} No key issues to review\n\n" + markdown_text += f"### {emoji} No major issues detected\n\n" else: - # issues = value.split('\n- ') - issues =value - # for i, _ in enumerate(issues): - # issues[i] = issues[i].strip().strip('-').strip() + issues = value if gfm_supported: markdown_text += f"" - markdown_text += f"{emoji} {key_nice}

\n\n" + # markdown_text += f"{emoji} {key_nice}

\n\n" + markdown_text += f"{emoji} Recommended review focus areas

\n\n" else: - markdown_text += f"### {emoji} Key issues to review\n\n#### \n" + markdown_text += f"### {emoji} Recommended review focus areas\n\n#### \n" for i, issue in enumerate(issues): try: - if not issue: + if not issue or not isinstance(issue, dict): continue relevant_file = issue.get('relevant_file', '').strip() issue_header = issue.get('issue_header', '').strip() @@ -223,7 +221,7 @@ def convert_to_markdown_v2(output_data: dict, issue_str = f"[**{issue_header}**]({reference_link})\n\n{issue_content}\n\n" markdown_text += f"{issue_str}\n\n" except Exception as e: - get_logger().exception(f"Failed to process key issues to review: {e}") + get_logger().exception(f"Failed to process 'Recommended review focus areas': {e}") if gfm_supported: markdown_text += f"\n" else: diff --git a/pr_agent/settings/pr_reviewer_prompts.toml b/pr_agent/settings/pr_reviewer_prompts.toml index 8971bdbf..56e93ce5 100644 --- a/pr_agent/settings/pr_reviewer_prompts.toml +++ b/pr_agent/settings/pr_reviewer_prompts.toml @@ -81,10 +81,10 @@ class SubPR(BaseModel): class KeyIssuesComponentLink(BaseModel): relevant_file: str = Field(description="The full file path of the relevant file") - issue_header: str = Field(description="one or two word title for the the issue. For example: 'Possible Bug', 'Performance Issue', 'Code Smell', etc.") - issue_content: str = Field(description="a short and concise description of the issue that needs to be reviewed") - start_line: int = Field(description="the start line that corresponds to this issue in the relevant file") - end_line: int = Field(description="the end line that corresponds to this issue in the relevant file") + issue_header: str = Field(description="One or two word title for the the issue. For example: 'Possible Bug', 'Performance Issue', 'Code Smell', etc.") + issue_content: str = Field(description="A short and concise summary of what should be further inspected and validated during the PR review process for this issue. Don't state line numbers here") + start_line: int = Field(description="The start line that corresponds to this issue in the relevant file") + end_line: int = Field(description="The end line that corresponds to this issue in the relevant file") class Review(BaseModel): {%- if require_estimate_effort_to_review %} From 454365913f92c4298da68e03d51e36c67496fd0c Mon Sep 17 00:00:00 2001 From: mrT23 Date: Mon, 30 Sep 2024 13:00:01 +0300 Subject: [PATCH 2/3] refactor: update terminology for issue review recommendations in utils.py --- pr_agent/algo/utils.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/pr_agent/algo/utils.py b/pr_agent/algo/utils.py index f8eca495..bd0781ae 100644 --- a/pr_agent/algo/utils.py +++ b/pr_agent/algo/utils.py @@ -101,7 +101,7 @@ def convert_to_markdown_v2(output_data: dict, emojis = { "Can be split": "๐Ÿ”€", "Key issues to review": "โšก", - "Recommended review focus areas": "โšก", + "Recommended focus areas for review": "โšก", "Score": "๐Ÿ…", "Relevant tests": "๐Ÿงช", "Focused PR": "โœจ", @@ -201,9 +201,9 @@ def convert_to_markdown_v2(output_data: dict, if gfm_supported: markdown_text += f"" # markdown_text += f"{emoji} {key_nice}

\n\n" - markdown_text += f"{emoji} Recommended review focus areas

\n\n" + markdown_text += f"{emoji} Recommended focus areas for review

\n\n" else: - markdown_text += f"### {emoji} Recommended review focus areas\n\n#### \n" + markdown_text += f"### {emoji} Recommended focus areas for review\n\n#### \n" for i, issue in enumerate(issues): try: if not issue or not isinstance(issue, dict): @@ -221,7 +221,7 @@ def convert_to_markdown_v2(output_data: dict, issue_str = f"[**{issue_header}**]({reference_link})\n\n{issue_content}\n\n" markdown_text += f"{issue_str}\n\n" except Exception as e: - get_logger().exception(f"Failed to process 'Recommended review focus areas': {e}") + get_logger().exception(f"Failed to process 'Recommended focus areas for review': {e}") if gfm_supported: markdown_text += f"\n" else: From 968fb71577fc57b0997f81d889ea763d21c6ed5c Mon Sep 17 00:00:00 2001 From: mrT23 Date: Mon, 30 Sep 2024 13:03:42 +0300 Subject: [PATCH 3/3] refactor: update terminology for issue review recommendations in utils.py --- tests/unittest/test_convert_to_markdown.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/unittest/test_convert_to_markdown.py b/tests/unittest/test_convert_to_markdown.py index 2eebfdef..8b82677a 100644 --- a/tests/unittest/test_convert_to_markdown.py +++ b/tests/unittest/test_convert_to_markdown.py @@ -53,7 +53,7 @@ class TestConvertToMarkdown: 'relevant_line': '[return ""](https://github.com/Codium-ai/pr-agent-pro/pull/102/files#diff-52d45f12b836f77ed1aef86e972e65404634ea4e2a6083fb71a9b0f9bb9e062fR199)'}]} - expected_output = f'{PRReviewHeader.REGULAR.value} ๐Ÿ”\n\nHere are some key observations to aid the review process:\n\n\n\n\n\n\n
โฑ๏ธ Estimated effort to review: 1 ๐Ÿ”ตโšชโšชโšชโšช
๐Ÿงช No relevant tests
โšก Possible issues: No\n
๐Ÿ”’ No security concerns identified
\n\n\n
Code feedback:\n\n
relevant filepr_agent/git_providers/git_provider.py\n
suggestion      \n\n\n\nConsider raising an exception or logging a warning when \'pr_url\' attribute is not found. This can help in debugging issues related to the absence of \'pr_url\' in instances where it\'s expected. [important]\n\n\n
relevant linereturn ""

\n\n
' + expected_output = f'{PRReviewHeader.REGULAR.value} ๐Ÿ”\n\nHere are some key observations to aid the review process:\n\n\n\n\n\n\n
โฑ๏ธ Estimated effort to review: 1 ๐Ÿ”ตโšชโšชโšชโšช
๐Ÿงช No relevant tests
 Possible issues: No\n
๐Ÿ”’ No security concerns identified
\n\n\n
Code feedback:\n\n
relevant filepr_agent/git_providers/git_provider.py\n
suggestion      \n\n\n\nConsider raising an exception or logging a warning when \'pr_url\' attribute is not found. This can help in debugging issues related to the absence of \'pr_url\' in instances where it\'s expected. [important]\n\n\n
relevant linereturn ""

\n\n
' assert convert_to_markdown_v2(input_data).strip() == expected_output.strip()