Skip to content

Commit

Permalink
Enhance logging in pr_processing.py for better traceability and debug…
Browse files Browse the repository at this point in the history
…ging
  • Loading branch information
mrT23 committed Feb 25, 2024
1 parent cf0ab45 commit 7dcbdff
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions pr_agent/tools/pr_description.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,7 @@ def __init__(self, pr_url: str, args: list = None,
# Initialize patches_diff and prediction attributes
self.patches_diff = None
self.prediction = None
self.file_label_dict = None
self.COLLAPSIBLE_FILE_LIST_THRESHOLD = 8

async def run(self):
Expand All @@ -90,7 +91,7 @@ async def run(self):
return None

if get_settings().pr_description.enable_semantic_files_types:
self._prepare_file_labels()
self.file_label_dict = self._prepare_file_labels()

pr_labels = []
if get_settings().pr_description.publish_labels:
Expand Down Expand Up @@ -323,19 +324,20 @@ def _prepare_pr_answer(self) -> Tuple[str, str]:
return title, pr_body

def _prepare_file_labels(self):
self.file_label_dict = {}
file_label_dict = {}
for file in self.data['pr_files']:
try:
filename = file['filename'].replace("'", "`").replace('"', '`')
changes_summary = file['changes_summary']
changes_title = file['changes_title'].strip()
label = file.get('label')
if label not in self.file_label_dict:
self.file_label_dict[label] = []
self.file_label_dict[label].append((filename, changes_title, changes_summary))
if label not in file_label_dict:
file_label_dict[label] = []
file_label_dict[label].append((filename, changes_title, changes_summary))
except Exception as e:
get_logger().error(f"Error preparing file label dict {self.pr_id}: {e}")
pass
return file_label_dict

def process_pr_files_prediction(self, pr_body, value):
# logic for using collapsible file list
Expand Down

0 comments on commit 7dcbdff

Please sign in to comment.