Skip to content

Commit 26211c0

Browse files
committed
add logs
1 parent 698ba4b commit 26211c0

2 files changed

Lines changed: 6 additions & 14 deletions

File tree

src/agent_tools/str_replace_editor.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,9 @@
11
#!/usr/bin/env python3
22

3-
"""This is an adaptation of the Anthropic Text Editor tool from
4-
https://github.com/anthropics/anthropic-quickstarts/blob/main/computer-use-demo/computer_use_demo/tools/edit.py
5-
However, we made it python 3.6 compatible and stateless (all state is saved in a json file)
3+
"""Source: https://github.com/SWE-agent/SWE-agent/blob/main/tools/edit_anthropic/bin/str_replace_editor
4+
This tool is used to view the given source code and view/edit the documentation files in the separate docs directory.
65
"""
76

8-
import argparse
97
import json
108
import re
119
import subprocess

src/cluster_modules.py

Lines changed: 4 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,7 @@
11
from typing import List, Dict, Any
22
from collections import defaultdict
3+
import logging
4+
logger = logging.getLogger(__name__)
35

46
from dependency_analyzer.models.core import Node
57
from llm_services import call_llm
@@ -18,8 +20,6 @@ def format_potential_core_components(leaf_nodes: List[str], components: Dict[str
1820
if leaf_node in components:
1921
valid_leaf_nodes.append(leaf_node)
2022
else:
21-
import logging
22-
logger = logging.getLogger(__name__)
2323
logger.warning(f"Skipping invalid leaf node '{leaf_node}' - not found in components")
2424

2525
#group leaf nodes by file
@@ -53,6 +53,7 @@ def cluster_modules(
5353
potential_core_components, potential_core_components_with_code = format_potential_core_components(leaf_nodes, components)
5454

5555
if count_tokens(potential_core_components_with_code) <= MAX_TOKEN_PER_MODULE:
56+
logger.info(f"Skipping clustering for {current_module_name} because the potential core components are too few: {count_tokens(potential_core_components_with_code)} tokens")
5657
return {}
5758

5859
prompt = format_cluster_prompt(potential_core_components, current_module_tree, current_module_name)
@@ -61,28 +62,23 @@ def cluster_modules(
6162
#parse the response
6263
try:
6364
if "<GROUPED_COMPONENTS>" not in response or "</GROUPED_COMPONENTS>" not in response:
64-
import logging
65-
logger = logging.getLogger(__name__)
6665
logger.error(f"Invalid LLM response format - missing component tags: {response[:200]}...")
6766
return {}
6867

6968
response_content = response.split("<GROUPED_COMPONENTS>")[1].split("</GROUPED_COMPONENTS>")[0]
7069
module_tree = eval(response_content)
7170

7271
if not isinstance(module_tree, dict):
73-
import logging
74-
logger = logging.getLogger(__name__)
7572
logger.error(f"Invalid module tree format - expected dict, got {type(module_tree)}")
7673
return {}
7774

7875
except Exception as e:
79-
import logging
80-
logger = logging.getLogger(__name__)
8176
logger.error(f"Failed to parse LLM response: {e}. Response: {response[:200]}...")
8277
return {}
8378

8479
# check if the module tree is valid
8580
if len(module_tree) <= 1:
81+
logger.info(f"Skipping clustering for {current_module_name} because the module tree is too small: {len(module_tree)} modules")
8682
return {}
8783

8884
if current_module_tree == {}:
@@ -104,8 +100,6 @@ def cluster_modules(
104100
if node in components:
105101
valid_sub_leaf_nodes.append(node)
106102
else:
107-
import logging
108-
logger = logging.getLogger(__name__)
109103
logger.warning(f"Skipping invalid sub leaf node '{node}' in module '{module_name}' - not found in components")
110104

111105
current_module_path.append(module_name)

0 commit comments

Comments
 (0)