-
Notifications
You must be signed in to change notification settings - Fork 621
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
Enhancement: Implement label case conversion and update label descriptions in settings files #530
Conversation
/describe |
PR Analysis
PR Feedback
How to useInstructions
|
PR Code Suggestions💡 Suggestion: Use a dictionary comprehension to create File: pr_agent/algo/utils.py (382-389) Example code:Existing code: counter = 0
labels_minimal_to_labels_dict = {}
for k, v in labels.items():
description = "'" + v['description'].strip('\n').replace('\n', '\\n') + "'"
variables["custom_labels_class"] += f"\n {k.lower().replace(' ', '_')} = {description}"
labels_minimal_to_labels_dict[k.lower().replace(' ', '_')] = k
counter += 1
variables["labels_minimal_to_labels_dict"] = labels_minimal_to_labels_dict Improved code: labels_minimal_to_labels_dict = {k.lower().replace(' ', '_'): k for k in labels.keys()}
for k, v in labels.items():
description = "'" + v['description'].strip('\n').replace('\n', '\\n') + "'"
variables["custom_labels_class"] += f"\n {k.lower().replace(' ', '_')} = {description}"
variables["labels_minimal_to_labels_dict"] = labels_minimal_to_labels_dict 💡 Suggestion: Use list comprehension to convert lowercase labels to original case for better readability and performance. File: pr_agent/tools/pr_description.py (209-216) Example code:Existing code: try:
if "labels_minimal_to_labels_dict" in self.variables:
d: dict = self.variables["labels_minimal_to_labels_dict"]
for i, label_i in enumerate(pr_types):
if label_i in d:
pr_types[i] = d[label_i]
except Exception as e:
get_logger().error(f"Error converting labels to original case {self.pr_id}: {e}") Improved code: try:
if "labels_minimal_to_labels_dict" in self.variables:
d: dict = self.variables["labels_minimal_to_labels_dict"]
pr_types = [d[label_i] if label_i in d else label_i for label_i in pr_types]
except Exception as e:
get_logger().error(f"Error converting labels to original case {self.pr_id}: {e}") 💡 Suggestion: Use list comprehension to convert lowercase labels to original case for better readability and performance. File: pr_agent/tools/pr_generate_labels.py (175-182) Example code:Existing code: try:
if "labels_minimal_to_labels_dict" in self.variables:
d: dict = self.variables["labels_minimal_to_labels_dict"]
for i, label_i in enumerate(pr_types):
if label_i in d:
pr_types[i] = d[label_i]
except Exception as e:
get_logger().error(f"Error converting labels to original case {self.pr_id}: {e}") Improved code: try:
if "labels_minimal_to_labels_dict" in self.variables:
d: dict = self.variables["labels_minimal_to_labels_dict"]
pr_types = [d[label_i] if label_i in d else label_i for label_i in pr_types]
except Exception as e:
get_logger().error(f"Error converting labels to original case {self.pr_id}: {e}") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hagai comment:
enable to write the walkthrough for this file directly here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
Enhancement: Implement label case conversion and update label descriptions in settings files
/describe |
PR Description updated to latest commit (1c4e643)
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
test
/describe |
PR Description updated to latest commit (1c4e643)
|
User description
Type
Enhancement
Description
This PR introduces a new feature that allows for label case conversion and updates label descriptions in settings files. The main changes include:
set_custom_labels
function inpr_agent/algo/utils.py
._get_prediction
function inpr_agent/tools/pr_description.py
andpr_agent/tools/pr_generate_labels.py
to set thevariables
attribute._prepare_labels
function inpr_agent/tools/pr_description.py
andpr_agent/tools/pr_generate_labels.py
to convert lowercase labels to their original case.labels
field inpr_agent/settings/pr_custom_labels.toml
andpr_agent/settings/pr_description_prompts.toml
.PR changes walkthrough
3 files
utils.py
pr_agent/algo/utils.py
Added a counter and a dictionary to map minimal labels to
original labels in the `set_custom_labels` function.
pr_description.py
pr_agent/tools/pr_description.py
Updated the `_get_prediction` function to set the
`variables` attribute and added a block of code in the
`_prepare_labels` function to convert lowercase labels to
their original case.
pr_generate_labels.py
pr_agent/tools/pr_generate_labels.py
Updated the `_get_prediction` function to set the
`variables` attribute and added a block of code in the
`_prepare_labels` function to convert lowercase labels to
their original case.
2 files
pr_custom_labels.toml
pr_agent/settings/pr_custom_labels.toml
Updated the description of the `labels` field.
pr_description_prompts.toml
pr_agent/settings/pr_description_prompts.toml
Updated the description of the `labels` field.
Type
Enhancement
Description
set_custom_labels
by adding a counter and a mapping dictionary.Changes walkthrough
utils.py
Enhance label handling in set_custom_labels function
pr_agent/algo/utils.py
expression.
pr_description.py
Update label handling and case conversion in PR description tool
pr_agent/tools/pr_description.py
variables
attribute after setting custom labels.dictionary.
pr_generate_labels.py
Update label handling and case conversion in PR label generation tool
pr_agent/tools/pr_generate_labels.py
variables
attribute after setting custom labels.pr_custom_labels.toml
Update label field description in custom labels settings
pr_agent/settings/pr_custom_labels.toml
labels
field to clarify the usage oflabel keys and meanings.
pr_description_prompts.toml
Update label field description in description prompts settings
pr_agent/settings/pr_description_prompts.toml
labels
field to enhance clarity onlabel usage.