Skip to content

Commit 45e5a86

Browse files
committed
improve comments readability
1 parent c55486d commit 45e5a86

File tree

11 files changed

+337
-337
lines changed

11 files changed

+337
-337
lines changed

apps/run-agent/calculate_score_from_log.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212

1313
def extract_score_from_log(run_dir, task_score_dict):
14-
# 遍历所有task_{task_id}_attempt_*.log的文件,提取score
14+
# Traverse all task_{task_id}_attempt_*.log files to extract score
1515
log_files = glob.glob(os.path.join(run_dir, "task_*_attempt_*.json"))
1616
for log_file in log_files:
1717
task_id = log_file.split("/")[-1].split("_")[1]
@@ -35,7 +35,7 @@ def main(results_dir: str, pass_at_k: int = 3):
3535

3636
print(f"Analyzing results from: {results_dir}")
3737

38-
# 遍历所有run_*目录under results_dir
38+
# Traverse all run_* directories under results_dir
3939
run_dirs = glob.glob(os.path.join(results_dir, "run_*"))
4040
task_score_dict = {}
4141
for run_dir in run_dirs:
@@ -50,7 +50,7 @@ def main(results_dir: str, pass_at_k: int = 3):
5050
else:
5151
failed_id.append(task)
5252

53-
# 保存简单的统计结果
53+
# Save simple statistical results
5454
output_file = os.path.join(results_dir, f"average_scores_pass_at_{pass_at_k}.txt")
5555
with open(output_file, "w") as f:
5656
f.write("EVALUATION RESULTS\n")

apps/run-agent/common_benchmark.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ def prepare_task_description(
546546
if path.is_absolute():
547547
return task.task_question, str(path.resolve())
548548

549-
# 构建完整文件路径:数据目录 + 相对路径
549+
# Build complete file path: data directory + relative path
550550
full_file_path = Path(self.data_dir) / path
551551
return task.task_question, str(full_file_path.resolve())
552552

@@ -636,9 +636,9 @@ def main(*args):
636636
with hydra.initialize_config_dir(config_dir=config_path(), version_base=None):
637637
cfg = hydra.compose(config_name=config_name(), overrides=list(args))
638638
_ = bootstrap_logger()
639-
# 默认关闭 tracing, 同时不 set key
639+
# Default to disable tracing, and don't set key
640640
set_tracing_disabled(True)
641641
set_tracing_export_api_key("fake-key")
642-
# 压制 trace provider 的报警
642+
# Suppress trace provider warnings
643643
bootstrap_silent_trace_provider()
644644
asyncio.run(entrypoint(cfg))

apps/visualize-trace/app.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99
app = Flask(__name__)
1010

11-
# 全局变量存储分析器实例
11+
# Global variable to store analyzer instance
1212
analyzer = None
1313

1414

@@ -25,13 +25,13 @@ def list_files():
2525
directory = request.args.get("directory", "")
2626

2727
if not directory:
28-
# 默认行为:检查上级目录
28+
# Default behavior: check parent directory
2929
directory = os.path.abspath("..")
3030

31-
# 扩展路径(处理~等符号)
31+
# Expand path (handle ~ and other symbols)
3232
directory = os.path.expanduser(directory)
3333

34-
# 转换为绝对路径
34+
# Convert to absolute path
3535
directory = os.path.abspath(directory)
3636

3737
if not os.path.exists(directory):
@@ -46,7 +46,7 @@ def list_files():
4646
if file.endswith(".json"):
4747
file_path = os.path.join(directory, file)
4848
try:
49-
# 获取文件大小和修改时间
49+
# Get file size and modification time
5050
stat = os.stat(file_path)
5151
json_files.append(
5252
{
@@ -61,7 +61,7 @@ def list_files():
6161
{"name": file, "path": file_path, "size": 0, "modified": 0}
6262
)
6363

64-
# 按文件名排序
64+
# Sort by filename
6565
json_files.sort(key=lambda x: x["name"])
6666

6767
return jsonify(
@@ -91,7 +91,7 @@ def load_trace():
9191
if not file_path:
9292
return jsonify({"error": "请提供文件路径"}), 400
9393

94-
# 如果是相对路径,转换为绝对路径
94+
# If it's a relative path, convert to absolute path
9595
if not os.path.isabs(file_path):
9696
file_path = os.path.abspath(file_path)
9797

@@ -193,7 +193,7 @@ def get_raw_messages():
193193
main_history = analyzer.get_main_agent_history()
194194
browser_sessions = analyzer.get_browser_agent_sessions()
195195

196-
# 获取消息结构概览
196+
# Get message structure overview
197197
main_messages = analyzer.get_main_agent_messages()
198198
message_structure = []
199199

libs/miroflow-tool/src/miroflow/tool/manager.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -50,8 +50,8 @@ async def execute_tool_call(
5050
class ToolManager(ToolManagerProtocol):
5151
def __init__(self, server_configs, tool_blacklist=None):
5252
"""
53-
初始化 ToolManager
54-
:param server_configs: create_server_parameters() 返回的列表
53+
Initialize ToolManager.
54+
:param server_configs: List returned by create_server_parameters()
5555
"""
5656
self.server_configs = server_configs
5757
self.server_dict = {
@@ -61,7 +61,7 @@ def __init__(self, server_configs, tool_blacklist=None):
6161
self.tool_blacklist = tool_blacklist if tool_blacklist else set()
6262

6363
logger.info(
64-
f"ToolManager 初始化,已加载服务器: {list(self.server_dict.keys())}"
64+
f"ToolManager initialized, loaded servers: {list(self.server_dict.keys())}"
6565
)
6666

6767
def _is_huggingface_dataset_or_space_url(self, url):
@@ -88,14 +88,14 @@ def _should_block_hf_scraping(self, tool_name, arguments):
8888
)
8989

9090
def get_server_params(self, server_name):
91-
"""获取指定服务器的参数"""
91+
"""Get parameters for specified server"""
9292
return self.server_dict.get(server_name)
9393

9494
async def _find_servers_with_tool(self, tool_name):
9595
"""
96-
在所有服务器中查找包含指定工具名称的服务器
97-
:param tool_name: 要查找的工具名称
98-
:return: 包含该工具的服务器名称列表
96+
Find servers containing the specified tool name among all servers
97+
:param tool_name: Tool name to search for
98+
:return: List of server names containing the tool
9999
"""
100100
servers_with_tool = []
101101

@@ -111,7 +111,7 @@ async def _find_servers_with_tool(self, tool_name):
111111
) as session:
112112
await session.initialize()
113113
tools_response = await session.list_tools()
114-
# 遵循与 get_all_tool_definitions 相同的 blacklist 逻辑
114+
# Follow the same blacklist logic as get_all_tool_definitions
115115
for tool in tools_response.tools:
116116
if (server_name, tool.name) in self.tool_blacklist:
117117
continue
@@ -129,8 +129,8 @@ async def _find_servers_with_tool(self, tool_name):
129129
await session.initialize()
130130
tools_response = await session.list_tools()
131131
for tool in tools_response.tools:
132-
# get_all_tool_definitions 保持一致:SSE 部分没有 blacklist 处理
133-
# 可以在这里添加特定工具的过滤逻辑(如果需要)
132+
# Consistent with get_all_tool_definitions: SSE part has no blacklist processing
133+
# Can add specific tool filtering logic here (if needed)
134134
# if server_name == "tool-excel" and tool.name not in ["get_workbook_metadata", "read_data_from_excel"]:
135135
# continue
136136
if tool.name == tool_name:
@@ -140,28 +140,28 @@ async def _find_servers_with_tool(self, tool_name):
140140
logger.error(
141141
f"错误: 服务器 '{server_name}' 的参数类型未知: {type(server_params)}"
142142
)
143-
# 对于未知类型,我们跳过而不是抛出异常,因为这是查找功能
143+
# For unknown types, we skip rather than throw an exception, because this is a search function
144144
continue
145145
except Exception as e:
146146
logger.error(
147-
f"错误: 无法连接或获取服务器 '{server_name}' 的工具以查找 '{tool_name}': {e}"
147+
f"Error: Cannot connect or get tools from server '{server_name}' to find '{tool_name}': {e}"
148148
)
149149
continue
150150

151151
return servers_with_tool
152152

153153
async def get_all_tool_definitions(self):
154154
"""
155-
连接到所有已配置的服务器,获取它们的工具定义。
156-
返回一个适合传递给 Prompt 生成器的列表。
155+
Connect to all configured servers and get their tool definitions.
156+
Returns a list suitable for passing to Prompt generators.
157157
"""
158158
all_servers_for_prompt = []
159-
# 处理远程服务器工具
159+
# Handle remote server tools
160160
for config in self.server_configs:
161161
server_name = config["name"]
162162
server_params = config["params"]
163163
one_server_for_prompt = {"name": server_name, "tools": []}
164-
logger.info(f"正在获取服务器 '{server_name}' 的工具定义...")
164+
logger.info(f"Getting tool definitions for server '{server_name}'...")
165165

166166
try:
167167
if isinstance(server_params, StdioServerParameters):
@@ -175,7 +175,7 @@ async def get_all_tool_definitions(self):
175175
for tool in tools_response.tools:
176176
if (server_name, tool.name) in self.tool_blacklist:
177177
logger.info(
178-
f"server '{server_name}' 中的工具 '{tool.name}' 被列入黑名单,跳过。"
178+
f"Tool '{tool.name}' in server '{server_name}' is blacklisted, skipping."
179179
)
180180
continue
181181
one_server_for_prompt["tools"].append(
@@ -196,7 +196,7 @@ async def get_all_tool_definitions(self):
196196
await session.initialize()
197197
tools_response = await session.list_tools()
198198
for tool in tools_response.tools:
199-
# 可以在这里添加特定工具的过滤逻辑(如果需要)
199+
# Can add specific tool filtering logic here (if needed)
200200
# if server_name == "tool-excel" and tool.name not in ["get_workbook_metadata", "read_data_from_excel"]:
201201
# continue
202202
one_server_for_prompt["tools"].append(
@@ -215,13 +215,13 @@ async def get_all_tool_definitions(self):
215215
)
216216

217217
logger.info(
218-
f"成功获取服务器 '{server_name}' 的 {len(one_server_for_prompt['tools'])} 个工具定义。"
218+
f"Successfully obtained {len(one_server_for_prompt['tools'])} tool definitions for server '{server_name}'."
219219
)
220220
all_servers_for_prompt.append(one_server_for_prompt)
221221

222222
except Exception as e:
223-
logger.error(f"错误: 无法连接或获取服务器 '{server_name}' 的工具: {e}")
224-
# 仍然添加服务器条目,但标记工具列表为空或包含错误信息
223+
logger.error(f"Error: Cannot connect or get tools from server '{server_name}': {e}")
224+
# Still add server entry, but mark tool list as empty or containing error information
225225
one_server_for_prompt["tools"] = [
226226
{"error": f"Failed to fetch tools: {e}"}
227227
]
@@ -232,11 +232,11 @@ async def get_all_tool_definitions(self):
232232
@with_timeout(600)
233233
async def execute_tool_call(self, server_name, tool_name, arguments) -> Any:
234234
"""
235-
执行单个工具调用。
236-
:param server_name: 服务器名称
237-
:param tool_name: 工具名称
238-
:param arguments: 工具参数字典
239-
:return: 包含结果或错误的字典
235+
Execute a single tool call.
236+
:param server_name: Server name
237+
:param tool_name: Tool name
238+
:param arguments: Tool arguments dictionary
239+
:return: Dictionary containing result or error
240240
"""
241241

242242
# 原远程服务器调用逻辑

libs/miroflow-tool/src/miroflow/tool/mcp_servers/searching_mcp_server.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
import calendar
55
from fastmcp import FastMCP
66
from mcp.client.stdio import stdio_client
7-
from mcp import ClientSession, StdioServerParameters # (已在 config.py 导入)
7+
from mcp import ClientSession, StdioServerParameters # (already imported in config.py)
88
import wikipedia
99
import asyncio
1010
from .utils.smart_request import smart_request, request_to_json

libs/miroflow-tool/src/miroflow/tool/mcp_servers/utils/smart_request.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
ClientSession,
77
StdioServerParameters,
88
stdio_client,
9-
) # (已在 config.py 导入)
9+
) # (already imported in config.py)
1010
import urllib.parse
1111
from markitdown import MarkItDown
1212
import io

libs/miroflow-tool/tests/test_reading_mcp_server.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ async def test_tool_definitions_available(self):
7171
"uri": f"file://{files_for_tests_dir}/test-pdf.pdf",
7272
},
7373
"should_succeed": True,
74-
"expected_content_keywords": ["做笔记"],
74+
"expected_content_keywords": ["note-taking"],
7575
},
7676
{
7777
"name": "convert_excel_file",
@@ -81,7 +81,7 @@ async def test_tool_definitions_available(self):
8181
"uri": f"file://{files_for_tests_dir}/test-excel.xlsx",
8282
},
8383
"should_succeed": True,
84-
"expected_content_keywords": ["财务"],
84+
"expected_content_keywords": ["finance"],
8585
},
8686
{
8787
"name": "convert_word_file",
@@ -91,7 +91,7 @@ async def test_tool_definitions_available(self):
9191
"uri": f"file://{files_for_tests_dir}/test-word.docx",
9292
},
9393
"should_succeed": True,
94-
"expected_content_keywords": ["做笔记"],
94+
"expected_content_keywords": ["note-taking"],
9595
},
9696
{
9797
"name": "convert_powerpoint_file",
@@ -101,7 +101,7 @@ async def test_tool_definitions_available(self):
101101
"uri": f"file://{files_for_tests_dir}/test-ppt.pptx",
102102
},
103103
"should_succeed": True,
104-
"expected_content_keywords": ["计算机系统"],
104+
"expected_content_keywords": ["computer system"],
105105
},
106106
{
107107
"name": "convert_image_file",
@@ -111,7 +111,7 @@ async def test_tool_definitions_available(self):
111111
"uri": f"file://{files_for_tests_dir}/test-zip.zip",
112112
},
113113
"should_succeed": True,
114-
"expected_content_keywords": ["计算机系统", "做笔记", "财务"],
114+
"expected_content_keywords": ["computer system", "note-taking", "finance"],
115115
},
116116
],
117117
)

libs/miroflow/src/miroflow/llm/provider_client_base.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,7 @@ def __post_init__(self):
7474
self.openrouter_provider: Optional[str] = self.cfg.llm.get(
7575
"openrouter_provider"
7676
)
77-
# 安全地处理字符串到bool的转换
77+
# Safely handle string to bool conversion
7878
disable_cache_control_val = self.cfg.llm.get("disable_cache_control", False)
7979
if isinstance(disable_cache_control_val, str):
8080
self.disable_cache_control: bool = (
@@ -84,10 +84,10 @@ def __post_init__(self):
8484
self.disable_cache_control: bool = bool(disable_cache_control_val)
8585

8686
logger.info(
87-
f"openrouter_provider配置值: {self.openrouter_provider} (类型: {type(self.openrouter_provider)})"
87+
f"openrouter_provider config value: {self.openrouter_provider} (type: {type(self.openrouter_provider)})"
8888
)
8989
logger.info(
90-
f"disable_cache_control配置值: {disable_cache_control_val} (类型: {type(disable_cache_control_val)}) -> 解析为: {self.disable_cache_control}"
90+
f"disable_cache_control config value: {disable_cache_control_val} (type: {type(disable_cache_control_val)}) -> parsed as: {self.disable_cache_control}"
9191
)
9292

9393
self.token_usage = self._reset_token_usage()

0 commit comments

Comments
 (0)